Package de.hybris.bootstrap.xml
Class XMLWriter
java.lang.Object
de.hybris.bootstrap.xml.XMLWriter
XML document writer based upon a
XMLTagWriter tree.
Use like this:
XMLWriter wr = new XMLWriter(
new FileWriter( "test.xml" ),
new MyRootTagWriter()
);
// optionally define the DTD
wr.setDtd(
new String[]{
"faces-config" // name
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN", // public
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd" // system
}
);
// optionally set encoding
wr.setEncoding("UTF-8");
// write
try
{
wr.write( new MyRootDataObject() );
}
catch( XMLWriteException e )
{
// report some error
}
finally
{
try{ wr.close() } catch( IOException e ){}
}
-
Constructor Summary
ConstructorsConstructorDescriptionXMLWriter(OutputStream os, XMLTagWriter root) Creates a new xml writer which wraps a exitingOutputStream.XMLWriter(Writer wr, XMLTagWriter root) Creates a new xml writer which wraps a exitingWriter. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected org.znerd.xmlenc.XMLOutputterprotected voidendDocument(org.znerd.xmlenc.XMLOutputter xout) String[]getDtd()org.znerd.xmlenc.LineBreakcharvoidvoidsetEncoding(String encoding) voidvoidsetLineBreak(org.znerd.xmlenc.LineBreak lineBreak) voidsetQuotation(char quotation) protected voidstartDocument(org.znerd.xmlenc.XMLOutputter xout) void
-
Constructor Details
-
XMLWriter
Creates a new xml writer which wraps a exitingWriter.- Parameters:
wr- the underlying writerroot- the root tag writer, must contain all sub tag writers of the document
-
XMLWriter
Creates a new xml writer which wraps a exitingOutputStream.- Parameters:
os- the underlying output streamroot- the root tag writer, must contain all sub tag writers of the document
-
-
Method Details
-
createXMLOutputter
protected org.znerd.xmlenc.XMLOutputter createXMLOutputter(Writer wr) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
write
- Throws:
XMLWriteException
-
startDocument
- Throws:
XMLWriteException
-
endDocument
protected void endDocument(org.znerd.xmlenc.XMLOutputter xout) -
close
- Throws:
IllegalStateExceptionIOException
-
getDtd
-
setDtd
-
getEncoding
-
setEncoding
-
getIndent
-
setIndent
-
getLineBreak
public org.znerd.xmlenc.LineBreak getLineBreak() -
setLineBreak
public void setLineBreak(org.znerd.xmlenc.LineBreak lineBreak) -
getQuotation
public char getQuotation() -
setQuotation
public void setQuotation(char quotation) -
getRootTagWriter
-