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

Re: [XSLT 1.0] Replace namespace prefixes?

Subject: Re: [XSLT 1.0] Replace namespace prefixes?
From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
Date: Thu, 24 Dec 2009 22:48:14 +0530
Re:  [XSLT 1.0] Replace namespace prefixes?
Hi Roger,
  I found the solutions presented below, to work.

On Thu, Dec 24, 2009 at 10:09 PM, Costello, Roger L. <costello@xxxxxxxxx>
wrote:
> Into this:
>
> B  B <bk:book xmlns:bk="http://www.book.org">
> B  B  B  B <bk:title>The Origin of Wealth</bk:title>
> B  B  B  B <bk:author>Eric D. Beinhocker</bk:author>
> B  B  B  B <bk:date>2006</bk:date>
> B  B  B  B <bk:ISBN>1-57851-777-X</bk:ISBN>
> B  B  B  B <bk:publisher>Harvard Business School Press</bk:publisher>
> B  B  B  B <bk:cost currency="USD">29.95</bk:cost>
> B  B </bk:book>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                       xmlns:bk="http://www.book.org"
                       version="1.0">

   <xsl:output method="xml" />

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

   <xsl:template match="/">
     <xsl:element name="bk:{local-name(*)}" xmlns:bk="http://www.book.org">
       <xsl:copy-of select="*/@*" />
       <xsl:apply-templates select="*/node()" />
     </xsl:element>
   </xsl:template>

   <xsl:template match="*">
     <xsl:element name="bk:{local-name()}">
       <xsl:copy-of select="@*" />
       <xsl:apply-templates />
     </xsl:element>
   </xsl:template>

</xsl:stylesheet>

> Or this:
>
> B  B <book xmlns="http://www.book.org">
> B  B  B  B <title>The Origin of Wealth</title>
> B  B  B  B <author>Eric D. Beinhocker</author>
> B  B  B  B <date>2006</date>
> B  B  B  B <ISBN>1-57851-777-X</ISBN>
> B  B  B  B <publisher>Harvard Business School Press</publisher>
> B  B  B  B <cost currency="USD">29.95</cost>
> B  B </book>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                       xmlns="http://www.book.org"
                       exclude-result-prefixes=""
                       version="1.0">

   <xsl:output method="xml" />

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

   <xsl:template match="/">
     <xsl:element name="{local-name(*)}" xmlns="http://www.book.org">
       <xsl:copy-of select="*/@*" />
       <xsl:apply-templates select="*/node()" />
     </xsl:element>
   </xsl:template>

   <xsl:template match="*">
     <xsl:element name="{local-name()}">
       <xsl:copy-of select="@*" />
       <xsl:apply-templates />
     </xsl:element>
   </xsl:template>

</xsl:stylesheet>


--
Regards,
Mukul Gandhi

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.