Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Question on Indentation

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Markus Jais <markus_jais AT yahoo.de>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] Question on Indentation
  • Date: Fri, 24 Oct 2003 22:43:46 -0000

hello

I hava java 1.4.2 and XOM 1.0d21

this is my sample Code:



=================

import nu.xom.*;
import java.io.*;

class XomOne
{
private static Element makeLanguage(String name, String creator,
boolean isOOP)
{
Element elem = new Element("language");
Element name_elem = new Element(name);
Element creator_elem = new Element(creator);

name_elem.appendChild(name);
creator_elem.appendChild(creator);

elem.appendChild(name_elem);
elem.appendChild(creator_elem);

Attribute oop = new Attribute("isoop", isOOP ? "yes" : "no");
elem.addAttribute(oop);

return elem;

}

public static void main (String args[])
{
Element [] langs = new Element[3];
langs[0] = makeLanguage("Ruby", "Matz", true);
langs[1] = makeLanguage("Python", "Guido", true);
langs[2] = makeLanguage("C", "Dennis", false);

Element root = new Element("programming_languages");

for(int i = 0; i < langs.length; i++) {
root.appendChild(langs[i]);
}

Document doc = new Document(root);
try {
Serializer serializer = new Serializer(System.out);
serializer.setIndent(3);
serializer.write(doc);
} catch (IOException ex) {
ex.printStackTrace();
}

}
}

==================

here is the output:

/home/markus/java/xml$ java XomOne
<?xml version="1.0" encoding="UTF-8"?>
<programming_languages>
<language isoop="yes">
<Ruby>Ruby</Ruby>
<Matz>Matz</Matz>
</language>
<language isoop="yes">
<Python>Python</Python>
<Guido>Guido</Guido>
</language>
<language isoop="no">
<C>C</C>
<Dennis>Dennis</Dennis>
</language></programming_languages>
/home/markus/java/xml$


everything works fine but shouldn't the closing root element be
on it's own line ??


regards

Markus














Archive powered by MHonArc 2.6.24.

Top of Page