[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Global variables/temporary tree problem

Subject: Global variables/temporary tree problem
From: Richard Rowell <richard@xxxxxxxxxxxxxxxxx>
Date: 13 Sep 2002 10:54:13 -0500
richard rowell
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.