xsl-list
[Top] [All Lists]

Re: [xsl] node() function

2014-06-24 08:51:49
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_^
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>