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: "Pankaj Chaturvedi" <pankaj.chaturvedi@xxxxxxxxx>
Date: Wed, 24 Sep 2008 14:21:38 +0530
What XML parser and XSLT processor are you using?


Just for curiosity Michael, is this related with XSLT processor or there is
error in my code.

Thanks for help.

Pankaj




> -----Original Message-----
> From: Pankaj Chaturvedi [mailto:pankaj.chaturvedi@xxxxxxxxx]
> Sent: 23 September 2008 23:52
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Xsl:strip-space and xsl:preserve-space (XSLT 2.0)
> 
> 
> 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:
> 
> Snippet
> =======
> 
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:fo="http://www.w3.org/1999/XSL/Format";
> xmlns:xs="http://www.w3.org/2001/XMLSchema";
> xmlns:fn="http://www.w3.org/2005/xpath-functions";>
> 
> <xsl:strip-space elements="*"/>
> 
> <xsl:preserve-space elements="element1 element2"/>
> 
> <xsl:output encoding="UTF-8" indent="no" media-type="text/xml"
> method="xml"/>
> 
> --------------
> --------------
> --------------
> --------------
> --------------
> 
> </xsl:stylesheet>
> 
> 
> Example:
> 
> <element1><surname>Dajnoki</surname>, <givenname>K.</givenname>
> (<year>2002</year>) <article-title>XXXXX YYYY</article-title>.
> <journal-title>ZZZZZZ XXXX</journal-title> 
> <first-page>43</first-page>&ndash;<last-page>46</last-page>.</
> element1>
> 
> 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">
>     <xsl:apply-templates/>
> </xsl:template>
> 
> Any suggestion would be an immense help.
> 
> 
> Best,
> 
> 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."

Current Thread