[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
I got a message off-list that suggested to me that I wasn't very clear about this. To be clear, the template-rule approach below requires that you have xml:space="preserve" in the source document to prevent MSXML from stripping any whitespace. Of course, as a stylesheet writer, that may not always be within your control. But one way or another, you need to preserve whitespace, and I can only think of three ways to do that:
A variation of #1 is to simply put xml:space="preserve" on all the <element1> and <element2> elements, but that might not be as practical.
Evan
Evan Lenz wrote:
Re: [xsl] Xsl:strip-space and xsl:preserve-space (XSLT 2.0)
Subject: Re: [xsl] Xsl:strip-space and xsl:preserve-space (XSLT 2.0) From: Evan Lenz <evan@xxxxxxxxxxxx> Date: Wed, 24 Sep 2008 10:52:58 -0700 |
I got a message off-list that suggested to me that I wasn't very clear about this. To be clear, the template-rule approach below requires that you have xml:space="preserve" in the source document to prevent MSXML from stripping any whitespace. Of course, as a stylesheet writer, that may not always be within your control. But one way or another, you need to preserve whitespace, and I can only think of three ways to do that:
1. Use xml:space="preserve" in the source document, 2. Set the preserveWhiteSpace property to true in the MSXML API, or 3. Use a different XSLT processor.
A variation of #1 is to simply put xml:space="preserve" on all the <element1> and <element2> elements, but that might not be as practical.
Evan
Evan Lenz wrote:
On second thought, your original stylesheet will have to change, because <xsl:strip-space/> won't strip whitespace-only text nodes that have been force-preserved using xml:space="preserve" (which will be true for all whitespace in your document if you put that at the root element).
Instead of using <xsl:strip-space/> (and <xsl:preserve-space/>), you could use a template rule that processes whitespace-only text nodes that are not children of <element1> or <element2>:
<xsl:template match="*[not(self::element1 or self::element2)]/text()[not(normalize-space())]"/>
The rule is empty and thus has the effect of "stripping" them from the result.
Let me know if that works. :-)
Evan
Evan Lenz wrote:Pankaj,
You can force MSXML to preserve whitespace by adding xml:space="preserve" to the root element of your document. Then your original stylesheet should work as desired. Let me know if that works.
Evan
Pankaj Chaturvedi wrote:Not a good news for me.
Well anyways David/Michael thanks for looking into this.
Best,
Pankaj Chaturvedi
============================================================================
================
-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx] Sent: Wednesday, September 24, 2008 6:36 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Xsl:strip-space and xsl:preserve-space (XSLT 2.0)
I believe it's true that the AltovaXML processor always strips whitespace
nodes (or calls the MSXML parser in a way that strips them) and I'm not
aware of any way of changing this.
Michael Kay http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Xsl:strip-space and xsl:p, Evan Lenz | Thread | RE: [xsl] Xsl:strip-space and xsl:p, Pankaj Chaturvedi |
Re: [xsl] Xsl:strip-space and xsl:p, Evan Lenz | Date | RE: Fwd: Re: [xsl] Xsl:strip-space , Michael Kay |
Month |
Keywords