Package org.htmlcleaner
Class DomSerializer
java.lang.Object
org.htmlcleaner.DomSerializer
DOM serializer - creates xml DOM.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected boolean
Whether XML entities should be escaped or not.protected CleanerProperties
The HTML Cleaner properties set by the user to control the HTML cleaning.protected boolean
protected String
-
Constructor Summary
ConstructorsConstructorDescriptionDomSerializer
(CleanerProperties props) DomSerializer
(CleanerProperties props, boolean escapeXml) DomSerializer
(CleanerProperties props, boolean escapeXml, boolean deserializeCdataEntities) DomSerializer
(CleanerProperties props, boolean escapeXml, boolean deserializeCdataEntities, boolean strictErrorChecking) -
Method Summary
Modifier and TypeMethodDescriptionprotected Document
createDocument
(TagNode rootNode) protected void
createSubnodes
(Document document, Element element, List<? extends BaseToken> tagChildren) Serialize a given HTML Cleaner node.protected String
deserializeCdataEntities
(String input) protected boolean
dontEscape
(Element element) encapsulate content with invalid input: '<'[CDATA[ ]]> for things like script and style elementsprotected boolean
isScriptOrStyle
(Element element) protected String
outputCData
(CData cdata) void
setXmlVersion
(String xmlVersion)
-
Field Details
-
props
The HTML Cleaner properties set by the user to control the HTML cleaning. -
escapeXml
protected boolean escapeXmlWhether XML entities should be escaped or not. -
deserializeCdataEntities
protected boolean deserializeCdataEntities -
strictErrorChecking
protected boolean strictErrorChecking -
xmlVersion
-
-
Constructor Details
-
DomSerializer
public DomSerializer(CleanerProperties props, boolean escapeXml, boolean deserializeCdataEntities, boolean strictErrorChecking) - Parameters:
props
- the HTML Cleaner properties set by the user to control the HTML cleaning.escapeXml
- if true then escape XML entitiesdeserializeCdataEntities
- if true then deserialize entities in CData sectionsstrictErrorChecking
- if false then Document strict error checking is turned off
-
DomSerializer
- Parameters:
props
- the HTML Cleaner properties set by the user to control the HTML cleaning.escapeXml
- if true then escape XML entitiesdeserializeCdataEntities
- if true then deserialize entities in CData sections
-
DomSerializer
- Parameters:
props
- the HTML Cleaner properties set by the user to control the HTML cleaning.escapeXml
- if true then escape XML entities
-
DomSerializer
- Parameters:
props
- the HTML Cleaner properties set by the user to control the HTML cleaning.
-
-
Method Details
-
getXmlVersion
-
setXmlVersion
- Throws:
Exception
-
createDocument
- Throws:
ParserConfigurationException
-
createDOM
- Parameters:
rootNode
- the HTML Cleaner root node to serialize- Returns:
- the W3C Document object
- Throws:
ParserConfigurationException
- if there's an error during serialization
-
isScriptOrStyle
- Parameters:
element
- the element to check- Returns:
- true if the passed element is a script or style element
-
dontEscape
encapsulate content with invalid input: '<'[CDATA[ ]]> for things like script and style elements- Parameters:
element
-- Returns:
- true if invalid input: '<'[CDATA[ ]]> should be used.
-
outputCData
-
deserializeCdataEntities
-
createSubnodes
protected void createSubnodes(Document document, Element element, List<? extends BaseToken> tagChildren) Serialize a given HTML Cleaner node.- Parameters:
document
- the W3C Document to use for creating new DOM elementselement
- the W3C element to which we'll add the subnodes totagChildren
- the HTML Cleaner nodes to serialize for that node
-