RE: [xsl] Namespace being carried over

Subject: RE: [xsl] Namespace being carried over
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 23 Aug 2004 16:14:48 +0100
When you use xsl:copy-of, you get an exact copy, namespaces and all.

To satisfy precisely this use case, XSLT 2.0 has introduced an option
copy-namespaces=yes|no that allows you to control this.

In 1.0, the only way to get rid of the namespaces is to do the copy using an
identity template, using xsl:element in place of xsl:copy:

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

Michael Kay 

> -----Original Message-----
> From: James Paul [mailto:jpaul@xxxxxxxxxxx] 
> Sent: 23 August 2004 16:07
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Namespace being carried over
> 
> Here is my xslt:
> 
> <?xml version = "1.0" encoding = "UTF-8"?>
> <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform";
> version = "1.0" xmlns:ns1 = "http://www.quadrem.com/soap/";
> exclude-result-prefixes = "ns1 ns2 Output" xmlns:ns2 =
> "http://schemas.xmlsoap.org/soap/envelope/"; xmlns:Output =
> "java://com.wm.pkg.xslt.extension.Output">
> 
> <xsl:output method = "xml" encoding = "utf-8" indent = "yes" />
> <xsl:template match = "*">
> 		<xsl:copy-of select =
> "ns2:Body/ns1:Body/ns1:Message-Body/*"/>
> </xsl:template>
> </xsl:stylesheet>
> 
> Here is the result:
> 
> <?xml version="1.0" encoding="utf-8"?>
> 
> <Order xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
> xmlns:Q-ENV="http://www.quadrem.com/soap/";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
> 
> 					<OrderHeader>
> 
> 						<OrderNumber>
> 
> 	
> <BuyerOrderNumber>DMMV_C84131</BuyerOrderNumber>
> 
> 						</OrderNumber>
> 
> 	
> <OrderIssueDate>20040818T11:10:28-03:00</OrderIssueDate>
> 
> 						<OrderReferences>
> 
> 
> The problem is this:
> <Order xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
> xmlns:Q-ENV="http://www.quadrem.com/soap/";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
> 
> Sould look like this:
> <Order>
> 
> I don't want all of the namespace information after the Order the tag.
> 
> Can anyone help me with this.
> 
> Thanks,
> James 

Current Thread