Subject: [xsl] Xsl:strip-space and xsl:preserve-space (XSLT 2.0) From: "Pankaj Chaturvedi" <pankaj.chaturvedi@xxxxxxxxx> Date: Wed, 24 Sep 2008 04:21:57 +0530 |
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>–<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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] trying to exclude result , Michael Kay | Thread | RE: [xsl] Xsl:strip-space and xsl:p, Michael Kay |
RE: [xsl] Custom function in templa, Michael Kay | Date | Re: [xsl] Custom function in templa, Ian Stokes-Rees |
Month |