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

RE: Problem in replacing XML namespace using XSLT

Subject: RE: Problem in replacing XML namespace using XSLT
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 17 Dec 2009 10:09:03 -0000
RE:  Problem in replacing XML namespace using XSLT
Please do not cross-post the same question on more than one forum. The
question has been answered elsewhere.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay  

> -----Original Message-----
> From: Krishna Gopal Binyala [mailto:kgbinyala@xxxxxxxxx] 
> Sent: 17 December 2009 09:56
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Problem in replacing XML namespace using XSLT
> 
> Hello,
> 
> I need to just replace the XML namespace using XSLT. My input 
> XML looks like as follows. I just want to replace 
> "oldNameSpace" with "newNameSpace" and rest of XML want as it is..
> 
> [CODE]<?xml version="1.0" encoding="UTF-8"?> 
> <soapenv:Envelope 
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> 	xmlns:impl="oldNameSpace" 
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> 	<soapenv:Body>
> 		<impl:requestData
> 			xmlns:impl="oldNameSpace">
> 			<xmlString 
> ChangeDate="2008-12-18T14:47:11.773+01:00"
> 				IdentificationNumber="WDDKJ5GBXAF000229"
> 				OrderNumber="08 295 70821"
> 				ProductionNumber="1700158">
> 				<ServiceTool 
> ExecutionTime="2008-12-18T14:47:11.773+01:00"
> 					UserID="kris" Version="1.1.1" />
> 			</xmlString>
> 		</impl:requestData>
> 	</soapenv:Body>
> </soapenv:Envelope>[/CODE]
> 
> I tried with following XSL
> 
> [CODE]<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> 	xmlns:source="oldNameSpace" xmlns:desti="newNameSPace" 
> xmlns="newNameSPace"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> version="2.0">
> 	<xsl:output method="xml" encoding="iso-8859-1" indent="yes" />
> 
> 
> 	<xsl:template match="source:*">
> 		<xsl:element name="{name()}" namespace="newNameSPace">
> 			<xsl:apply-templates select="@*|node()" />
> 		</xsl:element>
> 	</xsl:template>
> 
> 	<xsl:template match="@*|node()">
> 		<xsl:copy>
> 			<xsl:apply-templates select="@*|node()" />
> 		</xsl:copy>
> 	</xsl:template>
> </xsl:stylesheet>[/CODE]
> 
> but it is not giving the desired results...it is giving the 
> following results.
> 
> [CODE]
> <?xml version="1.0" encoding="iso-8859-1"?> <soapenv:Envelope 
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:impl="oldNameSpace"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> 	<soapenv:Body>
> 		<impl:requestData xmlns:impl="newNameSPace">
> 			<xmlString xmlns:impl="oldNameSpace"
> ChangeDate="2008-12-18T14:47:11.773+01:00"
> IdentificationNumber="WDDKJ5GBXAF000229" OrderNumber="08 295 70821"
> ProductionNumber="1700158">
> 				<ServiceTool 
> ExecutionTime="2008-12-18T14:47:11.773+01:00"
> UserID="kris" Version="1.1.1"/>
> 			</xmlString>
> 		</impl:requestData>
> 	</soapenv:Body>
> </soapenv:Envelope>
> 
> [/CODE]
> 
> problem with the above is that -- "<xmlString 
> xmlns:impl="oldNameSpace"  is still showing the "oldNameSpace" only..
> where as there was no namespace for that element in the input
> 
> Anyone can help in this ....
> Thanks a lot.
> 
> ---Krishna

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.