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);
}
}
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;
}
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;
}
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");
}
}
}
}
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;
}
}
}
}
Aggregations