File tree Expand file tree Collapse file tree
src/main/java/org/htmlunit/cyberneko/parsers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020import java .io .Reader ;
2121
2222import org .htmlunit .cyberneko .HTMLConfiguration ;
23+ import org .htmlunit .cyberneko .HTMLElementsProvider ;
2324import org .htmlunit .cyberneko .xerces .parsers .Constants ;
2425import org .htmlunit .cyberneko .xerces .util .ErrorHandlerWrapper ;
2526import org .htmlunit .cyberneko .xerces .util .XMLChar ;
@@ -94,6 +95,18 @@ public DOMFragmentParser() {
9495 parserConfiguration_ .setDocumentHandler (this );
9596 }
9697
98+ /**
99+ * Ctor using a custom {@link HTMLElementsProvider}
100+ * @param htmlElementsProvider the custom {@link HTMLElementsProvider}
101+ */
102+ public DOMFragmentParser (final HTMLElementsProvider htmlElementsProvider ) {
103+ parserConfiguration_ = new HTMLConfiguration (htmlElementsProvider );
104+ parserConfiguration_ .addRecognizedFeatures (RECOGNIZED_FEATURES );
105+ parserConfiguration_ .addRecognizedProperties (RECOGNIZED_PROPERTIES );
106+ parserConfiguration_ .setFeature ("http://cyberneko.org/html/features/balance-tags/document-fragment" , true );
107+ parserConfiguration_ .setDocumentHandler (this );
108+ }
109+
97110 /**
98111 * Parses a document fragment.
99112 *
Original file line number Diff line number Diff line change 1616package org .htmlunit .cyberneko .parsers ;
1717
1818import org .htmlunit .cyberneko .HTMLConfiguration ;
19+ import org .htmlunit .cyberneko .HTMLElementsProvider ;
1920import org .htmlunit .cyberneko .xerces .dom .DocumentImpl ;
2021import org .htmlunit .cyberneko .xerces .parsers .AbstractDOMParser ;
2122
2223/**
2324 * A DOM parser for HTML documents.
2425 *
2526 * @author Andy Clark
27+ * @author Ronald Brill
2628 */
2729public class DOMParser extends AbstractDOMParser {
2830
2931 /** Default constructor. */
3032 public DOMParser (final Class <? extends DocumentImpl > documentClass ) {
3133 super (new HTMLConfiguration (), documentClass );
3234 }
35+
36+ /**
37+ * Ctor using a custom {@link HTMLElementsProvider}
38+ * @param htmlElementsProvider the custom {@link HTMLElementsProvider}
39+ * @param documentClass the {@link DocumentImpl} to be used
40+ */
41+ public DOMParser (final HTMLElementsProvider htmlElementsProvider , final Class <? extends DocumentImpl > documentClass ) {
42+ super (new HTMLConfiguration (htmlElementsProvider ), documentClass );
43+ }
3344}
Original file line number Diff line number Diff line change 1616package org .htmlunit .cyberneko .parsers ;
1717
1818import org .htmlunit .cyberneko .HTMLConfiguration ;
19+ import org .htmlunit .cyberneko .HTMLElementsProvider ;
1920import org .htmlunit .cyberneko .xerces .parsers .AbstractSAXParser ;
2021
2122/**
2223 * A SAX parser for HTML documents.
2324 *
2425 * @author Andy Clark
26+ * @author Ronald Brill
2527 */
2628public class SAXParser extends AbstractSAXParser {
2729
2830 /** Default constructor. */
2931 public SAXParser () {
3032 super (new HTMLConfiguration ());
3133 }
34+
35+ /**
36+ * Ctor using a custom {@link HTMLElementsProvider}
37+ * @param htmlElementsProvider the custom {@link HTMLElementsProvider}
38+ */
39+ public SAXParser (final HTMLElementsProvider htmlElementsProvider ) {
40+ super (new HTMLConfiguration (htmlElementsProvider ));
41+ }
3242}
You can’t perform that action at this time.
0 commit comments