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

Re: characters in xsl

Subject: Re: characters in xsl
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 12 Nov 2004 10:21:00 GMT
xsl characters
  <xsl:variable name="x" select="'Fred'"/>
  vs
  <xsl:variable name="x" >Fred</xsl:variable>

  Is that the difference?
  The latter creating a document tree, the former not?


No. The former makes a string so that doesn't come in to the picture at
all, 
<xsl:apply-templates select="$x"/>
would generate an error (as in XSL 1) that apply templates can only be
applied to nodes.

The latter makes (for 1.0 compatibility reasons) a node set with a
document node and a text node, you could apply templates to that, but
again not really relevant as we're talking of element nodes mainly.


<xsl:variable name="x" >
 <stone/>
</xsl:variable>

makes (for compatibilty with XSLT 1) a document (root) node with child
an element node with name stone.

<xsl:apply-templates select="$x"/>

would work and templates matching "stone" or "//stone" would apply.

However you can also do this


<xsl:variable name="x" as="element()">
 <stone/>
</xsl:variable>

which makes $x into _just_ a free standing element node with no parent.

Now

<xsl:apply-templates select="$x"/>

would work and templates matching "stone" would apply but thiose
matching "//stone" would not.


David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.