[ http://issues.apache.org/jira/browse/XALANJ-1808?page=all ]
Brian Minchau updated XALANJ-1808:
----------------------------------
Version: Latest Development Code
(was: 2.5)
> Indenting doesn't work well
> ---------------------------
>
> Key: XALANJ-1808
> URL: http://issues.apache.org/jira/browse/XALANJ-1808
> Project: XalanJ2
> Type: Bug
> Components: Serialization
> Versions: Latest Development Code
> Environment: Operating System: Other
> Platform: Other
> Reporter: Tetsuya Yoshida
> Assignee: Xalan Developers Mailing List
>
> When in.xml is printed as indenting is true and indent is 2,
> expected output is expected.xml. But I got actual.xml.
> ===== in.xml =====
> <?xml version="1.0"?>
> <a><b>b</b>
> <c>c</c>
> </a>
> ===================
> ===== expected.xml =====
> <?xml version="1.0"?>
> <a>
> <b>b</b>
> <c>c</c>
> </a>
> =========================
> ===== actual.xml =====
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <a>
> <b>b</b>
> <c>c</c> <==== indenting not correct
> </a>
> ======================
> The test code is below :
> ===== PrintXalan.java =====
> import java.io.*;
> import java.util.*;
> import javax.xml.parsers.*;
> import org.w3c.dom.*;
> import org.xml.sax.*;
> import org.apache.xml.serializer.*;
> public class PrintXalan {
> public static void main (String[] args) throws Exception {
> String inputPath = "in.xml";
> String outputPath = "outXalan.xml";
> DocumentBuilderFactory factory =
> DocumentBuilderFactory.newInstance();
> DocumentBuilder builder = factory.newDocumentBuilder();
> Document doc = builder.parse(new InputSource(new
> FileInputStream(inputPath)));
> OutputStream out = null;
> try {
> out = new FileOutputStream(outputPath);
> print(out, doc, "UTF-8", true, 2);
> out.flush();
> } finally {
> if (out != null) out.close();
> }
> }
> public static void print(OutputStream out,
>
> Document doc,
>
> String encoding,
>
> boolean indenting,
>
> int indent) throws Exception {
> Properties outputFormat =
>
> OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
>
> outputFormat.setProperty(OutputPropertiesFactory.S_KEY_INDENT_AMOUNT,
>
> String.valueOf(indent));
> ToStream serializer = new ToXMLStream();
> serializer.setOutputFormat(outputFormat);
>
> serializer.setWriter(new OutputStreamWriter(out, encoding));
> serializer.setEncoding(encoding);
> serializer.setIndent(indenting);
>
> serializer.serialize(doc);
> }
> }
> ===========================
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]