This appears to be covered by XALANJ-2032, so the following is supplemental info. The idea is to remove the namespace declarations from the output root element using exclude-result-prefixes as specified in the XSLT 1.0 spec Section 7.1.1. This problem was produced by XALAN-J 2.7.0.

---Stylesheet---

<?xml version="1.0"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:conf="http://www.testxsl.org/2005/conformance";
    xmlns="http://www.testxsl.org/1999/ournamespace";
    exclude-result-prefixes="#default conf"
    version="1.0">

<xsl:output cdata-section-elements="script"/>

<!-- Copy everything that doesn't match other rules -->
<xsl:template match="/ | @* | node()">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
  </xsl:copy>
</xsl:template>

<!-- strip comments -->
<xsl:template match="comment()"/>

<!-- Success criteria -->
<xsl:template match="conf:pass">
  <prompt>pass</prompt>
  <exit/>
</xsl:template>

<!-- Failure criteria -->
<xsl:template match="conf:fail">
  <prompt>fail</prompt>
  <exit/>
</xsl:template>

</xsl:stylesheet>

---Instance Document---

<?xml version="1.0"?>
<root version="2.0"
  xmlns="http://www.testxsl.org/1999/ournamespace";
  xmlns:conf="http://www.testxsl.org/2005/conformance";>
 <catch>
  <conf:fail expr="'document caught event ' + _event"/>
 </catch>
</root>

---Output---

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://www.testxsl.org/1999/ournamespace"; xmlns:conf="http://www.testxsl.org/2005/conformance"; version="2.0">
 <catch>
  <prompt>fail</prompt><exit/>
 </catch>
</root>

---Desired Output---

<?xml version="1.0" encoding="UTF-8"?>
<root version="2.0">
 <catch>
  <prompt>fail</prompt><exit/>
 </catch>
</root>

----------------

Dan Evans

Reply via email to