Search in sources :

Example 6 with XmlSchemaElement

use of org.apache.ws.commons.schema.XmlSchemaElement in project tomee by apache.

the class CommonsSchemaInfoBuilder method addNestedElement.

private void addNestedElement(XmlSchemaElement element, XmlTypeInfo enclosingType) {
    QName elementQName;
    QName typeQName;
    if (element.getRefName() == null) {
        //
        // Normal element in a type
        //
        // Element Name with namespace
        String elementNamespace = element.getQName().getNamespaceURI();
        if (elementNamespace == null || elementNamespace.equals("")) {
            elementNamespace = enclosingType.qname.getNamespaceURI();
        }
        elementQName = new QName(elementNamespace, element.getQName().getLocalPart());
        // Type name
        if (element.getSchemaTypeName() != null) {
            // Global type
            typeQName = element.getSchemaTypeName();
        } else {
            // Anonymous type, so we need to declare it
            // Rule 2.b: Anonymous element absolute name "T>N"
            String anonymoustName = enclosingType.qname.getLocalPart() + ">" + elementQName.getLocalPart();
            QName anonymousQName = new QName(elementNamespace, anonymoustName);
            // Rule 1.b: Anonymous type name ">E"
            typeQName = new QName(elementNamespace, ">" + anonymousQName.getLocalPart());
            addType(typeQName, element.getSchemaType());
        }
    } else {
        //
        // Referenced global element
        //
        // Local the referenced global element
        XmlSchemaElement refElement = xmlSchemaCollection.getElementByQName(element.getRefName());
        // The name and type of the nested element are determined by the referenced element
        elementQName = refElement.getQName();
        typeQName = refElement.getSchemaTypeName();
    }
    // Add element to enclosing type
    XmlElementInfo nestedElement = createXmlElementInfo(elementQName, typeQName, element);
    enclosingType.elements.put(nestedElement.qname, nestedElement);
}
Also used : QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement)

Example 7 with XmlSchemaElement

use of org.apache.ws.commons.schema.XmlSchemaElement in project ddf by codice.

the class TestGenericFeatureConverter method buildSchemaElement.

private XmlSchemaElement buildSchemaElement(String elementName, XmlSchema schema, QName typeName) {
    XmlSchemaElement element = new XmlSchemaElement(schema, true);
    element.setSchemaType(new XmlSchemaSimpleType(schema, false));
    element.setSchemaTypeName(typeName);
    element.setName(elementName);
    return element;
}
Also used : XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType)

Example 8 with XmlSchemaElement

use of org.apache.ws.commons.schema.XmlSchemaElement in project ddf by codice.

the class FeatureMetacardTypeTest method testfeatureMetacardTypeFindSingleGmlProperty.

@Test
public void testfeatureMetacardTypeFindSingleGmlProperty() {
    XmlSchema schema = new XmlSchema();
    XmlSchemaElement gmlElement = new XmlSchemaElement(schema, true);
    gmlElement.setSchemaType(new XmlSchemaComplexType(schema, false));
    gmlElement.setSchemaTypeName(new QName(Wfs20Constants.GML_3_2_NAMESPACE, GML));
    gmlElement.setName(ELEMENT_NAME_1);
    FeatureMetacardType featureMetacardType = new FeatureMetacardType(schema, FEATURE_TYPE, NON_QUERYABLE_PROPS, Wfs20Constants.GML_3_2_NAMESPACE);
    assertTrue(featureMetacardType.getGmlProperties().size() == 1);
    assertAttributeDescriptor(featureMetacardType, ELEMENT_NAME_1, BasicTypes.GEO_TYPE);
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) FeatureMetacardType(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType) Test(org.junit.Test)

Example 9 with XmlSchemaElement

use of org.apache.ws.commons.schema.XmlSchemaElement in project ddf by codice.

the class FeatureMetacardTypeTest method testFeatureMetacardTypeSingleStringProperty.

@Test
public void testFeatureMetacardTypeSingleStringProperty() {
    XmlSchema schema = new XmlSchema();
    XmlSchemaElement stringElement = new XmlSchemaElement(schema, true);
    stringElement.setSchemaType(new XmlSchemaSimpleType(schema, false));
    stringElement.setSchemaTypeName(Constants.XSD_STRING);
    stringElement.setName(ELEMENT_NAME_1);
    schema.getElements().put(new QName(ELEMENT_NAME_1), stringElement);
    FeatureMetacardType featureMetacardType = new FeatureMetacardType(schema, FEATURE_TYPE, NON_QUERYABLE_PROPS, Wfs20Constants.GML_3_2_NAMESPACE);
    assertTrue(featureMetacardType.getTextualProperties().size() == 1);
    assertAttributeDescriptor(featureMetacardType, ELEMENT_NAME_1, BasicTypes.STRING_TYPE);
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) QName(javax.xml.namespace.QName) FeatureMetacardType(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType) Test(org.junit.Test)

Example 10 with XmlSchemaElement

use of org.apache.ws.commons.schema.XmlSchemaElement in project ddf by codice.

the class FeatureMetacardTypeTest method testFeatureMetacardTypeStringAndGmlProperties.

@Test
public void testFeatureMetacardTypeStringAndGmlProperties() {
    XmlSchema schema = new XmlSchema();
    XmlSchemaElement stringElement = new XmlSchemaElement(schema, true);
    stringElement.setSchemaType(new XmlSchemaSimpleType(schema, false));
    stringElement.setSchemaTypeName(Constants.XSD_STRING);
    stringElement.setName(ELEMENT_NAME_1);
    XmlSchemaElement gmlElement = new XmlSchemaElement(schema, true);
    gmlElement.setSchemaType(new XmlSchemaComplexType(schema, false));
    gmlElement.setSchemaTypeName(new QName(Wfs20Constants.GML_3_2_NAMESPACE, GML));
    gmlElement.setName(ELEMENT_NAME_2);
    schema.getElements().put(new QName(ELEMENT_NAME_1), stringElement);
    schema.getElements().put(new QName(ELEMENT_NAME_2), gmlElement);
    FeatureMetacardType featureMetacardType = new FeatureMetacardType(schema, FEATURE_TYPE, NON_QUERYABLE_PROPS, Wfs20Constants.GML_3_2_NAMESPACE);
    assertTrue(featureMetacardType.getTextualProperties().size() == 1);
    assertTrue(featureMetacardType.getGmlProperties().size() == 1);
    assertAttributeDescriptor(featureMetacardType, ELEMENT_NAME_1, BasicTypes.STRING_TYPE);
    assertAttributeDescriptor(featureMetacardType, ELEMENT_NAME_2, BasicTypes.GEO_TYPE);
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) QName(javax.xml.namespace.QName) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) FeatureMetacardType(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType) Test(org.junit.Test)

Aggregations

XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)52 QName (javax.xml.namespace.QName)38 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)36 XmlSchema (org.apache.ws.commons.schema.XmlSchema)35 Test (org.junit.Test)33 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)32 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)23 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)7 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)6 Iterator (java.util.Iterator)6 XmlSchemaGroupBase (org.apache.ws.commons.schema.XmlSchemaGroupBase)6 XmlSchemaObjectCollection (org.apache.ws.commons.schema.XmlSchemaObjectCollection)6 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)6 ParameterInfo (org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)6 ArrayList (java.util.ArrayList)5 XmlSchemaAttribute (org.apache.ws.commons.schema.XmlSchemaAttribute)5 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)4 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)4 HashMap (java.util.HashMap)3 XmlSchemaAny (org.apache.ws.commons.schema.XmlSchemaAny)3