java.lang.Object
org.cybergarage.xml.Parser
org.cybergarage.xml.parser.JaxpParser
- Direct Known Subclasses:
XMLParser
JAXP-based XML parser implementation.
This parser uses the Java API for XML Processing (JAXP) to parse XML documents. It includes security measures to prevent XXE (XML External Entity) attacks and handles null character filtering for compatibility.
Key features:
- XXE attack prevention
- DTD loading disabled
- Null character filtering
- Entity resolution blanking
- DOM to Node tree conversion
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classEntity resolver that returns empty input for all external entities.private static classInput stream filter that removes null characters.Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionparse(InputStream inStream) Parses XML content from the specified input stream using JAXP.Parses a DOM node and converts it to a Node tree.Recursively parses a DOM node and converts it to a Node tree.
Constructor Details
JaxpParser
public JaxpParser()Creates a new JaxpParser instance.
Method Details
parse
parse
Parses a DOM node and converts it to a Node tree.This is a convenience method that calls
parse(Node, org.w3c.dom.Node, int)with rank set to 0.- Parameters:
parentNode- the parent Node to attach parsed nodes todomNode- the DOM node to parse- Returns:
- the parsed Node
parse
Parses XML content from the specified input stream using JAXP.This method creates a secure DocumentBuilderFactory with XXE protection disabled, parses the XML content, and converts the DOM tree to a Node tree.
- Specified by:
parsein classParser- Parameters:
inStream- the input stream containing XML content- Returns:
- the root node of the parsed XML document
- Throws:
ParserException- if parsing fails