This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Global variables/temporary tree problem


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]