flushTextBuffer(); appendChild(element); return element;
public void comment(XMLString text, Augmentations augs) throws XNIException { flushTextBuffer(); // Add comments as comment nodes - needed to support sanitization // of SocialMarkup-parsed content Node comment = getDocument().createComment(new String(text.ch, text.offset, text.length)); appendChild(comment); }
public void startGeneralEntity(String name, XMLResourceIdentifier id, String encoding, Augmentations augs) throws XNIException { if (name.startsWith("#")) { try { boolean hex = name.startsWith("#x"); int offset = hex ? 2 : 1; int base = hex ? 16 : 10; int value = Integer.parseInt(name.substring(offset), base); String entity = HTMLEntities.get(value); if (entity != null) { name = entity; } } catch (NumberFormatException e) { // ignore } } printEntity(name); inEntity = true; }
flushTextBuffer(); appendChild(element); return element;
flushTextBuffer(); appendChild(element); return element;
public void startGeneralEntity(String name, XMLResourceIdentifier id, String encoding, Augmentations augs) throws XNIException { if (name.startsWith("#")) { try { boolean hex = name.startsWith("#x"); int offset = hex ? 2 : 1; int base = hex ? 16 : 10; int value = Integer.parseInt(name.substring(offset), base); String entity = HTMLEntities.get(value); if (entity != null) { name = entity; } } catch (NumberFormatException e) { // ignore } } printEntity(name); inEntity = true; }
public void startGeneralEntity(String name, XMLResourceIdentifier id, String encoding, Augmentations augs) throws XNIException { if (name.startsWith("#")) { try { boolean hex = name.startsWith("#x"); int offset = hex ? 2 : 1; int base = hex ? 16 : 10; int value = Integer.parseInt(name.substring(offset), base); String entity = HTMLEntities.get(value); if (entity != null) { name = entity; } } catch (NumberFormatException e) { // ignore } } printEntity(name); inEntity = true; }
@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 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 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 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; }
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; }
public void emptyElement(QName qName, XMLAttributes xmlAttributes, Augmentations augs) throws XNIException { startElementImpl(qName, xmlAttributes); }
public void endDocument(Augmentations augs) throws XNIException { flushTextBuffer(); elementStack.pop(); }
public void emptyElement(QName qName, XMLAttributes xmlAttributes, Augmentations augs) throws XNIException { startElementImpl(qName, xmlAttributes); }
public void endElement(QName qName, Augmentations augs) throws XNIException { flushTextBuffer(); elementStack.pop(); }
public void endElement(QName qName, Augmentations augs) throws XNIException { flushTextBuffer(); elementStack.pop(); }
public void endDocument(Augmentations augs) throws XNIException { flushTextBuffer(); elementStack.pop(); }
public void endDocument(Augmentations augs) throws XNIException { flushTextBuffer(); elementStack.pop(); }