Project

Profile

Help

Bug #4929

closed

Unexpected transformation result when (identity) transforming to XMLStreamWriterDestination

Added by Maarten Kroon over 3 years ago. Updated over 3 years 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:
Platforms:

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


Files

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

Please register to edit this issue

Also available in: Atom PDF