use of org.apache.ws.commons.schema.XmlSchemaAnnotated in project cxf by apache.
the class XmlSchemaUtils method getContentAttributes.
public static List<XmlSchemaAnnotated> getContentAttributes(XmlSchemaComplexType type, SchemaCollection collection) {
List<XmlSchemaAnnotated> results = new ArrayList<>();
QName baseTypeName = getBaseType(type);
if (baseTypeName != null) {
XmlSchemaComplexType baseType = (XmlSchemaComplexType) collection.getTypeByQName(baseTypeName);
// recurse onto the base type ...
results.addAll(getContentAttributes(baseType, collection));
// and now process our sequence.
List<XmlSchemaAttributeOrGroupRef> extAttrs = getContentAttributes(type);
results.addAll(extAttrs);
return results;
}
// no base type, the simple case.
List<XmlSchemaAttributeOrGroupRef> attrs = type.getAttributes();
results.addAll(attrs);
return results;
}
use of org.apache.ws.commons.schema.XmlSchemaAnnotated in project cxf by apache.
the class ServiceModelUtil method getOperationInputPartNames.
public static List<String> getOperationInputPartNames(OperationInfo operation) {
List<String> names = new ArrayList<>();
List<MessagePartInfo> parts = operation.getInput().getMessageParts();
if (parts == null || parts.isEmpty()) {
return names;
}
for (MessagePartInfo part : parts) {
XmlSchemaAnnotated schema = part.getXmlSchema();
if (schema instanceof XmlSchemaElement && ((XmlSchemaElement) schema).getSchemaType() instanceof XmlSchemaComplexType) {
XmlSchemaElement element = (XmlSchemaElement) schema;
XmlSchemaComplexType cplxType = (XmlSchemaComplexType) element.getSchemaType();
XmlSchemaSequence seq = (XmlSchemaSequence) cplxType.getParticle();
if (seq == null || seq.getItems() == null) {
return names;
}
for (int i = 0; i < seq.getItems().size(); i++) {
XmlSchemaElement elChild = (XmlSchemaElement) seq.getItems().get(i);
names.add(elChild.getName());
}
} else {
names.add(part.getConcreteName().getLocalPart());
}
}
return names;
}
use of org.apache.ws.commons.schema.XmlSchemaAnnotated in project cxf by apache.
the class AttributeInfo method forLocalItem.
/**
* Fill in an AttributeInfo for an attribute or anyAttribute from a sequence.
*
* @param sequenceElement
* @param currentSchema
* @param schemaCollection
* @param prefixAccumulator
* @return
*/
public static AttributeInfo forLocalItem(XmlSchemaObject sequenceObject, XmlSchema currentSchema, SchemaCollection schemaCollection, NamespacePrefixAccumulator prefixAccumulator, QName contextName) {
XmlSchemaAnnotated annotated = JavascriptUtils.getObjectAnnotated(sequenceObject, contextName);
AttributeInfo attributeInfo = new AttributeInfo();
XmlSchemaAnnotated realAnnotated = annotated;
if (annotated instanceof XmlSchemaAttribute) {
XmlSchemaAttribute attribute = (XmlSchemaAttribute) annotated;
attributeInfo.use = attribute.getUse();
if (attribute.getRef().getTarget() != null) {
realAnnotated = attribute.getRef().getTarget();
attributeInfo.global = true;
}
} else if (annotated instanceof XmlSchemaAnyAttribute) {
attributeInfo.any = true;
// unknown until runtime.
attributeInfo.xmlName = null;
attributeInfo.javascriptName = "any";
// runtime for any.
attributeInfo.type = null;
attributeInfo.use = XmlSchemaUse.OPTIONAL;
} else {
throw new UnsupportedConstruct(LOG, "UNSUPPORTED_ATTRIBUTE_ITEM", annotated, contextName);
}
factoryCommon(realAnnotated, currentSchema, schemaCollection, prefixAccumulator, attributeInfo);
attributeInfo.annotated = realAnnotated;
return attributeInfo;
}
use of org.apache.ws.commons.schema.XmlSchemaAnnotated in project cxf by apache.
the class SchemaJavascriptBuilder method complexTypeConstructorAndAccessors.
// In general, I (bimargulies) hate fields that are temporary communications
// between members of a class. However, given the style restrictions on the
// number
// of parameters, it's the least of the evils.
public void complexTypeConstructorAndAccessors(QName name, XmlSchemaComplexType type) {
accessors = new StringBuilder();
utils = new JavascriptUtils(code);
List<XmlSchemaObject> items = JavascriptUtils.getContentElements(type, xmlSchemaCollection);
List<XmlSchemaAnnotated> attrs = XmlSchemaUtils.getContentAttributes(type, xmlSchemaCollection);
final String elementPrefix = "this._";
String typeObjectName = nameManager.getJavascriptName(name);
code.append("//\n");
code.append("// Constructor for XML Schema item " + name.toString() + "\n");
code.append("//\n");
code.append("function " + typeObjectName + " () {\n");
// to assist in debugging we put a type property into every object.
utils.appendLine("this.typeMarker = '" + typeObjectName + "';");
for (XmlSchemaObject thing : items) {
ParticleInfo itemInfo = ParticleInfo.forLocalItem(thing, xmlSchema, xmlSchemaCollection, prefixAccumulator, type.getQName());
constructItem(type, elementPrefix, typeObjectName, itemInfo);
}
for (XmlSchemaAnnotated thing : attrs) {
AttributeInfo itemInfo = AttributeInfo.forLocalItem(thing, xmlSchema, xmlSchemaCollection, prefixAccumulator, type.getQName());
constructOneItem(type, elementPrefix, typeObjectName, itemInfo);
}
code.append("}\n\n");
code.append(accessors.toString());
}
use of org.apache.ws.commons.schema.XmlSchemaAnnotated in project cxf by apache.
the class AegisDatabinding method initializeMessageTypes.
protected void initializeMessageTypes(ServiceInfo s, AbstractMessageContainer container, int partType) {
if (container == null) {
return;
}
SchemaCollection col = s.getXmlSchemaCollection();
for (MessagePartInfo part : container.getMessageParts()) {
if (part.getXmlSchema() == null) {
if (part.isElement()) {
XmlSchemaAnnotated tp = col.getElementByQName(part.getElementQName());
part.setXmlSchema(tp);
} else {
XmlSchemaAnnotated tp = col.getTypeByQName(part.getTypeQName());
part.setXmlSchema(tp);
}
}
}
}
Aggregations