Altova Mailing List Archives

[xsl] Xsl:strip-space and xsl:preserve-space (XSLT 2.0)

From: "Pankaj Chaturvedi" <pankaj.chaturvedi@--------->
Date: 9/23/2008 10:50:00 PM
In my stylesheet, I am stripping all the spaces, new line character while
using <xsl:strip-space elements="*"/> which works perfectly as desired. 

But now I've come across the requirement where I need to preserve spaces
between the tags in few specific elements generally the punctuations(see
below example) I tried to use the <xsl:preserve-space> to sort out this
issue but doesn't seems to be working and "xsl:strip-space" seems to
overcoming the effect of "xsl:preserve-space" effects. Can we use both to
get their respective effects or simply they cannot be used together?

Below is how they looks in my stylesheet:


<xsl:stylesheet version="2.0"

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

<xsl:preserve-space elements="element1 element2"/>

<xsl:output encoding="UTF-8" indent="no" media-type="text/xml"




<element1><surname>Dajnoki</surname>, <givenname>K.</givenname>
(<year>2002</year>) <article-title>XXXXX YYYY</article-title>.
<journal-title>ZZZZZZ XXXX</journal-title>

Note: Spaces between the tags with any punctuation appears correctly (like
in <surname>Dajnoki</surname>, <givenname>K.</givenname>)  but fails in case
of a single space between tags > < (for instance in </journal-title>
<first-page> and results into the </journal-title><first-page> )

Below is how I have defined template for "element1"

<xsl:template match="element1">

Any suggestion would be an immense help.


Pankaj Chaturvedi


Confidentiality Notice:" This message and any attachment(s)
contained here are information that is confidential, proprietary to
IDS Infotech Ltd. and its customers.
Contents may be privileged or otherwise protected by law. The
information is solely intended for the individual or the entity it
is addressed to. If you are not the intended recipient of this
message, you are not authorized to read, forward, print, retain,
copy or disseminate this message or any part of it. If you have
received this e-mail in error, please notify the sender immediately
by return e-mail and delete it from your computer."


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.