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

Re: normalize-space and sequence

Subject: Re: normalize-space and sequence
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 27 Sep 2007 11:09:52 +0200
Re:  normalize-space and sequence
Mathieu Malaterre wrote:
On 9/27/07, Abel Braaksma <abel.online@xxxxxxxxx> wrote:
Maybe I totally misunderstood your question, but if I did, please
respond with a tiny example of what you are after: a small but working
xslt document, a small input and a small output xml document, plus an
extra output xml containing what you want different. You know, with xml
it is like with pictures: one xml says more than a thousand words, but
thousand xmls (or very large ones) say nothing. ;)

Hi Abel,


  Thanks again for your help. I think I have rewritten what happen in
a shorter example:

http://gdcm.svn.sourceforge.net/viewvc/gdcm/Sandbox/xslt/ws.xml
and
http://gdcm.svn.sourceforge.net/viewvc/gdcm/Sandbox/xslt/ws.xsl

Could you please let me know how to fix the following:

Thanks for the shorter samples, that sure helps a lot. But I still prefer them in the mail, though (link vanish with time).
I don't see how you applied my changes.. This is your stylesheet:


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
 <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
 <xsl:template match="@*">
   <xsl:attribute name="{name()}" select="normalize-space(.)"/>
 </xsl:template>
 <xsl:template match="text()">
   <xsl:value-of select="normalize-space(.)"/>
 </xsl:template>
 <xsl:template match="/">
   <xsl:apply-templates select="*"/>
 </xsl:template>
 <xsl:template match="table">
   <table>
     <xsl:apply-templates/>
   </table>
 </xsl:template>
 <xsl:template match="entry/para">
   <entry ie="{.}"/>
 </xsl:template>
</xsl:stylesheet>


I suggested to use a variable, like so:


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
 <xsl:output method="xml" indent="yes" encoding="UTF-8"/>

 <!-- whitespace correction templates -->
 <xsl:template match="@*" mode="correct-ws">
   <xsl:attribute name="{name()}" select="normalize-space(.)"/>
 </xsl:template>

 <xsl:template match="text()" mode="correct-ws">
   <xsl:value-of select="normalize-space(.)"/>
 </xsl:template>

 <xsl:template match="/" mode="correct-ws">
   <xsl:variable name="output">
      <xsl:apply-templates select="*"/>
   </xsl:variable>
   <xsl:apply-templates select="$output/*" mode="correct-ws" />
 </xsl:template>

 <!-- normal templates -->
 <xsl:template match="table">
   <table>
     <xsl:apply-templates/>
   </table>
 </xsl:template>

 <xsl:template match="entry/para">
   <entry ie="{.}"/>
 </xsl:template>

</xsl:stylesheet>


That should do it. I didn't test it though ;)


Cheers,
-- Abel Braaksma

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.