xsl-list
[Top] [All Lists]

Re: [xsl] XSLT to remove characters and whitespaces

2006-07-07 09:02:21
At 11:08 AM 7/7/2006, I wrote:
So if your input were

<greeting>
  <to>Georg</to>
  <from>XSL-List</from>
  <text>Hey, how are tricks?</text>
</greeting>

you'll get

<greeting>GeorgXSL-ListHey, how are tricks?
  <to>Georg</to>
  <from>XSL-List</from>
  <text>Hey, how are tricks?</text>
</greeting>

Actually you'll get

<greeting>GeorgXSL-ListHey, how are tricks?
  <to>GeorgGeorg</to>
  <from>XSL-ListXSL-List</from>
  <text>Hey, how are tricks?Hey, how are tricks?</text>
</greeting>

My wetware XSLT engine sometimes requires several runs to get it right.

Cheers,
Wendell

i have a xml file with some content in it which contains some unwanted
carriage returns and whitespaces. Now I'm trying to write a stylesheet
which makes an exact copy of the source file but without the returns
and whitespaces. I thought this should work:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output name="stripped" method="xml" version="1.0"
encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
  <xsl:result-document format="stripped" href="result.xml">
     <xsl:apply-templates/>
  </xsl:result-document>
</xsl:template>
<xsl:template match="*">
  <xsl:element name="{name()}">
     <xsl:value-of select="normalize-space(translate(translate(.,
'&#x0d;&#x0a;', ' '), '&#09;', ' '))"/>
  <xsl:apply-templates/>
  </xsl:element>
</xsl:template>
</xsl:stylesheet>

But the output is a mess in parts. What am I doing wrong?


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>