Subject: RE: [xsl] XSL node reference problem From: "Michael Kay" <mhk@xxxxxxxxx> Date: Fri, 21 May 2004 11:22:24 +0100 |
> 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XSL node reference problem, paul . bezault | Thread | RE: [xsl] XSL node reference proble, paul . bezault |
[xsl] XSL node reference problem, paul . bezault | Date | RE: [xsl] XSL node reference proble, paul . bezault |
Month |