org.apache.ws.commons.schema.XmlSchemaAnnotated Java Examples

The following examples show how to use org.apache.ws.commons.schema.XmlSchemaAnnotated. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavascriptUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * If the object is an attribute or an anyAttribute,
 * return the 'Annotated'. If it's not one of those, or it's a group,
 * throw. We're not ready for groups yet.
 * @param object
 */
public static XmlSchemaAnnotated getObjectAnnotated(XmlSchemaObject object, QName contextName) {

    if (!(object instanceof XmlSchemaAnnotated)) {
        unsupportedConstruct("NON_ANNOTATED_ATTRIBUTE",
                                            object.getClass().getSimpleName(),
                                            contextName, object);
    }
    if (!(object instanceof XmlSchemaAttribute)
        && !(object instanceof XmlSchemaAnyAttribute)) {
        unsupportedConstruct("EXOTIC_ATTRIBUTE",
                                            object.getClass().getSimpleName(), contextName,
                                            object);
    }

    return (XmlSchemaAnnotated) object;
}
 
Example #2
Source File: XmlSchemaUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: AttributeInfo.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Fill in an AttributeInfo for an attribute or anyAttribute from a sequence.
 *
 * @param sequenceObject
 * @param currentSchema
 * @param schemaCollection
 * @param prefixAccumulator
 * @param contextName
 * @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;
        attributeInfo.xmlName = null; // unknown until runtime.
        attributeInfo.javascriptName = "any";
        attributeInfo.type = null; // runtime for any.
        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;
}
 
Example #4
Source File: AttributeInfo.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static void factoryCommon(XmlSchemaAnnotated annotated, XmlSchema currentSchema,
                                  SchemaCollection schemaCollection,
                                  NamespacePrefixAccumulator prefixAccumulator,
                                  AttributeInfo attributeInfo) {

    if (annotated instanceof XmlSchemaAttribute) {
        XmlSchemaAttribute attribute = (XmlSchemaAttribute)annotated;
        String attributeNamespaceURI = attribute.getQName().getNamespaceURI();
        boolean attributeNoNamespace = "".equals(attributeNamespaceURI);

        XmlSchema attributeSchema = null;
        if (!attributeNoNamespace) {
            attributeSchema = schemaCollection.getSchemaByTargetNamespace(attributeNamespaceURI);
            if (attributeSchema == null) {
                throw new RuntimeException("Missing schema " + attributeNamespaceURI);
            }
        }

        boolean qualified = !attributeNoNamespace
                            && XmlSchemaUtils.isAttributeQualified(attribute, true, currentSchema,
                                                                 attributeSchema);
        attributeInfo.xmlName = prefixAccumulator.xmlAttributeString(attribute, qualified);
        // we are assuming here that we are not dealing, in close proximity,
        // with elements with identical local names and different
        // namespaces.
        attributeInfo.javascriptName = attribute.getQName().getLocalPart();
        attributeInfo.defaultValue = attribute.getDefaultValue();
        attributeInfo.fixedValue = attribute.getFixedValue();
        attributeInfo.use = attribute.getUse();
        factorySetupType(attribute, schemaCollection, attributeInfo);
    } else { // any
        attributeInfo.any = true;
        attributeInfo.xmlName = null; // unknown until runtime.
        attributeInfo.javascriptName = "any";
        attributeInfo.type = null; // runtime for any.
        attributeInfo.use = XmlSchemaUse.OPTIONAL;
    }
}
 
Example #5
Source File: ServiceModelUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #6
Source File: Xsd2UmlConvert.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
/**
 * The xs:annotation is parsed into {@link TaggedValue} with one entry per
 * xs:documentation or xs:appinfo.
 */
private static final List<TaggedValue> annotations(final XmlSchemaAnnotated schemaType, final Xsd2UmlConfig config) {
    if (schemaType == null) {
        return EMPTY_TAGGED_VALUES;
    }
    final XmlSchemaAnnotation annotation = schemaType.getAnnotation();
    if (annotation == null) {
        return EMPTY_TAGGED_VALUES;
    } else {
        final List<TaggedValue> taggedValues = new LinkedList<TaggedValue>();
        final XmlSchemaObjectCollection children = annotation.getItems();
        
        for (int childIdx = 0; childIdx < children.getCount(); ++childIdx) {
            
            final XmlSchemaObject child = children.getItem(childIdx);
            if (child instanceof XmlSchemaDocumentation) {
                final XmlSchemaDocumentation documentation = (XmlSchemaDocumentation) child;
                taggedValues.add(documentation(documentation, config));
            } else if (child instanceof XmlSchemaAppInfo) {
                final XmlSchemaAppInfo appInfo = (XmlSchemaAppInfo) child;
                taggedValues.addAll(config.getPlugin().tagsFromAppInfo(appInfo, config));
            } else {
                throw new AssertionError(child);
            }
        }
        
        return taggedValues;
    }
}
 
Example #7
Source File: MessagePartInfo.java    From cxf with Apache License 2.0 4 votes vote down vote up
public XmlSchemaAnnotated getXmlSchema() {
    return xmlSchema;
}
 
Example #8
Source File: MessagePartInfo.java    From cxf with Apache License 2.0 4 votes vote down vote up
public void setXmlSchema(XmlSchemaAnnotated xmlSchema) {
    this.xmlSchema = xmlSchema;
}
 
Example #9
Source File: AttributeInfo.java    From cxf with Apache License 2.0 2 votes vote down vote up
/**
 * Return the object for the Attribute or the anyAttribute.
 * @return
 */
public XmlSchemaAnnotated getAnnotated() {
    return annotated;
}