Search in sources :

Example 1 with IXmlBuilder

use of org.whole.lang.xml.builders.IXmlBuilder 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 IXmlBuilder

use of org.whole.lang.xml.builders.IXmlBuilder 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 IXmlBuilder

use of org.whole.lang.xml.builders.IXmlBuilder in project whole by wholeplatform.

the class XsdModelBuilderTest method testBuilderAPI.

@Category(KnownFailingTests.class)
@Test
public void testBuilderAPI() throws Exception {
    Schema xsdFromInputStream = (Schema) XsdPersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream("datatypes.xsd")));
    Document document = (Document) XmlSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream("datatypes.xsd")));
    IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
    bm.wDefValue("mergeCDataSect", true);
    XsdDeployStrategies.setDeployStrategy(bm, XsdDeployStrategies.ALL);
    ModelBuilderOperation mop = new ModelBuilderOperation();
    IBuilderOperation xsdBuilderOperation = new XmlSpecific2XsdBuilderAdapterOperation(mop, bm);
    XmlNormalizerBuilderOperation normalizerOp = new XmlNormalizerBuilderOperation(xsdBuilderOperation, bm);
    ModelTemplate template = new ModelTemplate(document);
    template.apply(new XmlGenericBuilderAdapter((IXmlBuilder) normalizerOp.wGetBuilder(XmlLanguageKit.URI)));
    Schema xsdFromXmlModel = (Schema) mop.wGetResult();
    Assert.assertTrue(Matcher.match(xsdFromInputStream, xsdFromXmlModel));
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) ModelTemplate(org.whole.lang.templates.ModelTemplate) IBuilderOperation(org.whole.lang.builders.IBuilderOperation) XmlNormalizerBuilderOperation(org.whole.lang.xml.codebase.XmlNormalizerBuilderOperation) XmlGenericBuilderAdapter(org.whole.lang.xml.builders.XmlGenericBuilderAdapter) Schema(org.whole.lang.xsd.model.Schema) IBindingManager(org.whole.lang.bindings.IBindingManager) IXmlBuilder(org.whole.lang.xml.builders.IXmlBuilder) StreamPersistenceProvider(org.whole.lang.codebase.StreamPersistenceProvider) Document(org.whole.lang.xml.model.Document) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 4 with IXmlBuilder

use of org.whole.lang.xml.builders.IXmlBuilder in project whole by wholeplatform.

the class AttributesMatcherFactory method getDefaultNsDeclPattern.

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

Example 5 with IXmlBuilder

use of org.whole.lang.xml.builders.IXmlBuilder in project whole by wholeplatform.

the class AttributesMatcherFactory method getRefAttrPattern.

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

Aggregations

IXmlBuilder (org.whole.lang.xml.builders.IXmlBuilder)8 ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)5 ICommonsBuilder (org.whole.lang.commons.builders.ICommonsBuilder)5 XmlGenericBuilderAdapter (org.whole.lang.xml.builders.XmlGenericBuilderAdapter)2 Test (org.junit.Test)1 Category (org.junit.experimental.categories.Category)1 IBindingManager (org.whole.lang.bindings.IBindingManager)1 IBuilder (org.whole.lang.builders.IBuilder)1 IBuilderFactory (org.whole.lang.builders.IBuilderFactory)1 IBuilderOperation (org.whole.lang.builders.IBuilderOperation)1 StreamPersistenceProvider (org.whole.lang.codebase.StreamPersistenceProvider)1 IEntityContext (org.whole.lang.contexts.IEntityContext)1 IOperation (org.whole.lang.operations.IOperation)1 PrettyPrinterOperation (org.whole.lang.operations.PrettyPrinterOperation)1 ModelTemplate (org.whole.lang.templates.ModelTemplate)1 IVisitor (org.whole.lang.visitors.IVisitor)1 IVisitorFactory (org.whole.lang.visitors.IVisitorFactory)1 XmlSpecificBuilderAdapter (org.whole.lang.xml.builders.XmlSpecificBuilderAdapter)1 XmlNormalizerBuilderOperation (org.whole.lang.xml.codebase.XmlNormalizerBuilderOperation)1 Document (org.whole.lang.xml.model.Document)1