aspose file tools*
The moose likes XML and Related Technologies and the fly likes Generating XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Generating XML" Watch "Generating XML" New topic
Author

Generating XML

Andrew Shepperd
Greenhorn

Joined: Jul 28, 2001
Posts: 1
Using DOM Transform to generate XML. Works OK, but attributes appear in a hard to read end-to-end block. Anyone know if there is a way to get them neatly indented on individual lines?
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Using Xerces

using Crimson
Using the Sun's Crimson you can cast the w3c document to type of XmlDocument and then use the write method.

This method works except for a small shortcoming - every save creates a carriage return character behind every closing tag. As I open modify and then save the same file these characters are adding up quickly.

Using Transformer Package that is included with JAXP1.1

This method works great except for one major flaw. If your document had a DOCTYPE, when you load your document, add some nodes etc.. and then save, you will notice the DOCTYPE declaration missing!!.
HTH
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generating XML