[xslt] Suppressing namespace attributes



Hi,


I am trying to generate a DocBook document from an XML document. The XML
document contains a few tags of my own, which I have stuck in a namespace
of my own, but I also embed a few DocBook tags since that is what I'm
generating.

The problem I am facing is that xsltproc insists on first seeing a
namespace declaration, "xmlns:ur='whatever'", for my own tags, but then
applies that namespace declaration to the DocBook tags when writing the
result document. However, I don't want _any_ namespace declarations to
appear in my output document - it is 100% DocBook, no namespaces anywhere.

I'm at a loss why the namespace declaration appears: none of my
substitution elements are in a namespace. The only namespaces are used on
the match patterns.

I have tried adding a "xmlns=''" to the <xsl:stylesheet> element as well.
This results in both "xmlns:ur" and "xmlns" attributes to be added to
every DocBook element, rather than removing the "xmlns:ur" attribute as I
hoped.

Simplified example:

source document, has embedded DocBook element inside my own element:

<?xml version="1.0" encoding="ISO-8859-1"?>
<sourcedoc xmlns:ur="http://whatever.com";>
<ur:phase><para>foo bar</para></ur:phase>
</sourcedoc>

XSL that will be applied:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:ur="http://whatever.com";
>
<xsl:template match="ur:phase">
    <section><xsl:copy-of select="para"/></section>
</xsl:template>
</xsl:stylesheet>

Output I get:

<?xml version="1.0"?>
<section xmlns:ur="http://whatever.com";><para>foo bar</para></section>

Output I would have liked to see:

<?xml version="1.0"?>
<section><para>foo bar</para></section>

Reason I prefer that: because the generated DocBook does not validate with
the xmlns:ur attribute present.


Thanks for any light you can shed on this,

Hans Guijt




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]