Search in sources :

Example 1 with XSModelGroupDecl

use of com.sun.xml.xsom.XSModelGroupDecl in project atlasmap by atlasmap.

the class SchemaTreeTraverser method schema.

/* (non-Javadoc)
     * @see com.sun.xml.xsom.visitor.XSVisitor#schema(com.sun.xml.xsom.XSSchema)
     */
public void schema(XSSchema s) {
    // QUICK HACK: don't print the built-in components
    if (s.getTargetNamespace().equals(Const.schemaNamespace)) {
        return;
    }
    SchemaTreeNode newNode = new SchemaTreeNode("Schema " + s.getLocator().getSystemId(), s.getLocator());
    this.currNode = newNode;
    this.model.addSchemaNode(newNode);
    for (XSAttGroupDecl groupDecl : s.getAttGroupDecls().values()) {
        attGroupDecl(groupDecl);
    }
    for (XSAttributeDecl attrDecl : s.getAttributeDecls().values()) {
        attributeDecl(attrDecl);
    }
    for (XSComplexType complexType : s.getComplexTypes().values()) {
        complexType(complexType);
    }
    for (XSElementDecl elementDecl : s.getElementDecls().values()) {
        elementDecl(elementDecl);
    }
    for (XSModelGroupDecl modelGroupDecl : s.getModelGroupDecls().values()) {
        modelGroupDecl(modelGroupDecl);
    }
    for (XSSimpleType simpleType : s.getSimpleTypes().values()) {
        simpleType(simpleType);
    }
}
Also used : XSAttGroupDecl(com.sun.xml.xsom.XSAttGroupDecl) XSSimpleType(com.sun.xml.xsom.XSSimpleType) XSComplexType(com.sun.xml.xsom.XSComplexType) XSModelGroupDecl(com.sun.xml.xsom.XSModelGroupDecl) XSAttributeDecl(com.sun.xml.xsom.XSAttributeDecl) XSElementDecl(com.sun.xml.xsom.XSElementDecl)

Example 2 with XSModelGroupDecl

use of com.sun.xml.xsom.XSModelGroupDecl in project atlasmap by atlasmap.

the class redefine method action1.

private void action1() throws SAXException {
    XSModelGroupDecl oldGrp = $runtime.currentSchema.getModelGroupDecl(newGrp.getName());
    if (oldGrp == null) {
        $runtime.reportError(Messages.format(Messages.ERR_UNDEFINED_MODELGROUP, newGrp.getName()));
    } else {
        newGrp.redefine((ModelGroupDeclImpl) oldGrp);
        $runtime.currentSchema.addModelGroupDecl(newGrp, true);
    }
}
Also used : XSModelGroupDecl(com.sun.xml.xsom.XSModelGroupDecl)

Example 3 with XSModelGroupDecl

use of com.sun.xml.xsom.XSModelGroupDecl in project atlasmap by atlasmap.

the class SchemaWriter method particle.

public void particle(XSParticle part) {
    BigInteger i;
    StringBuilder buf = new StringBuilder();
    i = part.getMaxOccurs();
    if (i.equals(BigInteger.valueOf(XSParticle.UNBOUNDED)))
        buf.append(" maxOccurs=\"unbounded\"");
    else if (!i.equals(BigInteger.ONE))
        buf.append(" maxOccurs=\"").append(i).append('\"');
    i = part.getMinOccurs();
    if (!i.equals(BigInteger.ONE))
        buf.append(" minOccurs=\"").append(i).append('\"');
    final String extraAtts = buf.toString();
    part.getTerm().visit(new XSTermVisitor() {

        public void elementDecl(XSElementDecl decl) {
            if (decl.isLocal())
                SchemaWriter.this.elementDecl(decl, extraAtts);
            else {
                // reference
                println(MessageFormat.format("<element ref=\"'{'{0}'}'{1}\"{2}/>", decl.getTargetNamespace(), decl.getName(), extraAtts));
            }
        }

        public void modelGroupDecl(XSModelGroupDecl decl) {
            // reference
            println(MessageFormat.format("<group ref=\"'{'{0}'}'{1}\"{2}/>", decl.getTargetNamespace(), decl.getName(), extraAtts));
        }

        public void modelGroup(XSModelGroup group) {
            SchemaWriter.this.modelGroup(group, extraAtts);
        }

        public void wildcard(XSWildcard wc) {
            SchemaWriter.this.wildcard("any", wc, extraAtts);
        }
    });
}
Also used : XSModelGroupDecl(com.sun.xml.xsom.XSModelGroupDecl) BigInteger(java.math.BigInteger) XSElementDecl(com.sun.xml.xsom.XSElementDecl) XSWildcard(com.sun.xml.xsom.XSWildcard) XSTermVisitor(com.sun.xml.xsom.visitor.XSTermVisitor) XSModelGroup(com.sun.xml.xsom.XSModelGroup)

Example 4 with XSModelGroupDecl

