[ 
http://issues.apache.org/jira/browse/XALANJ-2032?page=comments#action_12319041 
] 

Brian Minchau commented on XALANJ-2032:
---------------------------------------

The following was posted to xalan-j-users on Aug 17, 2005 by Dan Evans:


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



> XSLTC: Multiple namespace prefixes produce unexpected prefixes in output
> ------------------------------------------------------------------------
>
>          Key: XALANJ-2032
>          URL: http://issues.apache.org/jira/browse/XALANJ-2032
>      Project: XalanJ2
>         Type: Bug
>   Components: XSLTC
>     Versions: 2.6
>     Reporter: Alfred Nathaniel
>     Assignee: Santiago Pericas-Geertsen

>
> The bug can be demonstrated with the following stylesheet:
> <?xml version="1.0"?>
> <!-- bug3.xsl -->
> <xsl:stylesheet
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>   xmlns:xhtml="http://www.w3.org/1999/xhtml";
>   xmlns="http://www.w3.org/1999/xhtml";
>   exclude-result-prefixes="xhtml"
>   version="1.0">
>   <xsl:template match="never">
>     <xhtml:br/>
>   </xsl:template>
>   <xsl:template match="/">
>     <html>
>       <body>
>         Hello<br/>world
>       </body>
>     </html>
>   </xsl:template>
> </xsl:stylesheet>
> Given any input the result produced by the Xalan interpreter is:
> xalan -in bug3.xsl -xsl bug3.xsl
> <html xmlns="http://www.w3.org/1999/xhtml";>
>   <body>
>     Hello<br/>world
>   </body>
> </html>
> XSLTC 2.6.0 produces a different output:
> xalan -in in2.xml -xsl bug2.xsl -xsltc -v
> >>>>>>> Xalan Version Xalan Java 2.6.0, <<<<<<<
> <html xmlns="http://www.w3.org/1999/xhtml";>
>   <body>
>     Hello<xhtml:br xmlns:xhtml="http://www.w3.org/1999/xhtml"/>world
>   </body>
> </html>
> As XML documents both versions are equivalent that one could argue it not 
> really being a bug. However, contemporary browsers (Explorer6.0, 
> Firebox0.9.1, Mozilla1.7) ignore prefixed HTML tags, that the use of XSLTC 
> for HTML-to-HTML transformations is handicaped.
> The problem is in org.apache.xalan.xsltc.compiler.Parser. For each namespace 
> there is hashtable containing all tags in the stylesheet. In the example, 
> <xhtml:br/> and <br/> map to the same hashtable entry but the prefix form of 
> the first one seen by the parser is kept.
> The XSLTC code generator then uses this entry everywhere irrespective of the 
> prefix form used at the current position in the stylesheet. In order to avoid 
> the pro blem, the hashtable entries should be normalized to use a single 
> prefix form.
> WORKAROUNDS
> The safest way to avoid the problem is to avoid using multiple prefixes for 
> the same namespace. Note that with an appropriate <xls:import> sequence also 
> <xsl:template match="xhtml:br"> without any literal <xhtml:br/> can lead to 
> the same effect. That means for XHTML-to-XHTML transformations that all 
> literal tags in the stylesheet must use the prefixed notation (<xhtml:html>).
> If that is too tedious for stylesheets containing a lot of literal HTML tags, 
> you have to rearrange the imports and template definitions that the parser 
> sees for all tags the non-prefixed form first. Otherwise we will have to 
> filter the XSLTC output to do the prefix normalization in a separate step.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to