[xsl] Re:

Subject: [xsl] Re:
From: "Roger Chi" <roger.xslt@xxxxxxxxxxxx>
Date: Wed, 19 Oct 2005 16:48:39 -0400
Hmm, you are right.  I had assumed it would give true, false, false based
on the results with another stylesheet/xml file that I have.

After running a few more tests, I realize it is XMLSpy that is stripping
the non-significant whitespace before it sends it off to either its own
internal parser or to the built-in MSXML parser that it can use.  When
you tell it to call an external processor, it doesn't strip the
whitespace.  At least that is what I am concluding since running msxsl
from the command line also gives me true, true, true.

However, it doesn't explain a different issue I'm having with the other
stylesheet.  This is my stylesheet (slightly modified):

	<xsl:template match="@*">
		<xsl:copy>
			<xsl:apply-templates select="node()|@*"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="*[not(child::text())]">
		<xsl:copy>
			<xsl:apply-templates select="node()|@*"/>
			(some stuff)
		</xsl:copy>
	</xsl:template>

	<xsl:template match="node()">
		<xsl:element name="{name()}">
			(some other stuff)
		</xsl:element>
	</xsl:template>

What it does is copies over the structure of the source XML file but does
(some stuff) within elements that have child elements (branches), and
does (some other stuff) within elements that do not have child elements
(leaves).

This stylesheet works with command line msxsl, Saxon 6, but fails with
nxslt (it never gets to the <xsl:template
match="*[not(child::text())]"> part of the stylesheet).  Which is why
I did that test with text().  It only works with nxslt if I use the -xw
strip whitespace parameter.

Any idea why nxslt performs this way?

On 10/19/2005, "Michael Kay" <mike@xxxxxxxxxxxx> wrote:

>For me, both Saxon 8.5.1 and Saxon 6.5.4 give true, true, true.
>
>How are you running the processor?
>
>Michael Kay
>http://www.saxonica.com/
>
>
>
>> -----Original Message-----
>> From: Roger Chi [mailto:roger.xslt@xxxxxxxxxxxx]
>> Sent: 19 October 2005 19:39
>> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>> Subject: [xsl] text(), whitespace, and nxslt
>>
>> XSLT 1.0
>>
>> Given this stylesheet:
>> <xsl:stylesheet version="1.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>>   <xsl:output method="xml" version="1.0" encoding="UTF-8"
>> indent="yes"/>
>>
>>   <xsl:template match="node()">
>>     <output>
>>       <test1>
>>         <xsl:value-of select="boolean(.)"/>
>>       </test1>
>>       <test2>
>>         <xsl:value-of select="boolean(text())"/>
>>       </test2>
>>       <test3>
>>         <xsl:value-of select="boolean(child::text())"/>
>>       </test3>
>>     </output>
>>   </xsl:template>
>>
>> </xsl:stylesheet>
>>
>> And this source file:
>>
>> <ROOT>
>>     <!-- some whitespace -->
>> </ROOT>
>>
>> I get values of true, true, true in nxslt
>> However, in the built in XMLSpy parser, msxsl, and saxon I get true,
>> false, false. If I use the parameter -xw (Strip non-significant
>> whitespace from source and stylesheet), the result from nxslt becomes
>> the same as the other parsers (true, false, false).
>>
>> My question: Does nxslt consider whitespace as something that should
>> give a true when using boolean(text()), and is this
>> conforming to spec;
>> or do the other processors strip out whitespace before processing?

Current Thread
  • [xsl] Re:
    • Roger Chi - Wed, 19 Oct 2005 16:48:39 -0400 <=