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