View Single Post
Old 06-24-2002, 12:44 AM   PM User | #1
Alex Vincent
Moderator


 
Join Date: May 2002
Location: Hayward, CA
Posts: 1,427
Thanks: 1
Thanked 19 Times in 17 Posts
Alex Vincent is on a distinguished road
XSLT: Selecting elements by length of content text?

Here's an interesting situation. I'm working on an XML language for geometry, but I have a small problem in rendering a symbolism for arcs, rays and lines. For line segments, it's pretty simple: I associate a CSS styling with the element in question:

Code:
geo:line[ends="both"] {
   text-decoration: overline
   }
But beyond that, I need a little help...

For instance, with an arc:

Code:
<geo:arc id="ABC">...</geo:arc>
the presentation would need to be in the format:

Code:
<svg:g transform="translate(10,20)">
<svg:path d="M 0 10 A 20 10 0 0 1 26 10" fill="none" stroke="#000000" />
<svg:text x="0" y="20" font-family="Times New Roman">ABC</svg:text>
</svg:g>
With a two-letter id attribute for geo:arc, I'd need:

Code:
<svg:g transform="translate(10,0)">
<svg:path d="M 0 10 A 20 20 0 0 1 18 10" fill="none" stroke="#000000" />
<svg:text x="0" y="20" font-family="Times New Roman">AB</svg:text>
</svg:g>
A little different, obviously. So I'm wondering how to construct the <xsl:template>...</xsl:template> match attribute to distinguish between a two-character text content and a three-character text content.

Advice?
__________________
"The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
June 30, 2001
author, Verbosio prototype XML Editor
author, JavaScript Developer's Dictionary
https://alexvincent.us/blog
Alex Vincent is offline   Reply With Quote