|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] combining two variables to generate XPATH
All,
I have the following XML and XSLT, and I am having difficulty with the template that is labeled 'dispItem'. Specifically, I have commented out the portion that provides the error (see the for-each with the $branch variable). I want to take two variables as inputs and then combine them into a single XPATH and iterate over that XPATH. Unfortunately, I am getting a 'this is not a DOM' error. What can I do to fix this? Thanks in advance! Bix -------------- XML --------------
<list mode="normal">
<proc id="a" />
<proc id="h" />
<proc type="r" id="b">
<exec type="a">
<item idr="c" />
<item idr="d" />
</exec>
</proc> <proc type="e" id="c">
<dpnd>
<item idr="a" />
<item idr="h" />
</dpnd>
<exec type="a">
<item idr="e" />
<item idr="f" />
</exec>
</proc>
<proc id="d">
<dpnd>
<item idr="g" />
</dpnd>
</proc>
<proc id="e" />
<proc id="f" /><proc id="g" /> </list> -------------- XSLT -------------- <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:key name="idRef" match="proc" use="@id" /> <xsl:template match="proc" name="depn">
<xsl:param name="node" select="." /> <xsl:value-of select="$node/@id" />
<xsl:if test="$node/dpnd">
<xsl:text> (</xsl:text>
<xsl:call-template name="dispItem">
<xsl:with-param name="node" select="$node"/>
<xsl:with-param name="type" select="dpnd"/>
</xsl:call-template>
<xsl:text>)</xsl:text>
</xsl:if>
<xsl:if test="$node/exec">
<xsl:text> "</xsl:text>
<xsl:call-template name="dispItem">
<xsl:with-param name="node" select="$node"/>
<xsl:with-param name="type" select="exec"/>
</xsl:call-template>
<xsl:text>"</xsl:text>
</xsl:if>
<br />
</xsl:template><xsl:template name="dispItem"> <xsl:param name="node" /> <xsl:param name="type" select="dpnd" /> <xsl:value-of select="$node/@id" /> <xsl:value-of select="$type/@idr" /> <xsl:variable name="branch" select="concat($node,'/',$type,'/item')" /> <xsl:value-of select="$branch" /> <!-- <xsl:for-each select="$node"> <xsl:value-of select="@idr" /> <xsl:if test="following-sibling::*"><xsl:text>, </xsl:text></xsl:if> </xsl:for-each> --> </xsl:template> </xsl:stylesheet> _________________________________________________________________ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








