RE: XSL node reference problem
> so i have some trouble for 4 days with this problematic : > I have an XML file like that : > <FILE> > <SCALAR> > <LABEL>toto</LABEL> > <VALUE>123</LABEL> > </SCALAR> > <SCALAR> > <LABEL>tata</LABEL> > <VALUE>456</LABEL> > </SCALAR> > <STRUCT> > ... > </STRUCT> > <SCALAR> > <LABEL>titi</LABEL> > <VALUE>789</LABEL> > </SCALAR> > </FILE> > > and i have done a XSL Template that permitt me to obtain the path of a > specific SCALAR : > <xsl:template name="chercheNode"> > <xsl:param name="nom"/> > <xsl:value-of select="descendant::*[ (self::struct or > self::scalar) and > label =$nom ]"/> > </xsl:template> XML is case sensitive. If you use upper case in the source document, you must use upper case in the stylesheet. Are you expecting to find one node or several? Because xsl:value-of (in XSLT 1.0) will always give you the contents of the first selected node. > > And I call this one with this : > > <xsl:variable name="tata"> > <xsl:call-template name="chercheNode"> > <xsl:with-param name="nom">tata</xsl:with-param> > </xsl:call-template> > </xsl:variable> > > I have the node that i would have BUT i can't apply > > <xsl:for-each select="$tata"> > <xsl:value-of select="./value"/> > </xsl:for-each> > > because it result with a null value, the transformation don't return a > value. The variable $tata is a result tree fragment. In XSLT 1.0 the operand of xsl:for-each must be a node-set, so this construct should fail. Some products implement a feature of the XSLT 1.1 and 2.0 working drafts, whereby $tata is treated as the root node of a tree. In this case you wouldn't get an error, but you would get no data back, because this root node does not have a child element named "value". You would be closer if you used copy-of rather than value-of; you could then do xsl:value-of select="*/VALUE" (the * picks up a node called STRUCT or SCALAR). Michael Kay
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