Subject: [xsl] Global variables/temporary tree problem From: Richard Rowell <richard@xxxxxxxxxxxxxxxxx> Date: 13 Sep 2002 10:54:13 -0500 |
I'm having problems accessing a global variable that contains a result tree fragment (temporary tree?). If I load the variable by calling document()/path/path2 then I can use the variable as I expect. If I try to specify the variable value directly I get an error (from Xalan2.3.99). The error follows then the stylesheet: (Location of error unknown)XSLT Error (org.apache.xpath.XPathException): Can not convert #RTREEFRAG to a NodeList! <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1"> <xsl:output method="xml" indent="yes"/> <xsl:variable name="hud_races"> <races> <race>white</race> <race>black</race> </races> </xsl:variable> <xsl:template match="client/race[.=$hud_races/races/race]"> <xsl:element name="{name()}"><xsl:value-of select="concat('HUD:', text())"/></xsl:element> </xsl:template> </xsl:stylesheet> Now if I put the races into an xml file like so: (hud_races.xml) <?xml version="1.0"?> <races> <race>white</race> <race>black</race> </races> Then make the variable from the document() call it works: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1"> <xsl:output method="xml" indent="yes"/> <xsl:variable name="hud_races" select="document('hud_races.xml')/races/race"/> <xsl:template match="client/race[.=$hud_races]"> <xsl:element name="{name()}"><xsl:value-of select="concat('HUD:', text())"/></xsl:element> </xsl:template> </xsl:stylesheet>
Attachment:
signature.asc
Description: This is a digitally signed message part
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Matching on of many strin, TSchutzerWeissmann | Thread | Re: [xsl] Global variables/temporar, Richard Rowell |
RE: [xsl] Global variables/temporar, TSchutzerWeissmann | Date | RE: [xsl] Problem with iterating th, Michael Kay |
Month |