Search in sources :

Example 91 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.

the class XSDVisitor method visitSchema.

public void visitSchema(XSDSchema schema) {
    this.schema = schema;
    for (Iterator iterator = schema.getAttributeDeclarations().iterator(); iterator.hasNext(); ) {
        XSDAttributeDeclaration attr = (XSDAttributeDeclaration) iterator.next();
        visitAttributeDeclaration(attr);
    }
    for (Iterator iterator = schema.getTypeDefinitions().iterator(); iterator.hasNext(); ) {
        XSDTypeDefinition type = (XSDTypeDefinition) iterator.next();
        visitTypeDefinition(type);
    }
    for (Iterator iterator = schema.getElementDeclarations().iterator(); iterator.hasNext(); ) {
        XSDElementDeclaration element = (XSDElementDeclaration) iterator.next();
        visitElementDeclaration(element);
    }
    for (Iterator iterator = schema.getIdentityConstraintDefinitions().iterator(); iterator.hasNext(); ) {
        XSDIdentityConstraintDefinition identityConstraint = (XSDIdentityConstraintDefinition) iterator.next();
        visitIdentityConstraintDefinition(identityConstraint);
    }
    for (Iterator iterator = schema.getModelGroupDefinitions().iterator(); iterator.hasNext(); ) {
        XSDModelGroupDefinition modelGroup = (XSDModelGroupDefinition) iterator.next();
        visitModelGroupDefinition(modelGroup);
    }
    for (Iterator iterator = schema.getAttributeGroupDefinitions().iterator(); iterator.hasNext(); ) {
        XSDAttributeGroupDefinition attributeGroup = (XSDAttributeGroupDefinition) iterator.next();
        visitAttributeGroupDefinition(attributeGroup);
    }
    for (Iterator iterator = schema.getNotationDeclarations().iterator(); iterator.hasNext(); ) {
        XSDNotationDeclaration element = (XSDNotationDeclaration) iterator.next();
        visitNotationDeclaration(element);
    }
}
Also used : XSDNotationDeclaration(org.eclipse.xsd.XSDNotationDeclaration) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) Iterator(java.util.Iterator) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 92 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.

the class TypesHelper method getUserComplexTypeNamesList.

public java.util.List getUserComplexTypeNamesList() {
    Vector items = new Vector();
    if (xsdSchema != null) {
        updateExternalImportGlobals();
        Iterator i = xsdSchema.getTypeDefinitions().iterator();
        while (i.hasNext()) {
            XSDTypeDefinition typeDefinition = (XSDTypeDefinition) i.next();
            if (typeDefinition instanceof XSDComplexTypeDefinition) {
                items.addAll(getPrefixedNames(typeDefinition.getTargetNamespace(), typeDefinition.getName()));
            }
        }
        items = (Vector) sortList(items);
    }
    return items;
}
Also used : Iterator(java.util.Iterator) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) Vector(java.util.Vector) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 93 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.

the class TypesHelper method getUserSimpleTypeNamesList.

public java.util.List getUserSimpleTypeNamesList() {
    Vector items = new Vector();
    if (xsdSchema != null) {
        updateExternalImportGlobals();
        Iterator i = xsdSchema.getTypeDefinitions().iterator();
        while (i.hasNext()) {
            XSDTypeDefinition typeDefinition = (XSDTypeDefinition) i.next();
            if (typeDefinition instanceof XSDSimpleTypeDefinition) {
                items.addAll(getPrefixedNames(typeDefinition.getTargetNamespace(), typeDefinition.getName()));
            }
        }
        items = (Vector) sortList(items);
    }
    return items;
}
Also used : XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Iterator(java.util.Iterator) Vector(java.util.Vector) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 94 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.

the class BugFixesTest method testEnumerationsInSimpleTypeHierarchy.

