Project

Profile

Help

Bug #4433

closed

Saxon 9.9.1-5 outputs malformed XML due to duplicate default namespace declaration

Added by Andreas Sewe almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XQuery Java API
Sprint/Milestone:
-
Start date:
2020-01-19
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.9
Fix Committed on Branch:
9.9
Fixed in Maintenance Release:
Platforms:

Description

This bug occurs with Saxon 9.9.1-5 and -6 using the XQJ API. (I have previously also mention it on saxon-help, but unfortunately got no response there.)

I have attached a simple Maven project with which you can reproduce. Just run mvn clean verify exec:java -DsaxonVersion=9.9.1-6. This outputs malformed XML:

<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <title>Title</title>
   </head>
   <body>
      <article>
         <header>
            <h1>Title</h1>
         </header>
         <section xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/2005/Atom">
            <p>Some content</p>
         </section>
      </article>
   </body>
</html>

Note the duplicate default namespace declaration of the <section> element.

This bug does not occur with older versions of Saxon, as showcased by mvn clean verify exec:java -DsaxonVersion=9.9.1-4.

<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <title>Title</title>
   </head>
   <body>
      <article>
         <header>
            <h1>Title</h1>
         </header>
         <section xmlns="http://www.w3.org/1999/xhtml">
            <p>Some content</p>
         </section>
      </article>
   </body>
</html>

It also does not occur with any version when using the command-line interface, as showcased by java -cp ~/.m2/repository/net/sf/saxon/Saxon-HE/9.9.1-6/Saxon-HE-9.9.1-6.jar net.sf.saxon.Query -q:src/main/resources/org/example/saxonbug/query.xq -s:src/main/resources/org/example/saxonbug/input.atom. Command-line Saxon interestingly places the namespace declarations differently again – and IMHO best (output piped through xmllint -format for readability):

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Title</title>
  </head>
  <body>
    <article>
      <header>
        <h1>Title</h1>
      </header>
      <section>
        <p>Some content</p>
      </section>
    </article>
  </body>
</html>

This bug may hence be specific to invoking Saxon through XQJ, but it prevents us from upgrading. Also, I am really curious why using XQJ produces different results than using the command-line interface in both 9.9.1-4 and 9.9.1-6.

FYI, this might be related to issue #4319, which also sprung up with 9.9.1-5 and is related to namespace declarations as well.

I hope this information is useful in locating and fixing the bug.


Files

saxonbug.zip (2.12 KB) saxonbug.zip Minimal Maven project to reproduce Andreas Sewe, 2020-01-19 22:40

Please register to edit this issue

Also available in: Atom PDF