[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSLT to remove characters and whitespaces

Subject: Re: XSLT to remove characters and whitespaces
From: "Georg Hohmann" <georg.hohmann@xxxxxxxxx>
Date: Fri, 7 Jul 2006 14:22:07 +0200
xsl remove linefeed
Sorry for beeing not precise enough:

"&#x0d;&#x0a;" replaces linefeed+carriage-returns
"&#09;" replaces tabulators
"normalize-space" removes all unnecessary whitespaces

This replacements do their job in another stylesheet. So it is more a
problem of copying elements the right way than replacing chars. I know
the copy-elements-stylesheet from the the xslt-cookbook but i don't
know how to customize it for my needs (and i don't have the need to
copy any attributs).

I though the provided stylesheet would do the following: Select each
node (*), create element with same name (name={name()}) transform the
content, select next node ...
But the output looks like <tag1>content1</tag1>content1 ...

So maybe the usage of * is wrong. So i tried node() instead but than i
get an error for the usage of name() for the element name that says
i'm generating in invalid qname.

I guess i'm still mixed up with the xslt syntax. So any help is appreciated.


2006/7/7, Georg Hohmann <georg.hohmann@xxxxxxxxx>:

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:template match="*">
   <xsl:element name="{name()}">
      <xsl:value-of select="normalize-space(translate(translate(.,
'&#x0d;&#x0a;', ' '), '&#09;', ' '))"/>

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


Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.