Subject: Re: [xsl] Why is an empty xmlns="" added to child when I add namespace to parent? From: Andrew Welch <andrew.j.welch@xxxxxxxxx> Date: Mon, 6 Jun 2011 18:36:30 +0100 |
On 6 June 2011 18:30, Alex Muir <amuir@xxxxxxxxxx> wrote: > Hi, > > The following code adds a namespace to the mediawiki element and a > copyAll I import copies the other elements > > <xsl:import href="copyAll.xsl"/> > <xsl:template match="mediawiki"> > <mediawiki xmlns="http://www.mediawiki.org/xml/export-0.4/" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.4/ > http://www.mediawiki.org/xml/export-0.4.xsd" version="0.4" > xml:lang="en"> > <xsl:apply-templates/> > </mediawiki> > </xsl:template> > > However in the result the child element <page> gets a blank xmlns="" > attribute added..... Why? > > <mediawiki xmlns="http://www.mediawiki.org/xml/export-0.4/" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.4/ > http://www.mediawiki.org/xml/export-0.4.xsd" > version="0.4" xml:lang="en"> > <page xmlns=""> If <page> comes from your stylesheet, then its not in-scope for the default namespace change. If <page> comes from your input, then its it no namespace so rather than copy it you will have to create a new element in the result with the local name "page" in the right namespace, then copy page's attributes and process its children. -- Andrew Welch http://andrewjwelch.com
<- Previous | Index | Next -> |
---|---|---|
[xsl] Why is an empty xmlns="" adde, Alex Muir | Thread | Re: [xsl] Why is an empty xmlns="" , Alex Muir |
[xsl] Why is an empty xmlns="" adde, Alex Muir | Date | Re: [xsl] Why is an empty xmlns="" , Alex Muir |
Month |