[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] process xslt and xml spreadsheet via web browser


Subject: Re: [xsl] process xslt and xml spreadsheet via web browser
From: "Tony Graham tgraham@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 12 Sep 2014 12:13:49 -0000

On Fri, September 12, 2014 12:53 pm, rl@xxxxxxxxxxxxxxx wrote:
...
> <?xml version="1.0"?>
> <xsl:stylesheet
> 	version="2.0"
> 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> 	xmlns='http://www.w3.org/1999/xhtml'>
> 	<xsl:output
> 		method="text"
> 		encoding="utf-8"
> 		indent="no"
> 		omit-xml-declaration="yes"
> 		media-type="text/plain"
> 		standalone="yes"
> 		/>
> 	<xsl:template match='Cells'>
> 		<xsl:apply-templates select='Cell'/>
> 	</xsl:template>
> </xsl:stylesheet>
>
> The Jedit text editor was used with the plugin XLST processor (uses
> Xalan Java), which produces the text file (below). Why does the text
> file contain text from nodes outside the nodes 'Cells' and 'Cell'?

Because of the built-in template rules.  See
http://www.w3.org/TR/xslt20/#built-in-rule

The default for the document node and for element nodes is to process
their children, and the default for text nodes is to return a text node
with the string value of the node, so in the absence of any rules to the
contrary, you get the string value of all the text nodes in the document.

If you add another template rule matching on "/" that selects just its
descendant 'Cells', then you'll bypass the default processing of all the
rest of the nodes under the document node.

Regards,


Tony Graham                                         tgraham@xxxxxxxxxx
Consultant                                       http://www.mentea.net
Chair, Print and Page Layout Community Group @ W3C    XML Guild member
  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
Mentea       XML, XSL-FO and XSLT consulting, training and programming


Current Thread
Keywords