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

RE: Namespaces.

Subject: RE: Namespaces.
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 30 Mar 2006 12:07:06 +0100
RE:  Namespaces.
> Now, I want to copy customRows into supplier. I created the following 
> code to do this:
> 
> <xsl:stylesheet version="1.0"
>     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>     xmlns:sup="http://www.calypso.net.au/apps/supub/SupplierV1.0">
>   <xsl:template match="files">
>      <xsl:apply-templates select="sup:supplier"/>
>   </xsl:template> 
> 
>   <xsl:template match="sup:supplier">
>     <supplier>
>       <xsl:apply-templates select="@*|node()"/>
>       <supplementary>
>       <xsl:apply-templates select="../customRows"/>
>       </supplementary>
>     </supplier>
>   </xsl:template>
> 
>   <xsl:template match="@*|node()">
>     <xsl:copy>
>       <xsl:apply-templates select="@*|node()"/>
>     </xsl:copy>
>   </xsl:template>
> </xsl:stylesheet>
> 
> Works fine, except it copies namespace information to children nodes 
> that doesn't seem to exists. eg:
> 
> <supplier 
> xmlns:sup="http://www.calypso.net.au/apps/supub/SupplierV1.0">

This namespace is being added because of the rule that literal result
elements copy all the in-scope namespaces from the stylesheet. You can
prevent this using exclude-result-prefixes="sup" on the xsl:stylesheet
element.

>     <priority 
> xmlns="http://www.calypso.net.au/apps/supub/SupplierV1.0" 
> xmlns:dir="http://apache.org/cocoon/directory/2.0" 
> xmlns:cinclude="http://apache.org/cocoon/include/1.0" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">1</priority>

> 
> I have checked, these elements are not in the source document, and it 
> only seems to affect the children of supplier. 

You haven't shown the source document but I strongly suspect that priority
is an element in the source document and that these are its in-scope
namespaces.

In XSLT 2.0 you can copy an element without copying its in-scope namespaces
using <xsl:copy copy-namespaces="no">. In 1.0, you can't: you have to
reconstruct the element using <xsl:element>.

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

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.