Search in sources :

Example 6 with ModelBuilderOperation

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;
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) ModelTemplate(org.whole.lang.templates.ModelTemplate) XmlStoreProducerBuilder(org.whole.lang.xml.util.XmlStoreProducerBuilder) IEntity(org.whole.lang.model.IEntity) XmlStoreProducerBuilderOperation(org.whole.lang.xml.util.XmlStoreProducerBuilderOperation) XmlStoreConsumerVisitor(org.whole.lang.xml.util.XmlStoreConsumerVisitor)

Example 7 with ModelBuilderOperation

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();
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation)

Example 8 with ModelBuilderOperation

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);
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) HtmlParser(nu.validator.htmlparser.sax.HtmlParser) InputSource(org.xml.sax.InputSource) SaxConsumerHandler(org.whole.lang.xml.util.SaxConsumerHandler) IEntity(org.whole.lang.model.IEntity)

Example 9 with ModelBuilderOperation

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();
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IBuilderOperation(org.whole.lang.builders.IBuilderOperation) XmlNormalizerBuilderOperation(org.whole.lang.xml.codebase.XmlNormalizerBuilderOperation) IBindingManager(org.whole.lang.bindings.IBindingManager)

Example 10 with ModelBuilderOperation

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();
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation)

Aggregations

ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)41 IEntity (org.whole.lang.model.IEntity)21 Test (org.junit.Test)18 ICommonsBuilder (org.whole.lang.commons.builders.ICommonsBuilder)8 File (java.io.File)6 ModelTemplate (org.whole.lang.templates.ModelTemplate)6 XmlNormalizerBuilderOperation (org.whole.lang.xml.codebase.XmlNormalizerBuilderOperation)6 ResourceTemplate (org.whole.lang.artifacts.templates.ResourceTemplate)5 IBindingManager (org.whole.lang.bindings.IBindingManager)5 IXmlBuilder (org.whole.lang.xml.builders.IXmlBuilder)5 IArtifactsBuilder (org.whole.lang.artifacts.builders.IArtifactsBuilder)4 StreamPersistenceProvider (org.whole.lang.codebase.StreamPersistenceProvider)4 Document (org.whole.lang.xml.model.Document)4 XmlStoreProducerBuilderOperation (org.whole.lang.xml.util.XmlStoreProducerBuilderOperation)4 XmlStoreConsumerVisitor (org.whole.lang.xml.util.XmlStoreConsumerVisitor)3 Category (org.junit.experimental.categories.Category)2 WorkspaceTemplate (org.whole.lang.artifacts.templates.WorkspaceTemplate)2 IBuilderOperation (org.whole.lang.builders.IBuilderOperation)2 JavaStoreProducerBuilder (org.whole.lang.java.util.JavaStoreProducerBuilder)2 JavaStoreProducerBuilderOperation (org.whole.lang.java.util.JavaStoreProducerBuilderOperation)2