Search in sources :

Example 1 with XmlSchemaAnnotated

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;
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) XmlSchemaAnnotated(org.apache.ws.commons.schema.XmlSchemaAnnotated) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaAttributeOrGroupRef(org.apache.ws.commons.schema.XmlSchemaAttributeOrGroupRef)

Example 2 with XmlSchemaAnnotated

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;
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) ArrayList(java.util.ArrayList) XmlSchemaAnnotated(org.apache.ws.commons.schema.XmlSchemaAnnotated) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) Endpoint(org.apache.cxf.endpoint.Endpoint)

Example 3 with XmlSchemaAnnotated

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;
}
Also used : XmlSchemaAnnotated(org.apache.ws.commons.schema.XmlSchemaAnnotated) XmlSchemaAnyAttribute(org.apache.ws.commons.schema.XmlSchemaAnyAttribute) XmlSchemaAttribute(org.apache.ws.commons.schema.XmlSchemaAttribute)

Example 4 with XmlSchemaAnnotated

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());
}
Also used : AttributeInfo(org.apache.cxf.javascript.AttributeInfo) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) JavascriptUtils(org.apache.cxf.javascript.JavascriptUtils) ParticleInfo(org.apache.cxf.javascript.ParticleInfo) XmlSchemaAnnotated(org.apache.ws.commons.schema.XmlSchemaAnnotated)

Example 5 with XmlSchemaAnnotated

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);
            }
        }
    }
}
Also used : XmlSchemaAnnotated(org.apache.ws.commons.schema.XmlSchemaAnnotated) SchemaCollection(org.apache.cxf.common.xmlschema.SchemaCollection) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Aggregations

XmlSchemaAnnotated (org.apache.ws.commons.schema.XmlSchemaAnnotated)5 ArrayList (java.util.ArrayList)2 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)2 QName (javax.xml.namespace.QName)1 SchemaCollection (org.apache.cxf.common.xmlschema.SchemaCollection)1 Endpoint (org.apache.cxf.endpoint.Endpoint)1 AttributeInfo (org.apache.cxf.javascript.AttributeInfo)1 JavascriptUtils (org.apache.cxf.javascript.JavascriptUtils)1 ParticleInfo (org.apache.cxf.javascript.ParticleInfo)1 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)1 XmlSchemaAnyAttribute (org.apache.ws.commons.schema.XmlSchemaAnyAttribute)1 XmlSchemaAttribute (org.apache.ws.commons.schema.XmlSchemaAttribute)1 XmlSchemaAttributeOrGroupRef (org.apache.ws.commons.schema.XmlSchemaAttributeOrGroupRef)1 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)1 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)1 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)1