public final class SimpleSerializer extends Object
Copyright (c) SAP AG 2001-2005
Modifier and Type | Class and Description |
---|---|
static class |
SimpleSerializer.IllegalXmlNameException |
Modifier and Type | Field and Description |
---|---|
static String |
NS_XML
Namespace name for the namespace hardwired to the prefix "xml:"
|
static String |
NS_XMLNS
Namespace name for the namespace hardwired to the prefix "xmlns:"
|
Constructor and Description |
---|
SimpleSerializer(Writer writer,
String indent)
Construct a new Serializer
|
Modifier and Type | Method and Description |
---|---|
static void |
checkLegalNCName(String name)
|
static String |
escape(String s,
boolean escapeQuoteChar)
Escape characters in a string for inclusion into XML text content.
|
SimpleSerializer |
openElement(Element element)
Serializes the open tag of the specified element and returns a new
SimpleSerializer object for use in serializing any child elements (and
writing the closing tag).
|
void |
serialize(Node n)
Serialize a node and it's children.
|
void |
setNsAware(boolean nsAware)
Set to
false to switch off namespace processing (enabling
strict DOM level 1 serialization) |
void |
setOptimizeNSDeclarations(boolean doOptimize)
When set to
true , the serializer attempts to remove
superfluous namespace declarations. |
void |
setSortAttributes(boolean sortAttributes)
When set to
true , the serializer sorts attributes
(by name). |
static String |
toString(Document doc,
boolean indent)
Serialize the document to a string.
|
static String |
toString(Document doc,
boolean indent,
boolean doNsProcessing)
Serialize the document to a string.
|
static String |
toString(Node n,
boolean indent)
Serialize the element (and it's children) to a string.
|
public static final String NS_XML
public static final String NS_XMLNS
public static String toString(Document doc, boolean indent)
doc
- the documentindent
- whether to produce indented XML or notpublic static String toString(Document doc, boolean indent, boolean doNsProcessing)
doc
- the documentindent
- whether to produce indented XML or notdoNsProcessing
- enable/disable special namespace support in the
serializerpublic static String toString(Node n, boolean indent) throws IllegalArgumentException
indent
- whether to produce indented XML or notn
- node to serializeIllegalArgumentException
- when node is a AttributeNode or DOM contains illegal namespublic void setNsAware(boolean nsAware)
false
to switch off namespace processing (enabling
strict DOM level 1 serialization)nsAware
- flagpublic void setOptimizeNSDeclarations(boolean doOptimize)
true
, the serializer attempts to remove
superfluous namespace declarations.doOptimize
- flagpublic void setSortAttributes(boolean sortAttributes)
true
, the serializer sorts attributes
(by name).sortAttributes
- flagpublic SimpleSerializer openElement(Element element) throws IOException
element
- Element for which the start tag shall be writtenIOException
public void closeElement() throws IOException
IOException
public static String escape(String s, boolean escapeQuoteChar) throws IOException
s
- un-escaped stringescapeQuoteChar
- whether to escape the quote character or not (for attribute
values). Note that attributes are supposed to be quoted using
double quotes, so apostroph characters are not
replaced.IOException
- when quoting not possiblepublic void serialize(Node n) throws IOException
n
- start nodeIOException
public static void checkLegalNCName(String name) throws SimpleSerializer.IllegalXmlNameException
Access Rights |
---|
SC | DC | Public Part | ACH |
---|---|---|---|
[sap.com] KMC-CM
|
[sap.com] tc/km/frwk
|
api
|
EP-KM-CM
|
[sap.com] KMC-WPC
|
[sap.com] tc/kmc/wpc/wpcfacade
|
api
|
EP-PIN-WPC-WCM
|
Copyright 2018 SAP AG Complete Copyright Notice