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

RE: Apply-templates - how to omit top level element ta

Subject: RE: Apply-templates - how to omit top level element tags?
From: "Mike Schinkel" <mikes@xxxxxxxxx>
Date: Thu, 8 Sep 2005 14:45:40 -0400
RE:  Apply-templates - how to omit top level element ta
Thanks for the reply.


>> Part of your problem is that you are using xsl:value-of rather than
xsl:copy-of, value-of always

As I understand it, copy-of does a literal copy, and does not apply any
templates, right?

-Mike


-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: Thursday, September 08, 2005 4:45 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Apply-templates - how to omit top level element tags?

Unfortunately, I still don't grok the difference between:

> Unfortunately, I still don't grok the difference between:
>
> 	*
> 	.
> 	node()


Part of your problem is that you are using xsl:value-of rather than
xsl:copy-of, value-of always gives teh _string value_ of its argument,
so you never see the difference between an element and a text node using
value-of

Consider an input of

<a>www
  <b>zzz</b>
  <!-- yyy -->
  <z/>
</a>

and
<xsl:template match="a">
...
</xsl:template>

then if ... is

<xsl:copy-of select="."/>


You will output a copy of the current node (which is a) a node includes
all children etc so you get

<a>www
  <b>zzz</b>
  <!-- yyy -->
  <z/>
</a>


then if ... is

<xsl:copy-of select="*"/>

then * is short for child::* and selects all child elements so you get

<b>zzz</b><z/>

note, no top level a, no comments and no text nodes, including
indentation white space nodes.


then if ... is

<xsl:copy-of select="node()"/>

then node() is short for child::node() which selects all child nodes
(elements, text, comments and processing instructions) and you get

www
  <b>zzz</b>
  <!-- yyy -->
  <z/>


(no top level <a> element, as you only copied children.

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.