Package org.htmlcleaner
Class XmlSerializer
java.lang.Object
org.htmlcleaner.Serializer
org.htmlcleaner.XmlSerializer
- Direct Known Subclasses:
BrowserCompactXmlSerializer,CompactXmlSerializer,PrettyXmlSerializer,SimpleXmlSerializer
Abstract XML serializer - contains common logic for descendants.
-
Field Summary
FieldsFields inherited from class org.htmlcleaner.Serializer
props -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleandontEscape(TagNode tagNode) protected StringgetXmlAsString(TagNode tagNode) Deprecated.Use getAsString() instead.getXmlAsString(TagNode tagNode, String charset) Deprecated.Use getAsString() instead.booleanprotected booleanisForbiddenAttribute(TagNode tagNode, String attName, String value) Override to add additional conditions.protected booleanisForbiddenTag(TagNode tagNode) protected booleanisHeadOrBody(String tagName) protected booleanisMinimizedTagSyntax(TagNode tagNode) protected voidserializeAttribute(TagNode tagNode, Writer writer, String attName, String attValue) This allows overriding to eliminate forbidden attributes (for example javascript attributes onclick, onblur, etc.protected voidserializeCData(CData item, TagNode tagNode, Writer writer) Serialize a CDATA section.protected voidserializeContentToken(ContentNode item, TagNode tagNode, Writer writer) Serialize a content token, escaping where necessary.protected voidserializeEndTag(TagNode tagNode, Writer writer) protected voidserializeEndTag(TagNode tagNode, Writer writer, boolean newLine) protected voidserializeOpenTag(TagNode tagNode, Writer writer) protected voidserializeOpenTag(TagNode tagNode, Writer writer, boolean newLine) voidsetCreatingHtmlDom(boolean creatingHtmlDom) voidDeprecated.Use write() instead.voidwriteXmlToFile(TagNode tagNode, String fileName) Deprecated.Use writeToFile() instead.voidwriteXmlToFile(TagNode tagNode, String fileName, String charset) Deprecated.Use writeToFile() instead.voidwriteXmlToStream(TagNode tagNode, OutputStream out) Deprecated.Use writeToStream() instead.voidwriteXmlToStream(TagNode tagNode, OutputStream out, String charset) Deprecated.Use writeToStream() instead.Methods inherited from class org.htmlcleaner.Serializer
getAsString, getAsString, getAsString, getAsString, getAsString, isScriptOrStyle, serialize, write, write, writeToFile, writeToFile, writeToFile, writeToFile, writeToStream, writeToStream, writeToStream, writeToStream
-
Field Details
-
XMLNS_NAMESPACE
- See Also:
-
-
Constructor Details
-
XmlSerializer
-
-
Method Details
-
setCreatingHtmlDom
public void setCreatingHtmlDom(boolean creatingHtmlDom) - Parameters:
creatingHtmlDom- the creatingHtmlDom to set
-
isCreatingHtmlDom
public boolean isCreatingHtmlDom()- Returns:
- the creatingHtmlDom
-
writeXmlToStream
@Deprecated public void writeXmlToStream(TagNode tagNode, OutputStream out, String charset) throws IOException Deprecated.Use writeToStream() instead.- Throws:
IOException
-
writeXmlToStream
Deprecated.Use writeToStream() instead.- Throws:
IOException
-
writeXmlToFile
@Deprecated public void writeXmlToFile(TagNode tagNode, String fileName, String charset) throws IOException Deprecated.Use writeToFile() instead.- Throws:
IOException
-
writeXmlToFile
Deprecated.Use writeToFile() instead.- Throws:
IOException
-
getXmlAsString
Deprecated.Use getAsString() instead. -
getXmlAsString
Deprecated.Use getAsString() instead. -
writeXml
Deprecated.Use write() instead.- Throws:
IOException
-
escapeXml
-
dontEscape
-
isMinimizedTagSyntax
-
serializeOpenTag
- Throws:
IOException
-
serializeCData
Serialize a CDATA section. If the context is a script or style tag, and using CDATA for script and style is set to true, then we just write the actual content, as the whole section is wrapped in CDATA tokens. Otherwise we escape the content as if it were regular text.- Parameters:
item- the CDATA instancetagNode- the TagNode within which the CDATA appearswriter- the writer to output to- Throws:
IOException
-
serializeContentToken
protected void serializeContentToken(ContentNode item, TagNode tagNode, Writer writer) throws IOException Serialize a content token, escaping where necessary.- Parameters:
item- the content token to serializetagNode- the TagNode within which the content token appearswriter- the writer to output to- Throws:
IOException
-
serializeOpenTag
- Throws:
IOException
-
isForbiddenTag
- Parameters:
tagNode-- Returns:
- true if the tag is forbidden
-
isHeadOrBody
-
serializeAttribute
protected void serializeAttribute(TagNode tagNode, Writer writer, String attName, String attValue) throws IOException This allows overriding to eliminate forbidden attributes (for example javascript attributes onclick, onblur, etc. )- Parameters:
writer-attName-attValue-- Throws:
IOException
-
isForbiddenAttribute
Override to add additional conditions.- Parameters:
tagNode-attName-value-- Returns:
- true if the attribute should not be outputed.
-
serializeEndTag
- Throws:
IOException
-
serializeEndTag
- Throws:
IOException
-