Re: [xslt] Xpath on variables?



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.

    <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.

If it does, try
    <xsl:value-of select="$foo"/>
and see if that works.

if it does, maybe check you have a nodelist, using
    <xsl:for-each select="$foo">
	<xsl:text>[</xsl:text>
	<xsl:value-of select="."/>
	<xsl:text>] </xsl:text>
    </xsl:for-each>

If it still doesn't work, maybe you have found a bug!

Lee

-- 
Liam Quin - Barefoot in Toronto - liam@holoweb.net - http://www.holoweb.net/
Ankh: irc.sorcery.net www.valinor.sorcery.net irc.gnome.org www.advogato.org
Author, Open Source XML Database Toolkit, Wiley August 2000
Co-author: The XML Specification Guide, Wiley 1999; Mastering XML, Sybex 2001




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