Search in sources :

Example 1 with TreeParser

use of nu.validator.saxtree.TreeParser in project validator by validator.

the class MessageEmitterAdapter method elaborateContentModelandContext.

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();
    }
}
Also used : TreeParser(nu.validator.saxtree.TreeParser) XhtmlSaxEmitter(nu.validator.xml.XhtmlSaxEmitter) DocumentFragment(nu.validator.saxtree.DocumentFragment) ContentHandler(org.xml.sax.ContentHandler)

Example 2 with TreeParser

use of nu.validator.saxtree.TreeParser in project validator by validator.

the class MessageEmitterAdapter method elaborateElementSpecificAttributes.

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();
        }
    }
}
Also used : TreeParser(nu.validator.saxtree.TreeParser) XhtmlSaxEmitter(nu.validator.xml.XhtmlSaxEmitter) ContentHandler(org.xml.sax.ContentHandler) DocumentFragment(nu.validator.saxtree.DocumentFragment)

Example 3 with TreeParser

use of nu.validator.saxtree.TreeParser in project validator by validator.

the class MessageEmitterAdapter method elaborateContentModel.

/**
 * @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();
    }
}
Also used : TreeParser(nu.validator.saxtree.TreeParser) XhtmlSaxEmitter(nu.validator.xml.XhtmlSaxEmitter) DocumentFragment(nu.validator.saxtree.DocumentFragment) ContentHandler(org.xml.sax.ContentHandler)

Example 4 with TreeParser

use of nu.validator.saxtree.TreeParser in project validator by validator.

the class MessageEmitterAdapter method elaborateDatatypes.

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();
    }
}
Also used : Html5DatatypeException(nu.validator.datatype.Html5DatatypeException) DatatypeException(org.relaxng.datatype.DatatypeException) Html5DatatypeException(nu.validator.datatype.Html5DatatypeException) TreeParser(nu.validator.saxtree.TreeParser) XhtmlSaxEmitter(nu.validator.xml.XhtmlSaxEmitter) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) DocumentFragment(nu.validator.saxtree.DocumentFragment) ContentHandler(org.xml.sax.ContentHandler) HashSet(java.util.HashSet)

Aggregations

DocumentFragment (nu.validator.saxtree.DocumentFragment)4 TreeParser (nu.validator.saxtree.TreeParser)4 XhtmlSaxEmitter (nu.validator.xml.XhtmlSaxEmitter)4 ContentHandler (org.xml.sax.ContentHandler)4 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Html5DatatypeException (nu.validator.datatype.Html5DatatypeException)1 DatatypeException (org.relaxng.datatype.DatatypeException)1