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

RE: question on variable definition

Subject: RE: question on variable definition
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 30 Mar 2010 12:42:45 +0100
RE:  question on variable definition
This is an error in XSLT 1.0, but permitted in 2.0.

The relevant 1.0 rule is in section 11.5:

It is an error if a binding established by an xsl:variable or xsl:param
element within a template shadows another binding established by an
xsl:variable or xsl:param element also within the template.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 


> -----Original Message-----
> From: Hermann Stamm-Wilbrandt [mailto:STAMMW@xxxxxxxxxx] 
> Sent: 30 March 2010 12:33
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  question on variable definition
> 
> 
> Hello,
> 
> xsltproc complains about redefining variable v with an error.
> saxon9he has no complaints and does a rewrite(?) of the variable.
> 
> From the spec:
> http://www.w3.org/TR/xslt#variables
> 
> For any use of these variable-binding elements, there is a 
> region of the stylesheet tree within which the binding is 
> visible; within this region, any binding of the variable that 
> was visible on the variable-binding element itself is hidden. 
> Thus, only the innermost binding of a variable is visible. 
> The set of variable bindings in scope for an expression 
> consists of those bindings that are visible at the point in 
> the stylesheet where the expression occurs.
> 
> So saxon9he seems to assue the second definition of v as 
> innermost binding, while xsltproc seems to see both on the 
> same binding level.
> What is the spec conforming behavior?
> 
> $ xsltproc -version
> Using libxml 20626, libxslt 10117 and libexslt 813 xsltproc 
> was compiled against libxml 20626, libxslt 10117 and libexslt 
> 813 libxslt 10117 was compiled against libxml 20626 libexslt 
> 813 was compiled against libxml 20626 $ xsltproc m.xsl m.xsl 
> runtime error: file m.xsl line 8 element variable 
> xsl:variable : redefining v no result for m.xsl $ java -jar 
> saxon9he.jar -xmlversion:1.0 -xsl:m.xsl -s:m.xsl 
> -versionmsg:off ; echo <?xml version="1.0" 
> encoding="UTF-8"?>12 $ $ cat m.xsl <xsl:stylesheet version="1.0"
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >
>   <xsl:template match="/">
> 
>     <xsl:variable name="v" select="1"/>
>     <xsl:value-of select="$v"/>
>     <xsl:variable name="v" select="2"/>
>     <xsl:value-of select="$v"/>
> 
>   </xsl:template>
> </xsl:stylesheet>
> $
> 
> 
> Mit besten Gruessen / Best wishes,
> 
> Hermann Stamm-Wilbrandt
> Developer, XML Compiler, L3
> WebSphere DataPower SOA Appliances
> ----------------------------------------------------------------------
> IBM Deutschland Research & Development GmbH Vorsitzender des 
> Aufsichtsrats: Martin Jetter
> Geschaeftsfuehrung: Dirk Wittkopp
> Sitz der Gesellschaft: Boeblingen
> Registergericht: Amtsgericht Stuttgart, HRB 243294

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.