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

Re: Qualified variable names

Subject: Re: Qualified variable names
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 03 Nov 2008 12:27:54 -0500
Re:  Qualified variable names
At 2008-11-03 09:18 -0800, JamesXslt Smith wrote:
Wondering if qualifying variable names in XSLT 2.0 is a good idea as in:

<xsl:variable name="a:x">...</xsl:variable>

where the prefix a is bound to a namespace URI.

This was also available in XSLT 1.0 and I use it *extensively* because for many of my customers I deliver a black-box stylesheet core that is built upon by other project team members or my customers' customers.

I often have two namespaces for each library: a public one (declaring global constructs users of the black box are allowed to override) and a private one (declaring global constructs users of the black box are not allowed to override).

Consider your example: if I didn't qualify the variable "x" in my black box, and a user just coincidentally happened to declare their own "x", then my code could easily go crazy.

I explicitly counsel my XSLT students about the importance of this.

Qualifying all global names (including modes, keys, templates, variables, etc) is one of the enforced stylesheet writing rules when using the XSLStyle XSLT documentation methodology.

It has also come in handy when obfuscating stylesheets.

I think it is one of the most important features of XSLT that has been available since 1999.

I hope this helps.

. . . . . . . . . . Ken

Upcoming XSLT/XSL-FO hands-on courses:      Wellington, NZ 2009-01
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video sample lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg
Video course overview:  http://www.youtube.com/watch?v=VTiodiij6gE
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread


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.
First Name
Last Name
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.