public void testEnumerationsInSimpleTypeHierarchy() {
    // See bug 424276
    Bundle bundle = Platform.getBundle(XSDCoreTestsPlugin.PLUGIN_ID);
    // $NON-NLS-1$
    URL url = bundle.getEntry("/testresources/samples/bugzilla424276.xsd");
    CMDocument cmDocument = XSDImpl.buildCMDocument(url.toExternalForm());
    assertNotNull(cmDocument);
    XSDSchema xsdSchema = XSDImpl.buildXSDModel(url.toExternalForm());
    // $NON-NLS-1$
    assertNotNull("failed to build model for " + url.toExternalForm());
    // $NON-NLS-1$
    assertTrue("Number of types in the test schema is 8", xsdSchema.getTypeDefinitions().size() == 8);
    for (Iterator<XSDTypeDefinition> types = xsdSchema.getTypeDefinitions().iterator(); types.hasNext(); ) {
        XSDTypeDefinition type = types.next();
        if (type instanceof XSDSimpleTypeDefinition) {
            XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition) type;
            // System.out.println(simpleType.getName());
            if ("A".equals(simpleType.getName())) {
                String[] enumeratedValuesForType = XSDImpl.getEnumeratedValuesForType(simpleType);
                assertEquals(1, enumeratedValuesForType.length);
                assertEquals(enumeratedValuesForType[0], "01");
            }
            if ("B0".equals(simpleType.getName())) {
                String[] enumeratedValuesForType = XSDImpl.getEnumeratedValuesForType(simpleType);
                assertEquals(1, enumeratedValuesForType.length);
                assertEquals(enumeratedValuesForType[0], "01");
            }
            if ("C0".equals(simpleType.getName())) {
                String[] enumeratedValuesForType = XSDImpl.getEnumeratedValuesForType(simpleType);
                assertEquals(2, enumeratedValuesForType.length);
                assertEquals(enumeratedValuesForType[0], "01");
                assertEquals(enumeratedValuesForType[1], "02");
            }
            if ("D0".equals(simpleType.getName())) {
                String[] enumeratedValuesForType = XSDImpl.getEnumeratedValuesForType(simpleType);
                assertEquals(4, enumeratedValuesForType.length);
                assertEquals(enumeratedValuesForType[0], "01");
                assertEquals(enumeratedValuesForType[1], "02");
                assertEquals(enumeratedValuesForType[2], "03");
                assertEquals(enumeratedValuesForType[3], "04");
            }
        }
    }
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) Bundle(org.osgi.framework.Bundle) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) URL(java.net.URL) XSDSchema(org.eclipse.xsd.XSDSchema) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 95 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.

the class BugFixesTest method testEnumerationsInComplexTypesWithSimpleContent.

public void testEnumerationsInComplexTypesWithSimpleContent() {
    // See bug 215514
    // Obtain the Web Application schema
    String vxmlSchemaURI = locateFileUsingCatalog("http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd");
    assertNotNull("unable to locate file for " + vxmlSchemaURI, vxmlSchemaURI);
    assertTrue("unable to locate file for " + vxmlSchemaURI, vxmlSchemaURI.length() > 0);
    XSDSchema xsdSchema = XSDImpl.buildXSDModel(vxmlSchemaURI);
    assertNotNull("failed to build model for " + vxmlSchemaURI, xsdSchema);
    // The type transport-guaranteeType is defined as a complex type with simple type content
    // It has 3 enumerated values
    String typeName = "transport-guaranteeType";
    for (Iterator<XSDTypeDefinition> types = xsdSchema.getTypeDefinitions().iterator(); types.hasNext(); ) {
        XSDTypeDefinition type = types.next();
        if (type instanceof XSDComplexTypeDefinition) {
            XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) type;
            if (typeName.equals(complexType.getName())) {
                String[] enumeratedValuesForType = XSDImpl.getEnumeratedValuesForType(complexType);
                // Ensure that the 3 enumerated values are returned
                assertEquals(3, enumeratedValuesForType.length);
                return;
            }
        }
    }
}
Also used : XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDSchema(org.eclipse.xsd.XSDSchema) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Aggregations

XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)119 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)66 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)57 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)46 ArrayList (java.util.ArrayList)39 XSDParticle (org.eclipse.xsd.XSDParticle)36 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)32 Iterator (java.util.Iterator)26 XSDSchema (org.eclipse.xsd.XSDSchema)26 List (java.util.List)22 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)17 EList (org.eclipse.emf.common.util.EList)16 TreeObject (com.amalto.workbench.models.TreeObject)14 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)14 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)13 XSDTerm (org.eclipse.xsd.XSDTerm)13 XSDFactory (org.eclipse.xsd.XSDFactory)12 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)11 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)10 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)10