Search in sources :

Example 1 with ModelBuilderOperation

use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.

the class AttributesMatcherFactory method getQualifiedRefAttrPattern.

private static IEntity getQualifiedRefAttrPattern() {
    if (qualifiedRefAttrPattern == null) {
        ModelBuilderOperation mop = new ModelBuilderOperation();
        IXmlBuilder xb = (IXmlBuilder) mop.wGetBuilder(XmlLanguageKit.URI);
        ICommonsBuilder cb = (ICommonsBuilder) mop.wGetBuilder(CommonsLanguageKit.URI);
        xb.Attribute_();
        xb.QualifiedName_();
        cb.Variable_();
        cb.VarType("http://lang.whole.org/Xml#NameSpace");
        cb.VarName("xmlns");
        cb.Quantifier("!");
        cb._Variable();
        xb.Name("ref");
        xb._QualifiedName();
        cb.Variable_();
        cb.VarType("http://lang.whole.org/Xml#Value");
        cb.VarName("value");
        cb.Quantifier("!");
        cb._Variable();
        xb._Attribute();
        qualifiedRefAttrPattern = mop.wGetResult();
    }
    return qualifiedRefAttrPattern;
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IXmlBuilder(org.whole.lang.xml.builders.IXmlBuilder) ICommonsBuilder(org.whole.lang.commons.builders.ICommonsBuilder)

Example 2 with ModelBuilderOperation

use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.

the class AttributesMatcherFactory method getNsDeclPattern.

private static IEntity getNsDeclPattern() {
    if (nsDeclPattern == null) {
        ModelBuilderOperation mop = new ModelBuilderOperation();
        IXmlBuilder xb = (IXmlBuilder) mop.wGetBuilder(XmlLanguageKit.URI);
        ICommonsBuilder cb = (ICommonsBuilder) mop.wGetBuilder(CommonsLanguageKit.URI);
        xb.Attribute_();
        xb.QualifiedName_();
        xb.NameSpace("xmlns");
        cb.Variable_();
        cb.VarType(XmlEntityDescriptorEnum.Name);
        cb.VarName("xmlns");
        cb.Quantifier(QuantifierEnum.MANDATORY);
        cb._Variable();
        xb._QualifiedName();
        cb.Variable_();
        cb.VarType(XmlEntityDescriptorEnum.Value);
        cb.VarName("uri");
        cb.Quantifier(QuantifierEnum.MANDATORY);
        cb._Variable();
        xb._Attribute();
        nsDeclPattern = mop.wGetResult();
    }
    return nsDeclPattern;
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IXmlBuilder(org.whole.lang.xml.builders.IXmlBuilder) ICommonsBuilder(org.whole.lang.commons.builders.ICommonsBuilder)

Example 3 with ModelBuilderOperation

use of org.whole.lang.builders.ModelBuilderOperation 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 4 with ModelBuilderOperation

use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.

the class PersistenceTest method testXmlModel2Builder.

@Test
public void testXmlModel2Builder() throws ParserConfigurationException, SAXException, IOException {
    IEntity xmlModel = SaxConsumerHandler.parse(this.getClass().getResourceAsStream("persistenceTest.xwl"), "UTF-8", true);
    ModelBuilderOperation op = new ModelBuilderOperation();
    new XmlStoreConsumerVisitor(op).visit(xmlModel);
    PrettyPrinterOperation.prettyPrint(op.wGetResult());
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IEntity(org.whole.lang.model.IEntity) XmlStoreConsumerVisitor(org.whole.lang.xml.util.XmlStoreConsumerVisitor) Test(org.junit.Test)

Example 5 with ModelBuilderOperation

use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.

the class PersistenceTest method testSingleBuilder2Xml.

@Test
public void testSingleBuilder2Xml() {
    ModelBuilderOperation op = new ModelBuilderOperation();
    new ModelsModel().apply(new XmlStoreProducerBuilderOperation(op));
    IEntity xmlModel = op.wGetResult();
    PrettyPrinterOperation.prettyPrint(xmlModel);
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IEntity(org.whole.lang.model.IEntity) XmlStoreProducerBuilderOperation(org.whole.lang.xml.util.XmlStoreProducerBuilderOperation) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Test(org.junit.Test)

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