[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

merging of text-nodes and CDATA

Subject: merging of text-nodes and CDATA
From: Klaus-Georg Adams <Klaus-Georg.Adams@xxxxxxx>
Date: 05 Sep 2001 16:10:54 +0200
georg adams
Hi,
given the following XML fragment:

<strval>
  <![CDATA[bla ]]>
</strval>

and the famous identity transformation from the XSL spec:

<?xml version="1.0"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"
            indent="yes"
	    cdata-section-elements="strval"
/>

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

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

I get the following back:

<strval><![CDATA[
  bla 
]]></strval>

This is with Xalan-J and sablotron. My understanding is that the
parser generates three text nodes:
- one containing the first '\n' after <strval> and a couple of spaces,
- one containing 'bla '
- one with the closing '\n'

These three are merged in one and than whitespace stripping is
performed.

I'd like this order to be reversed: first strip whitespace and than
only merge the textnodes. The result would thus be:

<strval><![CDATA[bla ]]></strval>

, as the first and last node only contain whitespace. This, btw, is
how the XML parser in the application interprets the source fragment.

Note the space after bla, which I don't want to loose. No
normalize_text(), which will eat that space as well.

Now my questions:
- Is the order of merge/strip specified somewhere in the XML or XSL
  specifications?
- if not, does somebody have an XSL processor which does it my way?
- can I get the behaviour I want with XSL?

Thanks for your help,
Klaus-Georg Adams





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.