B
Bernd Fuhrmann
Hi!
I have some trouble with some simple stupid XSLT-stuff.
My stylesheet:
-------------
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
<xslutput method="xml"
cdata-section-elements="script"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
encoding="iso-8859-1"/>
<xsl:template match="html">
<p>Inserted</p>
</xsl:template>
</xsl:stylesheet>
-------------
My XML-Document:
-------------
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Whatever</title></head><body></body></html>
-------------
The result of this transformation is:
-------------
<?xml version="1.0" encoding="iso-8859-1"?>
-------------
or
-------------
<?xml version="1.0" encoding="iso-8859-1"?>
Whatever
-------------
Obviously the result should be sth. like <?xml ...><p>Inserted</p> and
now for the truly strange thing: Changing the stylesheet to:
------------
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
<xslutput method="xml"
cdata-section-elements="script"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
encoding="iso-8859-1"/>
<xsl:template match="xhtml:html">
<p>Inserted</p>
</xsl:template>
</xsl:stylesheet>
------------
results in:
------------
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE p PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<p xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml">Inserted</p>
------------
Why? Why does changing a namespace declaration change the behaviour of a
XSLT processor (tried Saxon (7.6.5) and Xalan (1.6.0 with Xerxes 2.3.0))
in that way? Shouldn't match="sometag" mean default-xmlns:sometag?
In case the xmlns:xhtml-Namespace is necessary: Is there a way to keep
the xslt-processors (saxon or xalan) from inserting unused, thus
unnecessary namespace declarations that interfere with the W3C XHTML
validator?
Thanks in advance
Bernd Fuhrmann
I have some trouble with some simple stupid XSLT-stuff.
My stylesheet:
-------------
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
<xslutput method="xml"
cdata-section-elements="script"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
encoding="iso-8859-1"/>
<xsl:template match="html">
<p>Inserted</p>
</xsl:template>
</xsl:stylesheet>
-------------
My XML-Document:
-------------
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Whatever</title></head><body></body></html>
-------------
The result of this transformation is:
-------------
<?xml version="1.0" encoding="iso-8859-1"?>
-------------
or
-------------
<?xml version="1.0" encoding="iso-8859-1"?>
Whatever
-------------
Obviously the result should be sth. like <?xml ...><p>Inserted</p> and
now for the truly strange thing: Changing the stylesheet to:
------------
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
<xslutput method="xml"
cdata-section-elements="script"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
encoding="iso-8859-1"/>
<xsl:template match="xhtml:html">
<p>Inserted</p>
</xsl:template>
</xsl:stylesheet>
------------
results in:
------------
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE p PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<p xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml">Inserted</p>
------------
Why? Why does changing a namespace declaration change the behaviour of a
XSLT processor (tried Saxon (7.6.5) and Xalan (1.6.0 with Xerxes 2.3.0))
in that way? Shouldn't match="sometag" mean default-xmlns:sometag?
In case the xmlns:xhtml-Namespace is necessary: Is there a way to keep
the xslt-processors (saxon or xalan) from inserting unused, thus
unnecessary namespace declarations that interfere with the W3C XHTML
validator?
Thanks in advance
Bernd Fuhrmann