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(//*[(_at_)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(//*[(_at_)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>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--