Subject: [xsl] xpath predicate help From: "McKinstry, Scott A" <scott.a.mckinstry@xxxxxxxx> Date: Thu, 17 Feb 2005 13:47:45 -0500 |
I am transforming SGML to XML. The sample sgml is: <graphic id="123" name="graphic" ......> <grphprim id="456" ....> </graphic> . . . <link linkends="999 456">link text</link> What I am trying to do is. When I find a link to a <grphprim element in sgml I want the xml link I create to link to the parent <graphic. The linkends attribute needs to be manipulated to get the part after the space. The xml I am using that does not work <xsl:element name="link"> <xsl:attribute name="linkend"> <xsl:variable name="link-target" <xsl:value-of select="substring-after(./@linkends,' ')"/> </xsl:variable> <xsl:choose> <xsl:when test="name(//*[@id=$link-target])='grphprim'"> <xsl:variable name="parent_graphic" select="//graphic[grphprim/@id=$link-target]"/> <xsl:value-of select="$parent_graphic/@id"> </xsl:when> <xsl:otherwise> <xsl:value-of select="$link-target"/> </xsl:othewise> </xsl:choose> </xsl:attribute> </xsl:element> This however does work. If I hard-code the id in below it works, If I use a variable as in above it does not work. Any help would be appreciated. <xsl:element name="link"> <xsl:attribute name="linkend"> <xsl:variable name="link-target" <xsl:value-of select="substring-after(./@linkends,' ')"/> </xsl:variable> <xsl:choose> <xsl:when test="name(//*[@id=$link-target])='grphprim'"> <xsl:variable name="parent_graphic" select="//graphic[grphprim/@id='456']"/> <xsl:value-of select="$parent_graphic/@id"> </xsl:when> <xsl:otherwise> <xsl:value-of select="$link-target"/> </xsl:othewise> </xsl:choose> </xsl:attribute> </xsl:element>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] SAX for XSL Transformatio, santhosh nair | Thread | Re: [xsl] xpath predicate help, David Carlisle |
Re: [xsl] Javascript variable to XS, Camaleón | Date | Re: [xsl] Javascript variable to XS, Camaleón |
Month |