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

Re: node() function

Subject: Re: node() function
From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 24 Jun 2014 13:51:38 -0000
Re:  node() function
Hi,

Another explanation for the behavior is that this template:

<xsl:template match="node()">
  <xsl:apply-templates/>
</xsl:template>

will override the built-in template for text nodes:

<xsl:template match="text()">
  <xsl:value-of select="."/>
</xsl:template>

Of course it is that template that ordinarily accounts for why text
contents of the source are copied to the result.

But text nodes have no children, so when the context is a text node,
the xsl:apply-templates instruction has no effect (since no templates
are applied to any children).

This is why the OP's stylesheet 1 creates no output -- because
templates are applied all the way down, but none of them ever write
anything to the result.

The solution is not to use node() when you don't want to match (or
select) text nodes ... use *, processing-instruction(), comment()
instead. Or see to it that you have another template to override the
match on 'node()':

<xsl:template match="text()" priority='1'>
  <xsl:value-of select="."/>
</xsl:template>

Cheers, Wendell

-- 
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^

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.