use of com.sun.xml.xsom.XSModelGroupDecl in project BIMserver by opensourceBIM.

the class XSDSchemaReader method start.

@SuppressWarnings("deprecation")
private void start() {
    ePackage = ecoreFactory.createEPackage();
    ePackage.setName("ifc2x3");
    ePackage.setNsPrefix("iai");
    ePackage.setNsURI("http:///buildingsmart.ifc.ecore");
    XSOMParser parser = new XSOMParser();
    try {
        parser.parse(getClass().getResource("IFC2X3.xsd"));
        XSSchemaSet schemas = parser.getResult();
        for (XSSchema schema : schemas.getSchemas()) {
            if (schema.getTargetNamespace().equals("http://www.iai-tech.org/ifcXML/IFC2x3/FINAL")) {
                for (XSComplexType type : schema.getComplexTypes().values()) {
                    createComplexType(type);
                }
                for (XSSimpleType simpleType : schema.getSimpleTypes().values()) {
                    createSimpleType(simpleType);
                }
            }
        }
        for (XSSchema schema : schemas.getSchemas()) {
            if (schema.getTargetNamespace().equals("http://www.iai-tech.org/ifcXML/IFC2x3/FINAL")) {
                for (XSComplexType type : schema.getComplexTypes().values()) {
                    fillComplexType(type);
                }
                for (XSModelGroupDecl modelGroupDecl : schema.getModelGroupDecls().values()) {
                    createGroup(modelGroupDecl);
                }
            }
        }
        writeEMF("test.ecore");
    } catch (SAXException e) {
        e.printStackTrace();
    }
}
Also used : XSOMParser(com.sun.xml.xsom.parser.XSOMParser) XSSimpleType(com.sun.xml.xsom.XSSimpleType) XSComplexType(com.sun.xml.xsom.XSComplexType) XSModelGroupDecl(com.sun.xml.xsom.XSModelGroupDecl) XSSchemaSet(com.sun.xml.xsom.XSSchemaSet) XSSchema(com.sun.xml.xsom.XSSchema) SAXException(org.xml.sax.SAXException)

Example 5 with XSModelGroupDecl

use of com.sun.xml.xsom.XSModelGroupDecl in project atlasmap by atlasmap.

the class SchemaWriter method schema.

public void schema(XSSchema s) {
    // QUICK HACK: don't print the built-in components
    if (s.getTargetNamespace().equals(Const.schemaNamespace))
        return;
    println(MessageFormat.format("<schema targetNamespace=\"{0}\">", s.getTargetNamespace()));
    indent++;
    Iterator itr;
    itr = s.iterateAttGroupDecls();
    while (itr.hasNext()) attGroupDecl((XSAttGroupDecl) itr.next());
    itr = s.iterateAttributeDecls();
    while (itr.hasNext()) attributeDecl((XSAttributeDecl) itr.next());
    itr = s.iterateComplexTypes();
    while (itr.hasNext()) complexType((XSComplexType) itr.next());
    itr = s.iterateElementDecls();
    while (itr.hasNext()) elementDecl((XSElementDecl) itr.next());
    itr = s.iterateModelGroupDecls();
    while (itr.hasNext()) modelGroupDecl((XSModelGroupDecl) itr.next());
    itr = s.iterateSimpleTypes();
    while (itr.hasNext()) simpleType((XSSimpleType) itr.next());
    indent--;
    println("</schema>");
}
Also used : XSAttGroupDecl(com.sun.xml.xsom.XSAttGroupDecl) XSSimpleType(com.sun.xml.xsom.XSSimpleType) XSComplexType(com.sun.xml.xsom.XSComplexType) XSModelGroupDecl(com.sun.xml.xsom.XSModelGroupDecl) XSAttributeDecl(com.sun.xml.xsom.XSAttributeDecl) Iterator(java.util.Iterator) XSElementDecl(com.sun.xml.xsom.XSElementDecl)

Aggregations

XSModelGroupDecl (com.sun.xml.xsom.XSModelGroupDecl)6 XSElementDecl (com.sun.xml.xsom.XSElementDecl)4 XSComplexType (com.sun.xml.xsom.XSComplexType)3 XSSimpleType (com.sun.xml.xsom.XSSimpleType)3 XSAttGroupDecl (com.sun.xml.xsom.XSAttGroupDecl)2 XSAttributeDecl (com.sun.xml.xsom.XSAttributeDecl)2 XSModelGroup (com.sun.xml.xsom.XSModelGroup)2 XSWildcard (com.sun.xml.xsom.XSWildcard)2 XSTermVisitor (com.sun.xml.xsom.visitor.XSTermVisitor)2 BigInteger (java.math.BigInteger)2 XSSchema (com.sun.xml.xsom.XSSchema)1 XSSchemaSet (com.sun.xml.xsom.XSSchemaSet)1 XSOMParser (com.sun.xml.xsom.parser.XSOMParser)1 Iterator (java.util.Iterator)1 SAXException (org.xml.sax.SAXException)1