JDK Transformer bug?

D

dibblego

Hello,
Can anyone please confirm or otherwise, that the following source test
case produces unexpected behaviour? I have found nothing in the bug
parade thus far.
This code is also available at http://www.xdweb.net/~dibblego/X.java
Thanks for any pointers.

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import java.io.Writer;
import java.io.StringWriter;
import java.io.StringReader;

// JDK 1.5.0_04 and JDK 1.5.0_05
// Win32
public final class X
{
private X() throws UnsupportedOperationException
{
throw new UnsupportedOperationException();
}

public static void main(final String[] args) throws
TransformerException
{
final String xml = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?><foo></foo>";
final String xsl = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?><xsl:stylesheet
xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"
version=\"1.0\"><xsl:eek:utput method=\"html\" indent=\"yes\"
doctype-public=\"-//W3C//DTD HTML 4.01 Transitional//EN\"
doctype-system=\"http://www.w3.org/TR/html4/loose.dtd\"/><xsl:template
match=\"/\"><html></html></xsl:template></xsl:stylesheet>";
final Writer w = new StringWriter();
final Transformer t =
TransformerFactory.newInstance().newTransformer(new StreamSource(new
StringReader(xsl)));
t.transform(new StreamSource(new StringReader(xml)), new
StreamResult(w));
System.out.println(w);

// expected
// <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

// actual (note the lack of a single space character)
// <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top