Bug#568348: libsaxon-java: produces extra NS declaration if multiple prefixes for NS

brian m. carlson sandals at crustytoothpaste.ath.cx
Thu Feb 4 03:10:13 UTC 2010


Package: libsaxon-java
Version: 1:6.5.5-6
Severity: important
File: /usr/share/java/saxon.jar

If, in a stylesheet, the same namespace is declared both as the default
namespace and with a prefix, and the prefix is present in the
exclude-result-prefixes attribute, Saxon will emit a namespace
declaration for the prefixed form as well.

For example, in the attached testcase, the XHTML namespace is both the
default namespace (xmlns) and a prefixed namespace (xmlns:xhtml).  Since
the "xhtml" prefix is listed in exclude-result-prefixes, it should not
be emitted by Saxon, but it is anyway.

This causes problems for stylesheets that process XHTML input and
produces XHTML output.  In XSLT 1.0, unprefixed element names in
xsl:template match statements are not interpreted as being in the
default namespace, but rather in no namespace.  Therefore, to be able to
match elements in the XHTML namespace, some prefix must be defined for
the purpose of matching these elements.  However, on output, the only
namespace declaration that can be present is the default one, since DTDs
do not understand namespace declarations.

As a consequence, Saxon is not particularly well-suited to processing
XHTML, which is a significant (and possibly the most common) use case.
There is a workaround: if inline elements are not used, but instead
replaced with xsl:element and xsl:attribute code, the spurious
declaration is not emitted.  This significantly bloats the stylesheet,
however, and makes it hard to read.

Transcript follows:

lakeview ok % xsltproc foo.xsl dummy.dbx                                     
<?xml version="1.0"?>
<db:book xmlns:db="http://docbook.org/ns/docbook" xmlns="http://www.w3.org/1999/xhtml"><a href="http://validator.w3.org/check/referer">XHTML+RDFa 1.0</a><a href="http://validator.w3.org/check/referer">XHTML+RDFa 1.0</a></db:book>

lakeview ok % java -jar /usr/share/java/xalan2.jar -in dummy.dbx -xsl foo.xsl
<?xml version="1.0" encoding="UTF-8"?><db:book xmlns:db="http://docbook.org/ns/docbook" xmlns="http://www.w3.org/1999/xhtml"><a href="http://validator.w3.org/check/referer">XHTML+RDFa 1.0</a><a href="http://validator.w3.org/check/referer">XHTML+RDFa 1.0</a></db:book>

lakeview ok % java -jar /usr/share/java/saxon.jar dummy.dbx foo.xsl          
<?xml version="1.0" encoding="utf-8"?><db:book xmlns:db="http://docbook.org/ns/docbook" xmlns="http://www.w3.org/1999/xhtml"><a xmlns:xhtml="http://www.w3.org/1999/xhtml" href="http://validator.w3.org/check/referer">XHTML+RDFa 1.0</a><a xmlns:xhtml="http://www.w3.org/1999/xhtml" href="http://validator.w3.org/check/referer">XHTML+RDFa 1.0</a></db:book>%

Notice that the Saxon output contains an xmlns:xhtml declaration that is
undesired and also useless.

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-trunk-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libsaxon-java depends on:
ii  default-jre [java2-runtime]   1.6-34     Standard Java or Java compatible R
ii  gcj-4.4-jre [java2-runtime]   4.4.3-1    Java runtime environment using GIJ
ii  gcj-jre [java2-runtime]       4:4.4.2-3  Java runtime environment using GIJ
ii  openjdk-6-jre [java2-runtime] 6b17-1.7-1 OpenJDK Java runtime, using Hotspo

libsaxon-java recommends no packages.

Versions of packages libsaxon-java suggests:
ii  libjdom1-java               1.1.1+dfsg-1 lightweight and fast library using
pn  libsaxon-java-doc           <none>       (no description available)

-- no debconf information

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 713 440 7475 | http://crustytoothpaste.ath.cx/~bmc | My opinion only
OpenPGP: RSA v4 4096b 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-java-maintainers/attachments/20100204/9ebaac9f/attachment-0001.pgp>


More information about the pkg-java-maintainers mailing list