Search in sources :

Example 1 with SaxHandlerBuilderOperation

use of org.whole.lang.xml.util.SaxHandlerBuilderOperation in project whole by wholeplatform.

the class PersistenceTest method testSaxHandlerBuilder.

@Test
public void testSaxHandlerBuilder() throws Exception {
    Document xmlModel = (Document) XmlSourcePersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/xsd/util/javaee_web_services_client_1_2.xsd"));
    ModelBuilderOperation op = new ModelBuilderOperation();
    SaxConsumerHandler saxHandler = new SaxConsumerHandler(op, !EntityUtils.isResolver(xmlModel.getProlog().getXmlDecl()));
    SaxHandlerBuilderOperation sbop = new SaxHandlerBuilderOperation(saxHandler, saxHandler);
    new ModelTemplate(xmlModel).apply(sbop);
    assertTrue(Matcher.match(op.wGetResult(), xmlModel));
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) ModelTemplate(org.whole.lang.templates.ModelTemplate) SaxConsumerHandler(org.whole.lang.xml.util.SaxConsumerHandler) SaxHandlerBuilderOperation(org.whole.lang.xml.util.SaxHandlerBuilderOperation) Document(org.whole.lang.xml.model.Document) Test(org.junit.Test)

Example 2 with SaxHandlerBuilderOperation

use of org.whole.lang.xml.util.SaxHandlerBuilderOperation in project whole by wholeplatform.

the class HtmlPrettyPrinterVisitor method visit.

public void visit(IEntity entity) {
    IEntity xhtmlDocument = BehaviorUtils.apply("whole:org.whole.lang.html:HTML5Semantics#toXHtml", entity);
    HtmlSerializer serializer = new HtmlSerializer(out.asWriter());
    SaxHandlerBuilderOperation sbop = new SaxHandlerBuilderOperation(serializer, serializer, "http://www.w3.org/1999/xhtml");
    if (xhtmlDocument != null)
        new ModelTemplate(xhtmlDocument).apply(sbop);
}
Also used : ModelTemplate(org.whole.lang.templates.ModelTemplate) IEntity(org.whole.lang.model.IEntity) HtmlSerializer(nu.validator.htmlparser.sax.HtmlSerializer) SaxHandlerBuilderOperation(org.whole.lang.xml.util.SaxHandlerBuilderOperation)

Aggregations

ModelTemplate (org.whole.lang.templates.ModelTemplate)2 SaxHandlerBuilderOperation (org.whole.lang.xml.util.SaxHandlerBuilderOperation)2 HtmlSerializer (nu.validator.htmlparser.sax.HtmlSerializer)1 Test (org.junit.Test)1 ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)1 IEntity (org.whole.lang.model.IEntity)1 Document (org.whole.lang.xml.model.Document)1 SaxConsumerHandler (org.whole.lang.xml.util.SaxConsumerHandler)1