|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnl.knowledgeplaza.util.io.XmlWriter
public class XmlWriter
XmlWriter derived from / inspired on / extended from / API compatible with http://code.google.com/p/osjava/wiki/XmlWriter Only this implementation has a few problems, like no XMLNS support on nodes and some issues with the ttty printer. This class does not do any validation checking, it just helps writing pretty printed XML Usage: OutputStreamWriter w = new OutputStreamWriter(new FileOutputStream("c:/tmp/test.xml"),"UTF-8"); XmlWriter lXmlWriter = new XmlWriter(w); lXmlWriter.writeXmlVersion("1.0", "UTF-8"); lXmlWriter.writeEntity("root"); lXmlWriter.writeXmlns(null, "urn:iso:std:iso:20022:tech:xsd:pain.001.001.03", ""); lXmlWriter.writeXmlns("xsi", "http://www.w3.org/2001/XMLSchema-instance", "urn:iso:std:iso:20022:tech:xsd:pain.001.001.03 [LOCATION] pain.001.001.03.xsd"); lXmlWriter.writeEntity("node1"); lXmlWriter.writeAttribute("attr1", "value1"); lXmlWriter.writeAttribute("attr2", "value2"); lXmlWriter.writeAttribute("attr3", "value3"); lXmlWriter.writeEntityWithText("txtnode", "some text"); lXmlWriter.endEntity(); lXmlWriter.endEntity(); lXmlWriter.close();
| Constructor Summary | |
|---|---|
XmlWriter(Writer writer)
|
|
| Method Summary | |
|---|---|
void |
close()
|
XmlWriter |
endEntity()
|
void |
flush()
Flushes the stream. |
boolean |
getPretty()
|
static void |
main(String[] args)
|
void |
setPretty(boolean value)
|
XmlWriter |
writeAttribute(String id,
String value)
|
XmlWriter |
writeEntity(String name)
write an entity |
XmlWriter |
writeEntityWithText(String name,
String text)
|
XmlWriter |
writeText(String text)
|
XmlWriter |
writeXmlns(String id,
String value,
String schemaLocation)
write XMLNS info |
XmlWriter |
writeXmlVersion(String version,
String encoding)
write xml version info |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XmlWriter(Writer writer)
writer - | Method Detail |
|---|
public void setPretty(boolean value)
public boolean getPretty()
public void flush()
throws IOException
IOException - If an I/O error occurs
public void close()
throws IOException
close in interface CloseableIOException
public XmlWriter writeXmlVersion(String version,
String encoding)
throws IOException
version - encoding -
IOException
public XmlWriter writeEntity(String name)
throws IOException
name -
IOException
public XmlWriter endEntity()
throws IOException
name -
IOException
public XmlWriter writeEntityWithText(String name,
String text)
throws IOException
name - text -
IOException
public XmlWriter writeAttribute(String id,
String value)
throws IOException
id - value -
IOException
public XmlWriter writeXmlns(String id,
String value,
String schemaLocation)
throws IOException
id - (may be null)value - schemaLocation - (may be null)
IOException
public XmlWriter writeText(String text)
throws IOException
text -
IOExceptionpublic static void main(String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||