You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Will Allan <wi...@active.com> on 2000/12/09 05:01:12 UTC

Xalan-Java version 2.0.D01 Bug

Hello,

I'm doing some testing with Xalan and I believe these methods:

1. transform(InputSource xmlSource) of class
org.apache.xalan.transformer.TransformerImpl
2. parseToNode(InputSource xmlSource) of class
org.apache.xalan.transformer.TransformerImpl
3. parse(InputSource xmlSource) of class
org.apache.xerces.jaxp.DocumentBuilderImpl

...are out of sync, meaning that they parse xml input differently.

Here is my source:

import org.apache.trax.*;
import org.xml.sax.*;
import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.apache.serialize.*;

public class Transform {

    public static void main(String[] args) throws Exception {

        InputSource xmlInput = new InputSource(args[0]);
        InputSource xslInput = new InputSource(args[1]);

        Processor processor = Processor.newInstance("xslt");
        Templates templates = processor.process(xslInput);
        Transformer transformer = templates.newTransformer();

        DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document output = builder.newDocument();
        Node xml = builder.parse(xmlInput);

        transformer.transformNode(xml, new Result(output));
        //transformer.transform(xmlInput, new Result(output));

        Serializer serializer = SerializerFactory.getSerializer("xml");
        serializer.setOutputStream(System.out);
        serializer.asDOMSerializer().serialize(output);
    }
}

When I switch the commented lines from transform() to transformNode() I get
two different results. Here is the results with tranform():

<?xml version="1.0" encoding="UTF-8"?>
<elements><textQuestion
id="name"><label>Name:</label><default>Bob</default><attributes><size>20</si
ze><maxlength>20</maxlength></attributes></textQuestion></elements>

Here is the results with transformNode():

<?xml version="1.0" encoding="UTF-8"?>
<elements>

	</elements>

I have also tried this, as I said, with the parseToNode() method in
TransformerImpl with the same result. Upon comparison of parseToNode()
source with transform() source I noticed some of the code was different,
despite the comments which say "duplicate code".

-Will