java.lang.Object
org.cybergarage.xml.Parser
org.cybergarage.xml.parser.JaxpParser
Direct Known Subclasses:
XMLParser

public class JaxpParserextends Parser
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
  • Constructor Details

    • JaxpParser

      public JaxpParser()
      Creates a new JaxpParser instance.
  • Method Details

    • parse

      public Node parse(Node parentNode, Node domNode, int rank)
      Recursively parses a DOM node and converts it to a Node tree.
      Parameters:
      parentNode - the parent Node to attach parsed nodes to
      domNode - the DOM node to parse
      rank - the recursion depth level (for debugging)
      Returns:
      the parsed Node
    • parse

      public Node parse(Node parentNode, Node domNode)
      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 to
      domNode - the DOM node to parse
      Returns:
      the parsed Node
    • parse

      public Node parse(InputStream inStream) throws ParserException
      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:
      parse in class Parser
      Parameters:
      inStream - the input stream containing XML content
      Returns:
      the root node of the parsed XML document
      Throws:
      ParserException - if parsing fails