[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: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 15 Sep 2014 13:24:05 -0000


Another alternative to Abel's and Tony's suggestions is to configure
the XSLT to ignore the text nodes you know to be insignificant. This
can be done by having it to discard such nodes before processing the

In the case of this input, you can do something like this:

<xsl:strip-space elements="*"/>

<xsl:preserve-space elements="gnm:Cell"/>

The strip-space will strip whitespace-only nodes in the document
except directly inside gnm:Cell, where it is overridden by the
preserve-space instruction.

This is safe to do because (as long as) you know from your spec of the
input that there will never be any text outside cells ... so all text,
in a valid document, will be whitespace-only, and can be stripped from
the stylesheet input.

Note: I use Abel's namespace prefix since you are going to need that namespace.

Cheers, Wendell

On Fri, Sep 12, 2014 at 8:14 AM, Tony Graham tgraham@xxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> 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

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

Current Thread