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

The following examples show how to use org.apache.ws.commons.schema.XmlSchemaAny. 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 5 votes vote down vote up
/**
 * If the object is an element or an any, return the particle. If it's not a particle, or it's a group,
 * throw. We're not ready for groups yet.
 * @param object
 */
public static XmlSchemaParticle getObjectParticle(XmlSchemaObject object, QName contextName,
                                                  XmlSchema currentSchema) {

    if (!(object instanceof XmlSchemaParticle)) {
        unsupportedConstruct("NON_PARTICLE_CHILD",
                                            object.getClass().getSimpleName(),
                                            contextName, object);
    }

    if (object instanceof XmlSchemaGroupRef) {
        QName groupName = ((XmlSchemaGroupRef) object).getRefName();
        XmlSchemaGroup group = currentSchema.getGroupByName(groupName);
        if (group == null) {
            unsupportedConstruct("MISSING_GROUP",
                    groupName.toString(), contextName, null);
        }

        XmlSchemaParticle groupParticle = group.getParticle();

        if (!(groupParticle instanceof XmlSchemaSequence)) {
            unsupportedConstruct("GROUP_REF_UNSUPPORTED_TYPE",
                    groupParticle.getClass().getSimpleName(), contextName, groupParticle);
        }

        return groupParticle;
    }

    if (!(object instanceof XmlSchemaElement)
        && !(object instanceof XmlSchemaAny)
        && !(object instanceof XmlSchemaChoice)
        && !(object instanceof XmlSchemaSequence)) {
        unsupportedConstruct("GROUP_CHILD",
                object.getClass().getSimpleName(), contextName,
                                            object);
    }

    return (XmlSchemaParticle) object;
}