use of org.whole.lang.xml.util.SaxConsumerHandler 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));
}
use of org.whole.lang.xml.util.SaxConsumerHandler in project whole by wholeplatform.
the class HtmlPersistenceKit method doReadModel.
protected IEntity doReadModel(IPersistenceProvider pp) throws Exception {
ModelBuilderOperation op = new ModelBuilderOperation();
SaxConsumerHandler saxHandler = new SaxConsumerHandler(op, false);
HtmlParser parser = new HtmlParser(XmlViolationPolicy.ALLOW);
parser.setContentHandler(saxHandler);
parser.setProperty("http://xml.org/sax/properties/lexical-handler", saxHandler);
parser.parse(new InputSource(pp.getInputStream()));
IEntity xhtmlDocument = NormalizerOperation.normalize(op.wGetResult());
return BehaviorUtils.apply("whole:org.whole.lang.html:HTML5Semantics#toHtml", xhtmlDocument);
}
Aggregations