[xsl] Re:Re: How to copy xml which attributes are processed with normalize-space function

Subject: [xsl] Re:Re: How to copy xml which attributes are processed with normalize-space function
From: "Yang" <sfyang@xxxxxxxxxxxxx>
Date: Fri, 20 Apr 2001 09:12:57 +0800
Hi,

Thanks for suggestions from Oliver and David for my problem how to copy
a normalized-space() attribute.

I apply it to my real problem, and realize that the original xml input
contains some additional namespace prefixes ( typical ms sql ado output),
which thus introduce a set of additional information in the each **line**
element ouput.

So my question should be how to get a xml with white-spaces squeezed out
attributes
from the given xml file, no matter any namespace prefix claimed in the PI
element or not.

The xml, xsl and output are listed below for your information.

Thanks

Sun-fu Yang
sfyang@xxxxxxxxxxxxx


--normalize-space.xml file--
<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<rs:data>
 <z:row ClientID="aaaa  " EntityID="xxxx   " FacilityID="A001      " />
 <z:row ClientID="bbbb  " EntityID="yyyy   " FacilityID="B001      " />
</rs:data>
</xml>

--  normalize-space.xsl file --

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
 xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">

<xsl:output method="xml" indent="yes" />

<xsl:template match="/">
<xsl:apply-templates select="//z:row"/>
</xsl:template>

<xsl:template match="z:row">
  <list>
    <xsl:apply-templates select="@*|node()"/>
  </list>
</xsl:template>

<xsl:template match="z:row/@*">  <!-- should I add some kind of predicates
pattern
                                 to filter out the explicit namespaces
infomation

  <xsl:attribute name="{name()}">
    <xsl:value-of select="normalize-space(.)"/>
  </xsl:attribute>
</xsl:template>
</xsl:stylesheet>


-- output --

<list ClientID="aaa" EntityID="xxxx" FacilityID="A001"
xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"     <===these part of
output I would like to get rid of.
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"     which are from the
namespace prefixes.
xmlns:rs="urn:schemas-microsoft-com:rowset"
xmlns:z="#RowsetSchema" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
</list>
<list>...
</list>

what I like to see a more clean output such as:

<list ClientID="aaa" EntityID="xxxx" FacilityID="A001">
</list>
<list ClientID="bbbb" EntityID="yyyy" FacilityID="B001"
</list>




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread