[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xpath predicate help

Subject: xpath predicate help
From: "McKinstry, Scott A" <scott.a.mckinstry@xxxxxxxx>
Date: Thu, 17 Feb 2005 13:47:45 -0500
xsl link target
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.