public void emptyElement(QName qName, XMLAttributes xmlAttributes, Augmentations augs) throws XNIException { startElementImpl(qName, xmlAttributes); }
protected DocumentHandler newDocumentHandler(String source) { return new DocumentHandler(source); }
@Override protected Document parseDomImpl(String source) throws GadgetException { DocumentHandler handler; HTMLConfiguration config = newConfiguration(); try { handler = parseHtmlImpl(source, config, new NormalizingTagBalancer()); } catch (IOException ioe) { return null; } Document document = handler.getDocument(); document.appendChild(DomUtil.getFirstNamedChildNode(handler.getFragment(), "html")); fixNekoWeirdness(document); return document; }
@Override protected DocumentFragment parseFragmentImpl(String source) throws GadgetException { DocumentHandler handler; HTMLConfiguration config = newConfiguration(); // http://cyberneko.org/html/features/balance-tags/document-fragment // deprecated http://cyberneko.org/html/features/document-fragment config.setFeature("http://cyberneko.org/html/features/balance-tags/document-fragment", true); config.setProperty("http://cyberneko.org/html/properties/balance-tags/fragment-context-stack", new QName[]{new QName(null, "HTML", "HTML", null), new QName(null, "BODY", "BODY", null)}); try { handler = parseHtmlImpl(source, config, new NekoPatchTagBalancer()); } catch (IOException ioe) { return null; } return handler.getFragment(); }
@Test public void scriptPushedToBody() throws Exception { String content = loadFile("org/apache/shindig/gadgets/parse/nekohtml/test-leadingscript.html"); String expected = loadFile("org/apache/shindig/gadgets/parse/nekohtml/test-leadingscript-expected.html"); parseAndCompareBalanced(content, expected, parser); }
@Override protected GadgetHtmlParser makeParser() { return new NekoSimplifiedHtmlParser( new ParseModule.DOMImplementationProvider().get()); }
@Override protected Document parseDomImpl(String source) throws GadgetException { DocumentHandler handler; HTMLConfiguration config = newConfiguration(); try { handler = parseHtmlImpl(source, config, new NormalizingTagBalancer()); } catch (IOException ioe) { return null; } Document document = handler.getDocument(); document.appendChild(DomUtil.getFirstNamedChildNode(handler.getFragment(), "html")); fixNekoWeirdness(document); return document; }
@Override protected DocumentFragment parseFragmentImpl(String source) throws GadgetException { DocumentHandler handler; HTMLConfiguration config = newConfiguration(); // http://cyberneko.org/html/features/balance-tags/document-fragment // deprecated http://cyberneko.org/html/features/document-fragment config.setFeature("http://cyberneko.org/html/features/balance-tags/document-fragment", true); config.setProperty("http://cyberneko.org/html/properties/balance-tags/fragment-context-stack", new QName[]{new QName(null, "HTML", "HTML", null), new QName(null, "BODY", "BODY", null)}); try { handler = parseHtmlImpl(source, config, new NekoPatchTagBalancer()); } catch (IOException ioe) { return null; } return handler.getFragment(); }
@Override @Test public void noBody() throws Exception { // Note that no doctype is injected for fragments String content = loadFile("org/apache/shindig/gadgets/parse/nekohtml/test-headnobody.html"); String expected = loadFile("org/apache/shindig/gadgets/parse/nekohtml/test-headnobody-expected.html"); parseAndCompareBalanced(content, expected, parser); }
public void emptyElement(QName qName, XMLAttributes xmlAttributes, Augmentations augs) throws XNIException { startElementImpl(qName, xmlAttributes); }
@Override protected GadgetHtmlParser makeParser() { return new NekoSimplifiedHtmlParser( new ParseModule.DOMImplementationProvider().get()); }
protected DocumentHandler newDocumentHandler(String source) { return new DocumentHandler(source); }
@Override protected Document parseDomImpl(String source) throws GadgetException { DocumentHandler handler; HTMLConfiguration config = newConfiguration(); try { handler = parseHtmlImpl(source, config, new NormalizingTagBalancer()); } catch (IOException ioe) { return null; } Document document = handler.getDocument(); document.appendChild(DomUtil.getFirstNamedChildNode(handler.getFragment(), "html")); fixNekoWeirdness(document); return document; }
@Override protected DocumentFragment parseFragmentImpl(String source) throws GadgetException { DocumentHandler handler; HTMLConfiguration config = newConfiguration(); // http://cyberneko.org/html/features/balance-tags/document-fragment // deprecated http://cyberneko.org/html/features/document-fragment config.setFeature("http://cyberneko.org/html/features/balance-tags/document-fragment", true); config.setProperty("http://cyberneko.org/html/properties/balance-tags/fragment-context-stack", new QName[]{new QName(null, "HTML", "HTML", null), new QName(null, "BODY", "BODY", null)}); try { handler = parseHtmlImpl(source, config, new NekoPatchTagBalancer()); } catch (IOException ioe) { return null; } return handler.getFragment(); }
@Override @Test public void notADocument() throws Exception { // Note that no doctype is injected for fragments String content = loadFile("org/apache/shindig/gadgets/parse/nekohtml/test-fragment.html"); String expected = loadFile("org/apache/shindig/gadgets/parse/nekohtml/test-fragment-expected.html"); parseAndCompareBalanced(content, expected, parser); }
public void emptyElement(QName qName, XMLAttributes xmlAttributes, Augmentations augs) throws XNIException { startElementImpl(qName, xmlAttributes); }
@Override protected GadgetHtmlParser makeParser() { return new NekoSimplifiedHtmlParser( new ParseModule.DOMImplementationProvider().get()); }
protected DocumentHandler newDocumentHandler(String source) { return new DocumentHandler(source); }
public void startElement(QName qName, XMLAttributes xmlAttributes, Augmentations augs) throws XNIException { Element element = startElementImpl(qName, xmlAttributes); // Not an empty element, so push on the stack elementStack.push(element); }
@Override protected GadgetHtmlParser makeParser() { return new NekoSimplifiedHtmlParser( new ParseModule.DOMImplementationProvider().get()); }