Project

Profile

Help

Bug #4929

Unexpected transformation result when (identity) transforming to XMLStreamWriterDestination

Added by Maarten Kroon 3 months ago. Updated 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
JAXP Java API
Sprint/Milestone:
-
Start date:
2021-03-07
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
10, trunk
Fix Committed on Branch:
10, trunk
Fixed in Maintenance Release:

Description

Hi,

When I execute an identity XSLT transformation to an XMLStreamWriterDestination using the s9api (Saxon Java 10.3) the result of the transformation differs from it's input. Some attributes are removed, other attributes are renamed to the local name of the containing element.

I've created a small Java code example that reproduces the problem. The source XML and XSLT files are also attached. When you run this testcase all "deltaxml:deltaV2" attributes are removed and the attributes "deltaxml:ordered" and "deltaxml:key" seem to be renamed to the local name of their containing element.

package test;

import java.io.File;
import java.io.FileOutputStream;

import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.stream.StreamSource;

import net.sf.saxon.s9api.Processor;
import net.sf.saxon.s9api.Serializer;
import net.sf.saxon.s9api.XdmNode;
import net.sf.saxon.s9api.XsltExecutable;
import net.sf.saxon.stax.XMLStreamWriterDestination;

public class Test {

  public static void main(String[] args) {
    try {
      Processor processor = new Processor(false);
      XdmNode inputDoc = processor.newDocumentBuilder().build(new File("renvooi-pre.xml"));
      try (FileOutputStream fos = new FileOutputStream(new File("renvooi-pre-out.xml")) ) {
        Serializer serializer = processor.newSerializer(fos);
        XMLStreamWriter xsw = serializer.getXMLStreamWriter(); 
        XsltExecutable executable = processor.newXsltCompiler().compile(new StreamSource(new File("identity.xsl")));
        executable.load30().applyTemplates(inputDoc, new XMLStreamWriterDestination(xsw));
      }
    } catch (Exception e) {
      e.printStackTrace(System.err);
    }
  }
}

Kind regards, Maarten Kroon

identity.xsl (221 Bytes) identity.xsl Maarten Kroon, 2021-03-07 15:11
renvooi-pre.xml (129 KB) renvooi-pre.xml Maarten Kroon, 2021-03-07 15:11

History

#1 Updated by Michael Kay 3 months ago

  • Status changed from New to In Progress

Sorry for the delay in responding to this. I've added this as a test case and reproduced the problem. It looks like none of our test for XMLStreamWriter output were using namespaced attributes.

#2 Updated by Michael Kay 3 months ago

  • Category set to JAXP Java API
  • Status changed from In Progress to Resolved
  • Assignee set to Michael Kay
  • Priority changed from Low to Normal
  • Applies to branch trunk added
  • Fix Committed on Branch 10, trunk added

A simple coding error in ReceiverToXMLStreamWriter.startElement()

#3 Updated by O'Neil Delpratt 2 months ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 10.5 added

Bug fix applied to Saxon 10.5 maintenance release.

Please register to edit this issue

Also available in: Atom PDF