[oXygen-user] Whitespace-only text nodes in XSLT

Wendell Piez
Thu Jun 25 15:44:45 CDT 2015


Hey Syd,

On Thu, Jun 25, 2015 at 3:38 PM, Syd Bauman <> wrote:
> If it makes you feel any better, Wendell, I get the same output when
> I run this on itself in saxon[1] from the commandline. I get the
> expected whitespace node if I add
>     <xsl:output method="xml" indent="yes"/>

Yes, I suspect that Saxon or its parser is stripping the node for some
reason. Thanks for helping to confirm it's not an oXygen thing.

The indent='yes' whitespace isn't actually the same ... it is inserted
by the serializer. and for one reason and another, isn't really
workable for me. (In the actual problem I am generating HTML output,
and in mixed content in the result, no extra whitespace is inserted
even with indent='yes'.)

I checked the Saxon -strip:none flag, which seems like it's supposed
to prevent this (though I have no DTD); I wonder what's up with it.

Cheers, Wendell

>> Given this stylesheet:
>>
>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>   xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>   exclude-result-prefixes="xs"
>>   version="2.0">
>>
>>   <xsl:variable name="mixed" as="element()">
>>     <mixed>Here is mixed content, including
>>
>>       <one>children</one>
>>       <two>with nothing</two>
>>
>>       but whitespace between them.</mixed>
>>   </xsl:variable>
>>
>>   <xsl:template match="/">
>>     <xsl:apply-templates select="$mixed"/>
>>   </xsl:template>
>>
>>   <xsl:template match="node() | @*">
>>     <xsl:copy>
>>       <xsl:apply-templates select="node() | @*"/>
>>     </xsl:copy>
>>   </xsl:template>
>>
>> </xsl:stylesheet>
>>
>> I run it on itself in oXygen, and get
>>
>> <?xml version="1.0" encoding="UTF-8"?><mixed>Here is mixed content, including
>>
>>       <one>children</one><two>with nothing</two>
>>
>>       but whitespace between them.</mixed>
>>
>> I would expect whitespace between the </one><two>.
>>
>> What am I missing? Have things changed wrt whitespace-handling rules?
>>
>> (As I see it, the temporary tree $mixed should contain a
>> whitespace-only text node between the 'one' and 'two' elements.)
>>
>> Thanks for any insights,
> _______________________________________________
> oXygen-user mailing list
> 
> http://www.oxygenxml.com/mailman/listinfo/oxygen-user



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


More information about the oXygen-user mailing list