private void elaborateDatatypes(Map<String, DatatypeException> map) throws SAXException { Set<DocumentFragment> fragments = new HashSet<>(); for (Map.Entry<String, DatatypeException> entry : map.entrySet()) { DatatypeException ex = entry.getValue(); if (ex instanceof Html5DatatypeException) { Html5DatatypeException ex5 = (Html5DatatypeException) ex; DocumentFragment fragment = HTML5_DATATYPE_ADVICE.get(ex5.getDatatypeClass()); if (fragment != null) { fragments.add(fragment); } } } if (!fragments.isEmpty()) { ContentHandler ch = emitter.startElaboration(); if (ch != null) { TreeParser treeParser = new TreeParser(ch, null); XhtmlSaxEmitter xhtmlSaxEmitter = new XhtmlSaxEmitter(ch); xhtmlSaxEmitter.startElement("dl"); for (DocumentFragment fragment : fragments) { treeParser.parse(fragment); } xhtmlSaxEmitter.endElement("dl"); } emitter.endElaboration(); } }
/** * Parses a fragment. * * @param input the input to parse * @param contextLocal the local name of the context element * @param contextNamespace the namespace of the context element * @throws IOException * @throws SAXException */ public void parseFragment(InputSource input, String contextLocal, String contextNamespace) throws IOException, SAXException { lazyInit(); try { treeBuilder.setFragmentContext(contextLocal.intern(), contextNamespace.intern(), null, false); tokenize(input); } finally { if (saxTreeBuilder != null) { DocumentFragment fragment = saxTreeBuilder.getDocumentFragment(); new TreeParser(contentHandler, lexicalHandler).parse(fragment); } } }
/** * Parses a fragment. * * @param input the input to parse * @param contextLocal the local name of the context element * @param contextNamespace the namespace of the context element * @throws IOException * @throws SAXException */ public void parseFragment(InputSource input, String contextLocal, String contextNamespace) throws IOException, SAXException { lazyInit(); try { treeBuilder.setFragmentContext(contextLocal.intern(), contextNamespace.intern(), null, false); tokenize(input); } finally { if (saxTreeBuilder != null) { DocumentFragment fragment = saxTreeBuilder.getDocumentFragment(); new TreeParser(contentHandler, lexicalHandler).parse(fragment); } } }
/** * Parses a fragment with HTML context. * * @param input the input to parse * @param context the name of the context element (HTML namespace assumed) * @throws IOException * @throws SAXException */ public void parseFragment(InputSource input, String context) throws IOException, SAXException { lazyInit(); try { treeBuilder.setFragmentContext(context.intern()); tokenize(input); } finally { if (saxTreeBuilder != null) { DocumentFragment fragment = saxTreeBuilder.getDocumentFragment(); new TreeParser(contentHandler, lexicalHandler).parse(fragment); } } }
/** * Parses a fragment with HTML context. * * @param input the input to parse * @param context the name of the context element (HTML namespace assumed) * @throws IOException * @throws SAXException */ public void parseFragment(InputSource input, String context) throws IOException, SAXException { lazyInit(); try { treeBuilder.setFragmentContext(context.intern()); tokenize(input); } finally { if (saxTreeBuilder != null) { DocumentFragment fragment = saxTreeBuilder.getDocumentFragment(); new TreeParser(contentHandler, lexicalHandler).parse(fragment); } } }
/** * Parses a fragment. * * @param input the input to parse * @param context the name of the context element * @throws IOException * @throws SAXException */ public void parseFragment(InputSource input, String context) throws IOException, SAXException { lazyInit(); try { treeBuilder.setFragmentContext(context.intern()); tokenize(input); } finally { if (saxTreeBuilder != null) { DocumentFragment fragment = saxTreeBuilder.getDocumentFragment(); new TreeParser(contentHandler, lexicalHandler).parse(fragment); } } }
/** * @see nu.validator.messages.MessageEmitter#startImageReview(DocumentFragment, boolean) */ @Override public ImageReviewHandler startImageReview(DocumentFragment instruction, boolean fatal) throws SAXException { attrs.clear(); attrs.addAttribute("id", "imagereport"); this.emitter.startElement("h2", attrs); this.emitter.characters(IMAGE_REPORT); this.emitter.endElement("h2"); if (instruction != null) { treeParser.parse(instruction); } return this; }
/** * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource) */ public void parse(InputSource input) throws IOException, SAXException { lazyInit(); try { treeBuilder.setFragmentContext(null); tokenize(input); } finally { if (saxTreeBuilder != null) { Document document = saxTreeBuilder.getDocument(); if (document != null) { new TreeParser(contentHandler, lexicalHandler).parse(document); } } } }
/** * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource) */ public void parse(InputSource input) throws IOException, SAXException { lazyInit(); try { treeBuilder.setFragmentContext(null); tokenize(input); } finally { if (saxTreeBuilder != null) { Document document = saxTreeBuilder.getDocument(); if (document != null) { new TreeParser(contentHandler, lexicalHandler).parse(document); } } } }
/** * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource) */ public void parse(InputSource input) throws IOException, SAXException { lazyInit(); try { treeBuilder.setFragmentContext(null); tokenize(input); } finally { if (saxTreeBuilder != null) { Document document = saxTreeBuilder.getDocument(); if (document != null) { new TreeParser(contentHandler, lexicalHandler).parse(document); } } } }
private void elaborateContentModelandContext(Name parent, Name child) throws SAXException { DocumentFragment contentModelDds = spec.contentModelDescription(parent); DocumentFragment contextDds = spec.contextDescription(child); if (contentModelDds != null || contextDds != null) { ContentHandler ch = emitter.startElaboration(); if (ch != null) { TreeParser treeParser = new TreeParser(ch, null); XhtmlSaxEmitter xhtmlSaxEmitter = new XhtmlSaxEmitter(ch); xhtmlSaxEmitter.startElement("dl"); if (contextDds != null) { emitContextDt(xhtmlSaxEmitter, child); treeParser.parse(contextDds); } if (contentModelDds != null) { emitContentModelDt(xhtmlSaxEmitter, parent); treeParser.parse(contentModelDds); } xhtmlSaxEmitter.endElement("dl"); } emitter.endElaboration(); } }
/** * @param elt * @throws SAXException */ private void elaborateContentModel(Name elt) throws SAXException { DocumentFragment dds = spec.contentModelDescription(elt); if (dds != null) { ContentHandler ch = emitter.startElaboration(); if (ch != null) { TreeParser treeParser = new TreeParser(ch, null); XhtmlSaxEmitter xhtmlSaxEmitter = new XhtmlSaxEmitter(ch); xhtmlSaxEmitter.startElement("dl"); emitContentModelDt(xhtmlSaxEmitter, elt); treeParser.parse(dds); xhtmlSaxEmitter.endElement("dl"); } emitter.endElaboration(); } }
private void elaborateElementSpecificAttributes(Name elt, Name attribute) throws SAXException { if ("input".equals(elt.getLocalName())) { ContentHandler ch = emitter.startElaboration(); if (ch != null) { XhtmlSaxEmitter xhtmlSaxEmitter = new XhtmlSaxEmitter(ch); elaborateInputAttributes(xhtmlSaxEmitter, elt, attribute); } emitter.endElaboration(); } else { DocumentFragment dds = spec.elementSpecificAttributesDescription(elt); if (dds != null) { ContentHandler ch = emitter.startElaboration(); if (ch != null) { TreeParser treeParser = new TreeParser(ch, null); XhtmlSaxEmitter xhtmlSaxEmitter = new XhtmlSaxEmitter(ch); xhtmlSaxEmitter.startElement("dl"); emitElementSpecificAttributesDt(xhtmlSaxEmitter, elt); treeParser.parse(dds); xhtmlSaxEmitter.endElement("dl"); } emitter.endElaboration(); } } }
this.emitter.endElement("h3"); treeParser.parse(instruction);