Package org.htmlunit.html.parser.neko
Class HtmlUnitNekoHtmlParser
java.lang.Object
org.htmlunit.html.parser.neko.HtmlUnitNekoHtmlParser
- All Implemented Interfaces:
HTMLParser
SAX parser implementation that uses the NekoHTML HTMLConfiguration
to parse HTML into a HtmlUnit-specific DOM (HU-DOM) tree.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Map
<String, ElementFactory> static final SvgElementFactory
The SVG factory. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static Throwable
Extract nested exception within an XNIException (Nekohtml uses reflection and generated exceptions are wrapped many times within XNIException and InvocationTargetException)getElementFactory
(SgmlPage page, String namespaceURI, String qualifiedName, boolean insideSvg, boolean svgSupport) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns the pre-registered element factory corresponding to the specified tag, or an UnknownElementFactory.getFactory
(String tagName) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.void
parse
(WebResponse webResponse, HtmlPage page, boolean xhtml, boolean createdByJavascript) Parses the WebResponse into an object tree representation.void
parseFragment
(DomNode parent, String source) Parses the HTML content from the given string into an object tree representation.void
parseFragment
(DomNode parent, DomNode context, String source, boolean createdByJavascript) Parses the HTML content from the given string into an object tree representation.
-
Field Details
-
SVG_FACTORY
The SVG factory. -
ELEMENT_FACTORIES
-
-
Constructor Details
-
HtmlUnitNekoHtmlParser
public HtmlUnitNekoHtmlParser()Ctor.
-
-
Method Details
-
parseFragment
Parses the HTML content from the given string into an object tree representation.- Specified by:
parseFragment
in interfaceHTMLParser
- Parameters:
parent
- the parent for the new nodessource
- the (X)HTML to be parsed- Throws:
SAXException
- if a SAX error occursIOException
- if an IO error occurs
-
parseFragment
public void parseFragment(DomNode parent, DomNode context, String source, boolean createdByJavascript) throws SAXException, IOException Parses the HTML content from the given string into an object tree representation.- Specified by:
parseFragment
in interfaceHTMLParser
- Parameters:
parent
- where the new parsed nodes will be added tocontext
- the context to build the fragment context stacksource
- the (X)HTML to be parsedcreatedByJavascript
- if true the (script) tag was created by javascript- Throws:
SAXException
- if a SAX error occursIOException
- if an IO error occurs
-
parse
public void parse(WebResponse webResponse, HtmlPage page, boolean xhtml, boolean createdByJavascript) throws IOException Parses the WebResponse into an object tree representation.- Specified by:
parse
in interfaceHTMLParser
- Parameters:
webResponse
- the response datapage
- the HtmlPage to add the nodesxhtml
- if true use the XHtml parsercreatedByJavascript
- if true the (script) tag was created by javascript- Throws:
IOException
- if there is an IO error
-
extractNestedException
Extract nested exception within an XNIException (Nekohtml uses reflection and generated exceptions are wrapped many times within XNIException and InvocationTargetException)- Parameters:
e
- the original XNIException- Returns:
- the cause exception
-
getSvgFactory
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.- Specified by:
getSvgFactory
in interfaceHTMLParser
- Returns:
- a factory for creating SvgElements representing the given tag
-
getFactory
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.- Specified by:
getFactory
in interfaceHTMLParser
- Parameters:
tagName
- an HTML element tag name- Returns:
- a factory for creating HtmlElements representing the given tag
-
getElementFactory
public ElementFactory getElementFactory(SgmlPage page, String namespaceURI, String qualifiedName, boolean insideSvg, boolean svgSupport) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns the pre-registered element factory corresponding to the specified tag, or an UnknownElementFactory.- Specified by:
getElementFactory
in interfaceHTMLParser
- Parameters:
page
- the pagenamespaceURI
- the namespace URIqualifiedName
- the qualified nameinsideSvg
- is the node inside an SVG node or notsvgSupport
- true if called from javascript createElementNS- Returns:
- the pre-registered element factory corresponding to the specified tag, or an UnknownElementFactory
-