RE: [xsl] exclude result prefixes doesn't stop prefix from showing up.

Subject: RE: [xsl] exclude result prefixes doesn't stop prefix from showing up.
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 22 Aug 2003 08:49:49 +0100
exclude-result-prefixes only affects the namespaces copied from the
stylesheet by a literal result element, it doesn't affect copying of
namespaces from source documents. In any case, the codeBook element is
in the namespace http://www.icpsr.umich.edu/DDI, so the namespace must
be declared. exclude-result-prefixes only suppresses namespaces that are
not used in any element or attribute name, and this namespace is used.
What you want to do is not to suppress the namespace declaration, it is
to change the name of the element, which you can do by using
<xsl:element name="{local-name(.)}"> in place of xsl:copy.

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Mark R. Diggory
> Sent: 21 August 2003 23:10
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] exclude result prefixes doesn't stop prefix 
> from showing up.
> 
> 
> I have a stylesheet that copies an xml document with a 
> default namespace 
> while it also is adding some content to it:
> 
> *The stylesheet*
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet
> 	version="1.0"
> 	xmlns="http://www.icpsr.umich.edu/DDI";
> 	xmlns:ddi="http://www.icpsr.umich.edu/DDI";
> 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> 	exclude-result-prefixes="ddi"
> 	>
> 
> 	<xsl:template match="@* | *">
> 		<xsl:copy>
> 			<xsl:apply-templates select="* | @* | text()"/>
> 		</xsl:copy>
> 	</xsl:template>
> 	
> 	<xsl:template match="ddi:codeBook">
> 	   <xsl:copy>
> 	     <xsl:apply-templates select="@*"/>
> 		<docDscr>
> 		   <citation>
> 			<titlStmt>
> 			   <titl>
> 			     <xsl:value-of 
> select="ddi:stdyDscr/ddi:citation/ddi:titlStmt/ddi:titl"/>
> 			   </titl>
> 			</titlStmt>
> 		    </citation>
> 	         </docDscr>		
> 		 <xsl:apply-templates select="*"/>
> 		</xsl:copy>
> 	</xsl:template>
> </xsl:stylesheet>
> 
> *The xml document*
> 
> <?xml version="1.0" encoding="utf-8"?>
> <codeBook xmlns="http://www.icpsr.umich.edu/DDI"; >
> 	<stdyDscr> ....
> 
> 
> *the resulting xml document*
> 
> 
> <?xml version="1.0" encoding="utf-8"?>
> <codeBook xmlns="http://www.icpsr.umich.edu/DDI";>
> 	<docDscr xmlns:ddi="http://www.icpsr.umich.edu/DDI";>
> 		<citation>
> 			...
> 		</citation>
> 	</docDscr>
> 	<stdyDscr>
> 		<citation>
> 			<titlStmt>
> 				<titl>Foo bar</titl>
> 			</titlStmt>
> 		</citation>
> 	</stdyDscr>
> </codeBook>
> 
> My problem is that I'm getting an extra 
> xmlns:ddi="http://www.icpsr.umich.edu/DDI"; in the docDscr 
> element even 
> though I'm suppressing it in the excludes. Is there any way I 
> can stop 
> this from happening?
> 
> -Mark Diggory
> Harvard MIT Data Center
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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


Current Thread