xsl-list
[Top] [All Lists]

XSLT to SVG markup

2004-05-26 07:31:55
Can anybody help me out with the following problem?

I need to create an xslt that will compare the values of the href attribute
of the xref element to that of the id attribute in the next testblock
element. If those values are equal, I need it to generate in svg the value
of the name attribute of value-answer in one location. If they are not
equal, I need it to generate the value of the name attribute in a different
location. I was able to get the name value to appear in the separate
locations but could not force it to do so only in the appropriate situation
(i.e. both "yes" and "no" appeared at both locations superimposed on top of
each other).

I have been poring over this for half a day with no luck. Someone puh-lease
tell me the answer to my riddle. And be gentle.  :-)

Here's my source code for XSLT and XML thus far:

XSLT Source Code: [ Reference to my query is for the final <xsl:template> ]

<?xml version="1.0"?>
<xsl:stylesheet version="1.2"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml" indent="yes" doctype-public="-//W3C//DTD SVG
1.2//EN"
doctype-system="http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg12.dtd"/>

<xsl:template match="/">
 <xsl:apply-templates/>
</xsl:template>

<xsl:template match="wpidinfo"/>
<xsl:template match="a.config"/>
<xsl:template match="a.sourceinfo"/>
<xsl:template match="wpinfo"/>
<xsl:template match="testblock"/>
<xsl:template match="endblock"/>

<xsl:template match="testentranceblock">
 <svg width="778px" height="580px">
  <rect x="38" y="5" width="134" height="40" rx="20" style="stroke: black;
fill: none;"/>
  <text x="80" y="30" style="font-weight: bold;
font-size:12pt;">START</text>
  <line x1="105" y1="45" x2="105" y2="60" style="stroke: black;"/>
 <xsl:apply-templates/>
 </svg>
</xsl:template>

<xsl:template match="test">
 <svg width="778px" height="580px">
  <rect x="5" y="60" width="225" height="80" style="stroke: black; fill:
none;"/>
  <line x1="105" y1="140" x2="105" y2="155" style="stroke: black;"/>
  <text x="10" y="75" style="font-size: 8pt;">
    <xsl:value-of select="step/para"/>
  </text>
  <xsl:apply-templates/>
 </svg>
</xsl:template>

<xsl:template match="indication">
 <svg width="778px" height="580px">
  <polygon style="fill:none; stroke:#000000;" points="5,190 105,155 205,190
105,225"/>
  <line x1="105" y1="225" x2="105" y2="240" style="stroke: black;"/>
  <line x1="205" y1="190" x2="220" y2="190" style="stroke: black;"/>
  <text x="105" y="190" style="font-size: 8pt;" text-anchor="middle">
   <xsl:value-of select="pcnarr"/>
  </text>
 <xsl:apply-templates/>
 </svg>
</xsl:template>

</xsl:stylesheet>

XML Source Code:

<testentranceblock>
    <select-value>
        <value-answer name="yes"> [ ...to generate this "YES"... ]
            <testblockref>
                <xref title="1 SH 1" href="T00001-TS-11-5820-890-30-004"/>
                <!--1
                SH 1-->
            </testblockref>
        </value-answer>
        <value-answer name="no"> [ ...or this "NO". ]
            <testblockref>
                <xref href="T00001-TS-11-5820-890-30-013"/> [ Need to
compare THIS... ]
            </testblockref>
        </value-answer>
    </select-value>
</testentranceblock>

<testblock blocklabel="0" id="T00001-TS-11-5820-890-30-013"
idtoken="idtokenT00001-TS-11-5820-890-30-013" name=" "> [ ...to THIS... ]
</testblock>
<testblock blocklabel="0" id="T00001-TS-11-5820-890-30-014"
idtoken="idtokenT00001-TS-11-5820-890-30-013" name=" ">
</testblock>




<Prev in Thread] Current Thread [Next in Thread>
  • XSLT to SVG markup, David M Carriger <=