Re: [xslt] Xpath on variables?



Le 06/08/01 17:26:46, Liam Quin a écrit :
> On Mon, Aug 06, 2001 at 11:11:59AM -0400, Daniel Veillard wrote:
> > On Mon, Aug 06, 2001 at 05:00:58PM +0200, Heiko Rupp wrote:
> > > it looks like the following is failing:
> > > 
> > > <xsl:copy-of select="$foo/PATH"/>
> 
> This works fine for me in xt, saxon and as far as I know xsltproc,
> but it will depend on the value of $foo.
> 
>     <xsl:variable name="foo" select="document('xxx.xml')"/>
> or
>     <xsl:variable name="foo" select="/book/metadata"/>
> or
>     <xsl:variable name="foo">
> 	<sock>
> 	    <colour>red</colour>
> 	    <material>cotton</material>
> 	    <origin>found in car park</origin>
> 	</sock>
>     </xsl:variable>
> 
> are plausible examples.

The last one creates a result-tree-fragment which, in XSLT 1.0, isn't
interchangeable with a node-set.

>     <xsl:variable name="foo" select="string('smiling youths')"/>
> will raise a bad type error
> 
> So maybe start with printing the value of $foo in an xsl:message,
> <xsl:message>foo is <xsl:value-of select="$foo"/></xsl:message>
> to see if foo has the content you expect.
[...]

Or just use
  <xsl:value-of select="exslt:object-type($foo)"
      xmlns:exslt="http://exslt.org/common"/>
to print out the type of $foo (result is "string", "boolean", "number",
"node-set" or "RTF" -- for result-tree-fragments)

If the result is "node-set", then there is a bug.
If it were "RTF", then theorically you could use exslt:node-set($foo) to
convert $foo into a node-set but this is currently broken in lib(e)xslt.

Tom.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]