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

Should variable resolution be done at compile-time or

Subject: Should variable resolution be done at compile-time or run-time?
From: Eric Promislow <ericp@xxxxxxxxxxxxxxx>
Date: Fri, 17 Oct 2003 12:28:04 -0700
.net compile time
I ran into this problem while comparing results over
Xalan 1.0, Saxon 6.1, and .Net 1.0 System.Xml.Xsl

Here's the instance:

?xml version="1.0" encoding="UTF-8"?>
<x>special contents</x>

Here's the code, which tries to reference a variable
bound in an outer dynamic scope, but foreign static scope:

?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" />

<xsl:template match="/">
    <xsl:variable name="v1">bupkis</xsl:variable>
    <xsl:apply-templates />
</xsl:template>

<xsl:template match='x'>
  <output>
    First, var v1 = <xsl:value-of select="$v1"/>.
    Text = <xsl:value-of select='.' />
  </output>
</xsl:template>
</xsl:stylesheet>

Saxon and .Net give error messages and terminate; Xalan gives a
warning message and replaces '$v1' with the empty string.

I then changed [[<xsl:template match='x'>]] to [[<xsl:template match='x2'>]]
so that the check could only be made at compile-time.

Saxon complains, but Xalan and .Net carry out the full transform.

The XSLT 1.0 spec says how the scope of variables is determined,
but not when.  Is this a known gray area?  I just had a brief look,
but XSLT 2.0:9.7 "Scope of Variables" doesn't specify this either.
I know I would prefer this to be checked at compile-time, particularly
with complex stylesheets with large numbers of rules and cases.

- Eric

------------------------------------------------
Eric Promislow
Visual Studio .NET Plugins Development Lead
EricP@xxxxxxxxxxxxxxx
--


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.