[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] how to reserve single space after transformation


Subject: RE: [xsl] how to reserve single space after transformation
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 5 Mar 2007 21:35:50 -0000

Your stylesheet says

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

So the space has gone because you asked for it to be stripped.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Lin, Jessica [mailto:jlin@xxxxxxxxxxx] 
> Sent: 05 March 2007 21:28
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] how to reserve single space after transformation
> 
> Here is example for XML file.
> <?xml version="1.0" encoding="UTF-8"?>
> <blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <apg>
>   <channel_object>
>     <element1>test1</element1>
>     <element2>test2</elemetn1>
>   </channel_object>
>   <category_system_object>
>     <category_label>
> 	<string> </string>
>     </category_label>
>   </category_system_object>	
> </apg>
> 
> 
> Here is my XSLT file.
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> 
> 
> <xsl:output method="xml" version="1.0" encoding="UTF-8" 
> indent="no"/> <xsl:strip-space elements="*"/>
> 
> <xsl:template match="/ | node() | @* | comment() | 
> processing-instruction()">
>   <xsl:copy>
>     <xsl:apply-templates select="@* | node()"/>
>   </xsl:copy>
> </xsl:template>
> 
> 
> <xsl:template match="channel_object">
>   <advanced_channel_object>
>     <xsl:apply-template />
>   </advanced_channel_object>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> 
> I strip out all white space in this transform since I will 
> call customized pretty-print XSLT later on the better print 
> (that is out of the scope of this problem).
> 
> 
> Thanks,
> Jessica
> -----Original Message-----
> From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
> Sent: Monday, March 05, 2007 12:57 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] how to reserve single space after transformation
> 
> > 
> > I am doing XML to XML transform by using saxon 8. But the result 
> > changed from single space to empty space, could you please 
> help me for 
> > this problem?
> > 
> > <category_label>
> > 	<string> </string>
> > </category_label>
> > 
> > 
> > to: 
> > 
> > <category_label>
> > 	<string/>
> > </category_label>
> > 
> 
> I can think of many different stylesheets that would 
> transform a single space to a zero-length string, but the 
> chances are that none of them is the stylesheet you wrote. 
> Show us some code!
> 
> Michael Kay
> http://www.saxonica.com/


Current Thread
Keywords