[xml] xsltproc and redundant namespace prefix declarations



Hi everyone.

I'm using xsltproc, and one thing I find is that it sticks in xmlns
attributes into my output documents when they are not needed.

For example, with this input document (in.xml):

  <in xmlns="urn:blah:1">
    <test/>
  </in>

and this transformation (test.xsl):

  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:blah="urn:blah:1" xmlns="urn:blah:1">
    <xsl:template match="blah:test">
      <replacement/>
    </xsl:template>
    <xsl:template match="node()|@*">
      <xsl:copy>
        <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
    </xsl:template>
  </xsl:stylesheet>

then I get an output document like this:

  <?xml version="1.0"?>
  <in xmlns="urn:blah:1">
    <replacement xmlns:blah="urn:blah:1"/>
  </in>

The xmlns:blah="urn:blah:1" is not really needed.  The namespace prefix
was introduced in the .xsl file just so I could refer to the <test/>
element.  Is there any way to get xsltproc to leave the prefix
declaration out?

As an aside, why doesn't the element referenced in the match attribute
of <xsl:template/> use the default namespace?

Thanks,

Cameron

-- 
Cameron McCormack
  // clm csse monash edu au
  // http://www.csse.monash.edu.au/~clm/
  // icq 26955922



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