Subject: RE: [xsl] Namespaces. From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Thu, 30 Mar 2006 12:07:06 +0100 |
> 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Namespaces., Kamal Bhatt | Thread | Re: [xsl] Namespaces., Kamal Bhatt |
AW: [xsl] XSL 1.1 -> Asking for an , news | Date | RE: [xsl] XSL 1.1 -> Asking for an , Michael Kay |
Month |