| java.lang.Object org.apache.tools.ant.util.DOMElementWriter
DOMElementWriter | public class DOMElementWriter (Code) | | Writes a DOM tree to a given Writer.
warning: this utility currently does not declare XML Namespaces.
Utility class used by
org.apache.tools.ant.XmlLoggerXmlLogger and
org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter
XMLJUnitResultFormatter}.
|
Inner Class :public static class XmlNamespacePolicy | |
Field Summary | |
protected String[] | knownEntities Don't try to be too smart but at least recognize the predefined
entities. |
Constructor Summary | |
public | DOMElementWriter() Create an element writer. | public | DOMElementWriter(boolean xmlDeclaration) Create an element writer
XML namespaces will be ignored. | public | DOMElementWriter(boolean xmlDeclaration, XmlNamespacePolicy namespacePolicy) Create an element writer
XML namespaces will be ignored. |
Method Summary | |
public void | closeElement(Element element, Writer out, int indent, String indentWith, boolean hasChildren) Writes a DOM tree to a stream. | public String | encode(String value) Escape <, > & ', " as their entities and
drop characters that are illegal in XML documents.
Parameters: value - the string to encode. | public String | encodedata(String value) Drop characters that are illegal in XML documents.
Also ensure that we are not including an ]]>
marker by replacing that sequence with
]]> .
See XML 1.0 2.2
http://www.w3.org/TR/1998/REC-xml-19980210#charsets and
2.7 http://www.w3.org/TR/1998/REC-xml-19980210#sec-cdata-sect.
Parameters: value - the value to be encoded. | public boolean | isLegalCharacter(char c) Is the given character allowed inside an XML document?
See XML 1.0 2.2
http://www.w3.org/TR/1998/REC-xml-19980210#charsets.
Parameters: c - the character to test. | public boolean | isReference(String ent) Is the given argument a character or entity reference?
Parameters: ent - the value to be checked. | public void | openElement(Element element, Writer out, int indent, String indentWith) Writes the opening tag - including all attributes -
corresponding to a DOM element. | public void | openElement(Element element, Writer out, int indent, String indentWith, boolean hasChildren) Writes the opening tag - including all attributes -
corresponding to a DOM element. | public void | write(Element root, OutputStream out) Writes a DOM tree to a stream in UTF8 encoding. | public void | write(Element element, Writer out, int indent, String indentWith) Writes a DOM tree to a stream. | public void | writeXMLDeclaration(Writer wri) Writes the XML declaration if xmlDeclaration is true. |
knownEntities | protected String[] knownEntities(Code) | | Don't try to be too smart but at least recognize the predefined
entities.
|
DOMElementWriter | public DOMElementWriter()(Code) | | Create an element writer.
The ?xml? declaration will be included, namespaces ignored.
|
DOMElementWriter | public DOMElementWriter(boolean xmlDeclaration)(Code) | | Create an element writer
XML namespaces will be ignored.
Parameters: xmlDeclaration - flag to indicate whether the ?xml? declarationshould be included. since: Ant1.7 |
DOMElementWriter | public DOMElementWriter(boolean xmlDeclaration, XmlNamespacePolicy namespacePolicy)(Code) | | Create an element writer
XML namespaces will be ignored.
Parameters: xmlDeclaration - flag to indicate whether the ?xml? declarationshould be included. Parameters: namespacePolicy - the policy to use. since: Ant1.7 |
closeElement | public void closeElement(Element element, Writer out, int indent, String indentWith, boolean hasChildren) throws IOException(Code) | | Writes a DOM tree to a stream.
Parameters: element - the Root DOM element of the tree Parameters: out - where to send the output Parameters: indent - number of Parameters: indentWith - string that should be used to indent thecorresponding tag. Parameters: hasChildren - if true indent. throws: IOException - if an error happens while writing to the stream. |
encode | public String encode(String value)(Code) | | Escape <, > & ', " as their entities and
drop characters that are illegal in XML documents.
Parameters: value - the string to encode. the encoded string. |
isReference | public boolean isReference(String ent)(Code) | | Is the given argument a character or entity reference?
Parameters: ent - the value to be checked. true if it is an entity. |
openElement | public void openElement(Element element, Writer out, int indent, String indentWith) throws IOException(Code) | | Writes the opening tag - including all attributes -
corresponding to a DOM element.
Parameters: element - the DOM element to write Parameters: out - where to send the output Parameters: indent - number of Parameters: indentWith - string that should be used to indent thecorresponding tag. throws: IOException - if an error happens while writing to the stream. |
openElement | public void openElement(Element element, Writer out, int indent, String indentWith, boolean hasChildren) throws IOException(Code) | | Writes the opening tag - including all attributes -
corresponding to a DOM element.
Parameters: element - the DOM element to write Parameters: out - where to send the output Parameters: indent - number of Parameters: indentWith - string that should be used to indent thecorresponding tag. Parameters: hasChildren - whether this element has children. throws: IOException - if an error happens while writing to the stream. since: Ant 1.7 |
write | public void write(Element root, OutputStream out) throws IOException(Code) | | Writes a DOM tree to a stream in UTF8 encoding. Note that
it prepends the <?xml version='1.0' encoding='UTF-8'?> if
the xmlDeclaration field is true.
The indent number is set to 0 and a 2-space indent.
Parameters: root - the root element of the DOM tree. Parameters: out - the outputstream to write to. throws: IOException - if an error happens while writing to the stream. |
write | public void write(Element element, Writer out, int indent, String indentWith) throws IOException(Code) | | Writes a DOM tree to a stream.
Parameters: element - the Root DOM element of the tree Parameters: out - where to send the output Parameters: indent - number of Parameters: indentWith - string that should be used to indent thecorresponding tag. throws: IOException - if an error happens while writing to the stream. |
writeXMLDeclaration | public void writeXMLDeclaration(Writer wri) throws IOException(Code) | | Writes the XML declaration if xmlDeclaration is true.
Parameters: wri - the writer to write to. throws: IOException - if there is an error. since: Ant 1.7.0 |
|
|