xsl-list
[Top] [All Lists]

[xsl] xslt 1.0 namespace on output doc

2006-04-12 09:23:17
Hi list,
I'm at a lost to sort out where my problem with this stylesheet
is. The following example xml:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="view_a0.xsl" type="text/xsl"?>
<doc xmlns="http://www.w3.org/1999/xhtml";>
   <title>test_a0</title>
   <path>
      <span>Österreichisches Staatsarchiv</span>
   </path>
   <body>
      <ul>
         <li><span>Allgemeines Verwaltungsarchiv</span></li>
         <li><span>Finanz- und Hofkammerarchiv</span></li>
         <li><span>Haus-, Hof- und Staatsarchiv</span></li>
         <li><span>Kriegsarchiv</span></li>
      </ul>
   </body>
</doc>

should get transformed by:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
                        xmlns="http://www.w3.org/1999/xhtml";
                        xmlns:xhtml="http://www.w3.org/1999/xhtml";
                        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml"
   doctype-public="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
   doctype-system="-//W3C//DTD XHTML 1.0 Strict//EN"
   omit-xml-declaration="yes" indent="yes" />
<xsl:template match="node() | @*">
        <xsl:copy>
                <xsl:apply-templates select="node() | @*"/>
        </xsl:copy>
</xsl:template>
<xsl:template match="xhtml:body">
        <xsl:copy>
                <h3>Documenta Rudolphina</h3>
                <xsl:apply-templates select="/xhtml:doc/xhtml:path"/>
                <div id="xmlbody" class="archiv">
                        <xsl:apply-templates select="node() | @*"/>
                </div>
        </xsl:copy>
</xsl:template>
<xsl:template match="xhtml:path">
        <div>
                <xsl:apply-templates select="node() | @*"/>
        </div>
</xsl:template>
<xsl:template match="/">
        <html lang="de" xml:lang="de">
                <head>
                        <meta http-equiv="Content-Type" 
content="application/xhtml+xml;
charset=UTF-8" />
                        <xsl:apply-templates select="xhtml:doc/xhtml:title"/>
                </head>
                <xsl:apply-templates select="xhtml:doc/xhtml:body"/>
        </html>
</xsl:template>
</xsl:stylesheet>

into the following xhtml (apart from white-space, and well, not really
xhtml in IE):
<!DOCTYPE html
  PUBLIC "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
"-//W3C//DTD XHTML 1.0 Strict//EN">
<html xmlns="http://www.w3.org/1999/xhtml"; lang="de" xml:lang="de">
   <head>
      <meta http-equiv="Content-Type" content="application/xhtml+xml;
charset=UTF-8"/>
      <title>test_a0</title>
   </head>
   <body>
      <h3>Documenta Rudolphina</h3>
      <div class="path">
         <span>Österreichisches Staatsarchiv</span>
      </div>
      <div id="xmlbody" class="archiv">
         <ul>
            <li><span>Allgemeines Verwaltungsarchiv</span></li>
            <li><span>Finanz- und Hofkammerarchiv</span></li>
            <li><span>Haus-, Hof- und Staatsarchiv</span></li>
            <li><span>Kriegsarchiv</span></li>
         </ul>
      </div>
   </body>
</html>

But only Transformiix (Fx 1.5.01) gives me the expected result, whereas
SAXON 6.5.5 and MSXML 3 both add
xmlns:xhtml="http://www.w3.org/1999/xhtml";
to the html element.

To achieve my expected result with SAXON 6.5.5, I modified the
stylsheet (changes marked by ***), but the changes are to the effect, that
the default namespace declaration for literal result-elements is canceled:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
                        xmlns:xhtml="http://www.w3.org/1999/xhtml";
                        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";> <!-- 
*** -->
<xsl:output method="xml"
   doctype-public="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
   doctype-system="-//W3C//DTD XHTML 1.0 Strict//EN"
   omit-xml-declaration="yes" indent="yes" />
<xsl:template match="node() | @*">
        <xsl:copy>
                <xsl:apply-templates select="node() | @*"/>
        </xsl:copy>
</xsl:template>
<xsl:template match="xhtml:body">
        <body xmlns="http://www.w3.org/1999/xhtml";> <!-- *** -->
                <h3>Documenta Rudolphina</h3>
                <xsl:apply-templates select="/xhtml:doc/xhtml:path"/>
                <div id="xmlbody" class="archiv">
                        <xsl:apply-templates select="node() | @*"/>
                </div>
        </body> <!-- *** -->
</xsl:template>
<xsl:template match="xhtml:path">
        <div class="path" xmlns="http://www.w3.org/1999/xhtml";> <!-- *** -->
                <xsl:apply-templates select="node() | @*"/>
        </div>
</xsl:template>
<xsl:template match="/">
        <html xmlns="http://www.w3.org/1999/xhtml"; lang="de" xml:lang="de">
<!-- *** -->
                <head>
                        <meta http-equiv="Content-Type" 
content="application/xhtml+xml;
charset=UTF-8" />
                        <xsl:apply-templates select="xhtml:doc/xhtml:title"/>
                </head>
                <xsl:apply-templates select="xhtml:doc/xhtml:body"/>
        </html>
</xsl:template>
</xsl:stylesheet>

But in this case Transformiix added
xmlns="http://www.w3.org/1999/xhtml";
to the body and the div (with class="path") element, whereas
MSXML 3 still added
xmlns:xhtml="http://www.w3.org/1999/xhtml";
to the html element.

I've no information about Opera (9.0 beta) and libxslt (Safari), but would
like to receive any comments on these too.

Any help will be much appreciated.
Regards, Manfred

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>