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

RE: Unwanted namespace after using COPY-OF

Subject: RE: Unwanted namespace after using COPY-OF
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 8 Jan 2005 23:00:24 -0000
xsl copy of namespace
xsl:copy-of copies a complete subtree, unchanged, including all its
namespaces.

exclude-result-prefixes only affects the behavior of literal result elements
in the stylesheets, it has no effect on xsl:copy-of.

XSLT 2.0 allows you to suppress namespaces by means of a new attribute on
xsl:copy-of (copy-namespaces="yes|no")

In XSLT 1.0, if you want to copy everything except namespaces you need:

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

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

> -----Original Message-----
> From: gerritjan [mailto:gerritjankoekkoek@xxxxxxx] 
> Sent: 08 January 2005 21:12
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Unwanted namespace after using COPY-OF
> 
> Newbe question?
> This is my XSLT:
> 
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
>      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         exclude-result-prefixes="xsi"
>      >
>    <xsl:output method = "xml" indent = "yes" />
> 
>    <xsl:template match="/" >
>      <onderwerpen>
>         <xsl:apply-templates select="onderwerp">
>      </onderwerpen>
>    </xsl:template>
> 
>    <xsl:template match="onderwerp" >
>      <xsl:variable name="v_titel"><xsl:value-of 
> select="@titel"/></xsl:variable>
>      <xsl:variable name="v_datum"><xsl:value-of 
> select="@datum"/></xsl:variable>
>      <xsl:variable name="v_datum_einde"><xsl:value-of 
> select="@datum_einde"/></xsl:variable>
>      <xsl:variable name="v_menu"><xsl:value-of 
> select="@menu"/></xsl:variable>
>      <xsl:variable name="v_submenu"><xsl:value-of 
> select="@sub_menu"/></xsl:variable>
>      <xsl:variable name="v_beveiliging"><xsl:value-of 
> select="@beveiliging"/></xsl:variable>
> 	<onderwerp titel="{$v_titel}" datum="{$v_datum}" 
> datum_einde="{$v_datum_einde}" menu="{$v_menu}" 
> submenu="{$v_submenu}" 
> beveiliging="{$v_beveiliging}" >
>        			<xsl:copy-of select="subtitel"/>
>        			<xsl:copy-of select="kenwoorden"/>
>        			<xsl:copy-of 
> select="over_cdls_persoon"/>
>        			<xsl:copy-of select="inleidingtekst"/>
>        			<xsl:copy-of select="onderwerptekst"/>
>        			<xsl:copy-of select="auteur"/>
>        			<xsl:copy-of select="bron"/>
> 	</onderwerp>
>    </xsl:template>
> 
> </xsl:stylesheet>
> 
> The result contains:
> <kenwoorden xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <inleidingtekst xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> 
> It looks like using <XSL:COPY-OF...> is adding this 
> namespacestatement, 
> I did not intend this "xmlns:xsi..." to be added!
> I try to suppress it by the 2 lines added to the:
> <xsl:stylesheet version="1.0"
>      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         exclude-result-prefixes="xsi">
> 
> This does not help?
> Any suggestions?
> 
> Gerritjan Koekkoek

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.