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

Problem with namespaces when transforming one namespac

Subject: Problem with namespaces when transforming one namespace to another.
From: "Sal Mangano" <smangano@xxxxxxxxxx>
Date: Mon, 27 May 2002 12:15:18 -0400
 Problem with namespaces when transforming one namespac
There is something I am not understanding about the behavior of
namespaces.

Imagine I have the following XML:

<foo:someElement xmlns:foo="http://www.somewhere.com/namespace/foo"
xmlns:doc="http://www.somewhere.com /namespace/doc">
  <foo:aChild>
    <foo:aGrandChild/>
    <foo:aGrandChild>
      <doc:doc>This documentation should not be removed or altered in
any way.</doc:doc>
    </foo:aGrandChild>
  </foo:aChild>
</foo:someElement>

And I want to change all elements in the foo namespace to a bar
namespace but leave all other elements untouched. . I use the following
stylesheet.


<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:foo="http://www.somewhere.com/namespace/foo"
 xmlns:bar="http://www. somewhere.com/namespace/bar">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<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="foo:*">
  <xsl:element name="bar:{local-name()}">
    <xsl:apply-templates/>
  </xsl:element>
</xsl:template>	

</xsl:stylesheet>


The output is:

<?xml version="1.0" encoding="UTF-8"?>
<bar:someElement xmlns:bar="http://www.somewhere.com/namespace/bar">
   <bar:aChild>
      <bar:aGrandChild/>
      <bar:aGrandChild>
         <doc:doc xmlns:doc="http:/www.somewhere.com/namespace/doc"
xmlns:foo="http:/www.somewhere.c
om/namespace/foo">This documentation should not be removed or altered in
any way.</doc:d
oc>
      </bar:aGrandChild>
   </bar:aChild>
</bar:someElement>

Which is fine except that the doc element retains the foo namespace
which seems to server no purpose anymore and I would prefer to be
stripped.

Suggestions?
 



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


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.