use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class PersistenceTest method xmlRoundtrip.
private IEntity xmlRoundtrip(IEntity model1) {
ModelBuilderOperation op = new ModelBuilderOperation();
XmlStoreProducerBuilderOperation xmlOp = new XmlStoreProducerBuilderOperation(op);
((XmlStoreProducerBuilder) xmlOp.wGetBuilder()).buildStartDocument();
new ModelTemplate(model1).apply(xmlOp);
((XmlStoreProducerBuilder) xmlOp.wGetBuilder()).buildEndDocument();
IEntity xmlModel = op.wGetResult();
op = new ModelBuilderOperation();
new XmlStoreConsumerVisitor(op).visit(xmlModel);
IEntity model2 = op.wGetResult();
return model2;
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class GrammarsUtils method parse.
@SuppressWarnings("unchecked")
public static <E extends IEntity> E parse(CharSequence source, String grammarUri) {
ModelBuilderOperation mop = new ModelBuilderOperation();
parse(source, grammarUri, mop);
return (E) mop.wGetResult();
}
use of org.whole.lang.builders.ModelBuilderOperation 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);
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class AbstractXsiPersistenceKit method doReadModel.
@Override
protected IEntity doReadModel(IPersistenceProvider pp) throws Exception {
IBindingManager bm = pp.getBindings();
ModelBuilderOperation mop = new ModelBuilderOperation(RegistryConfigurations.RESOLVER);
IBuilderOperation xsiBuilderOperation = getBuilderOperation(mop, bm);
bm.wDefValue("mergeCDataSect", true);
XmlNormalizerBuilderOperation normalizerOp = new XmlNormalizerBuilderOperation(xsiBuilderOperation, bm);
SaxConsumerHandler.parse(pp.getInputStream(), pp.getEncoding(), normalizerOp);
return mop.wGetResult();
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class SaxConsumerHandler method parse.
public static IEntity parse(InputSource inputSource, boolean produceXmlDecl) throws ParserConfigurationException, SAXException, IOException {
ModelBuilderOperation op = new ModelBuilderOperation();
parse(inputSource, produceXmlDecl, op);
return op.wGetResult();
}
Aggregations