[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xslt 1.0 namespace on output doc

Subject: xslt 1.0 namespace on output doc
From: "Manfred Staudinger" <manfred.staudinger@xxxxxxxxx>
Date: Wed, 12 Apr 2006 09:22:56 -0700
xslt xhtml xmlns
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>Vsterreichisches 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>Vsterreichisches 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.