org.apache.cxf.javascript
Class XmlSchemaUtils

java.lang.Object
  extended by org.apache.cxf.javascript.XmlSchemaUtils

public final class XmlSchemaUtils
extends java.lang.Object

There are a number of pitfalls in Commons Xml Schema. This class contains some utilities that avoid some of the problems and centralizes some repetitive tasks.


Field Summary
static org.apache.ws.commons.schema.XmlSchemaForm QUALIFIED
           
static org.apache.ws.commons.schema.XmlSchemaForm UNQUALIFIED
           
static java.lang.String XSI_NIL
           
static java.lang.String XSI_NIL_WITH_PREFIX
           
static java.lang.String XSI_NS_ATTR
           
 
Method Summary
static org.apache.ws.commons.schema.XmlSchemaElement findElementByRefName(org.apache.cxf.common.xmlschema.SchemaCollection xmlSchemaCollection, javax.xml.namespace.QName name, java.lang.String referencingURI)
          This copes with an observed phenomenon in the schema built by the ReflectionServiceFactoryBean.
static javax.xml.namespace.QName getBaseType(org.apache.ws.commons.schema.XmlSchemaComplexType type)
           
static org.apache.ws.commons.schema.XmlSchemaObjectCollection getContentAttributes(org.apache.ws.commons.schema.XmlSchemaComplexType type)
           
static java.util.List<org.apache.ws.commons.schema.XmlSchemaAnnotated> getContentAttributes(org.apache.ws.commons.schema.XmlSchemaComplexType type, org.apache.cxf.common.xmlschema.SchemaCollection collection)
           
static java.util.List<org.apache.ws.commons.schema.XmlSchemaObject> getContentElements(org.apache.ws.commons.schema.XmlSchemaComplexType type, org.apache.cxf.common.xmlschema.SchemaCollection collection)
           
static org.apache.ws.commons.schema.XmlSchemaSequence getContentSequence(org.apache.ws.commons.schema.XmlSchemaComplexType type)
           
static org.apache.ws.commons.schema.XmlSchemaType getElementType(org.apache.cxf.common.xmlschema.SchemaCollection xmlSchemaCollection, java.lang.String referencingURI, org.apache.ws.commons.schema.XmlSchemaElement element, org.apache.ws.commons.schema.XmlSchemaType containingType)
          Follow a chain of references from element to element until we can obtain a type.
static org.apache.ws.commons.schema.XmlSchemaAnnotated getObjectAnnotated(org.apache.ws.commons.schema.XmlSchemaObject object, javax.xml.namespace.QName contextName)
          If the object is an attribute or an anyAttribute, return the 'Annotated'.
static org.apache.ws.commons.schema.XmlSchemaParticle getObjectParticle(org.apache.ws.commons.schema.XmlSchemaObject object, javax.xml.namespace.QName contextName)
          If the object is an element or an any, return the particle.
static org.apache.ws.commons.schema.XmlSchemaElement getReferredElement(org.apache.ws.commons.schema.XmlSchemaElement element, org.apache.cxf.common.xmlschema.SchemaCollection xmlSchemaCollection)
           
static org.apache.ws.commons.schema.XmlSchemaSequence getSequence(org.apache.ws.commons.schema.XmlSchemaComplexType type)
           
static boolean isAttributeNameQualified(org.apache.ws.commons.schema.XmlSchemaAttribute attribute, org.apache.ws.commons.schema.XmlSchema schema)
           
static boolean isAttributeQualified(org.apache.ws.commons.schema.XmlSchemaAttribute attribute, boolean global, org.apache.ws.commons.schema.XmlSchema localSchema, org.apache.ws.commons.schema.XmlSchema attributeSchema)
          due to a bug, feature, or just plain oddity of JAXB, it isn't good enough to just check the form of an element and of its schema.
static boolean isComplexType(org.apache.ws.commons.schema.XmlSchemaType type)
           
static boolean isElementNameQualified(org.apache.ws.commons.schema.XmlSchemaElement element, org.apache.ws.commons.schema.XmlSchema schema)
           
static boolean isElementQualified(org.apache.ws.commons.schema.XmlSchemaElement element, boolean global, org.apache.ws.commons.schema.XmlSchema localSchema, org.apache.ws.commons.schema.XmlSchema elementSchema)
          due to a bug, feature, or just plain oddity of JAXB, it isn't good enough to just check the form of an element and of its schema.
static boolean isParticleArray(org.apache.ws.commons.schema.XmlSchemaParticle particle)
           
static boolean isParticleOptional(org.apache.ws.commons.schema.XmlSchemaParticle particle)
           
static void unsupportedConstruct(java.lang.String messageKey, java.lang.String what, javax.xml.namespace.QName subjectName, org.apache.ws.commons.schema.XmlSchemaObject subject)
           
static void unsupportedConstruct(java.lang.String messageKey, org.apache.ws.commons.schema.XmlSchemaType subject)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUALIFIED

public static final org.apache.ws.commons.schema.XmlSchemaForm QUALIFIED

UNQUALIFIED

public static final org.apache.ws.commons.schema.XmlSchemaForm UNQUALIFIED

XSI_NS_ATTR

public static final java.lang.String XSI_NS_ATTR
See Also:
Constant Field Values

XSI_NIL_WITH_PREFIX

public static final java.lang.String XSI_NIL_WITH_PREFIX
See Also:
Constant Field Values

XSI_NIL

public static final java.lang.String XSI_NIL
See Also:
Constant Field Values
Method Detail

unsupportedConstruct

public static void unsupportedConstruct(java.lang.String messageKey,
                                        org.apache.ws.commons.schema.XmlSchemaType subject)

unsupportedConstruct

public static void unsupportedConstruct(java.lang.String messageKey,
                                        java.lang.String what,
                                        javax.xml.namespace.QName subjectName,
                                        org.apache.ws.commons.schema.XmlSchemaObject subject)

getBaseType

public static javax.xml.namespace.QName getBaseType(org.apache.ws.commons.schema.XmlSchemaComplexType type)

getContentSequence

public static org.apache.ws.commons.schema.XmlSchemaSequence getContentSequence(org.apache.ws.commons.schema.XmlSchemaComplexType type)

getContentAttributes

public static org.apache.ws.commons.schema.XmlSchemaObjectCollection getContentAttributes(org.apache.ws.commons.schema.XmlSchemaComplexType type)

getContentElements

public static java.util.List<org.apache.ws.commons.schema.XmlSchemaObject> getContentElements(org.apache.ws.commons.schema.XmlSchemaComplexType type,
                                                                                              org.apache.cxf.common.xmlschema.SchemaCollection collection)

getContentAttributes

public static java.util.List<org.apache.ws.commons.schema.XmlSchemaAnnotated> getContentAttributes(org.apache.ws.commons.schema.XmlSchemaComplexType type,
                                                                                                   org.apache.cxf.common.xmlschema.SchemaCollection collection)

getSequence

public static org.apache.ws.commons.schema.XmlSchemaSequence getSequence(org.apache.ws.commons.schema.XmlSchemaComplexType type)

findElementByRefName

public static org.apache.ws.commons.schema.XmlSchemaElement findElementByRefName(org.apache.cxf.common.xmlschema.SchemaCollection xmlSchemaCollection,
                                                                                 javax.xml.namespace.QName name,
                                                                                 java.lang.String referencingURI)
This copes with an observed phenomenon in the schema built by the ReflectionServiceFactoryBean. It is creating element such that: (a) the type is not set. (b) the refName is set. (c) the namespaceURI in the refName is set empty. This apparently indicates 'same Schema' to everyone else, so thus function implements that convention here. It is unclear if that is a correct structure, and it if changes, we can simplify or eliminate this function.

Parameters:
name -
referencingURI -
Returns:

getElementType

public static org.apache.ws.commons.schema.XmlSchemaType getElementType(org.apache.cxf.common.xmlschema.SchemaCollection xmlSchemaCollection,
                                                                        java.lang.String referencingURI,
                                                                        org.apache.ws.commons.schema.XmlSchemaElement element,
                                                                        org.apache.ws.commons.schema.XmlSchemaType containingType)
Follow a chain of references from element to element until we can obtain a type.

Parameters:
element -
Returns:

isComplexType

public static boolean isComplexType(org.apache.ws.commons.schema.XmlSchemaType type)

isElementNameQualified

public static boolean isElementNameQualified(org.apache.ws.commons.schema.XmlSchemaElement element,
                                             org.apache.ws.commons.schema.XmlSchema schema)

isAttributeNameQualified

public static boolean isAttributeNameQualified(org.apache.ws.commons.schema.XmlSchemaAttribute attribute,
                                               org.apache.ws.commons.schema.XmlSchema schema)

isElementQualified

public static boolean isElementQualified(org.apache.ws.commons.schema.XmlSchemaElement element,
                                         boolean global,
                                         org.apache.ws.commons.schema.XmlSchema localSchema,
                                         org.apache.ws.commons.schema.XmlSchema elementSchema)
due to a bug, feature, or just plain oddity of JAXB, it isn't good enough to just check the form of an element and of its schema. If schema 'a' (default unqualified) has a complex type with an element with a ref= to schema (b) (default unqualified), JAXB seems to expect to see a qualifier, anyway.
So, if the element is local to a complex type, all we care about is the default element form of the schema and the local form of the element.
If, on the other hand, the element is global, we might need to compare namespaces.

Parameters:
element - the element.
global - if this element is a global element (complex type ref= to it, or in a part)
localSchema - the schema of the complex type containing the reference, only used for the 'odd case'.
elementSchema - the schema for the element.
Returns:
if the element needs to be qualified.

isAttributeQualified

public static boolean isAttributeQualified(org.apache.ws.commons.schema.XmlSchemaAttribute attribute,
                                           boolean global,
                                           org.apache.ws.commons.schema.XmlSchema localSchema,
                                           org.apache.ws.commons.schema.XmlSchema attributeSchema)
due to a bug, feature, or just plain oddity of JAXB, it isn't good enough to just check the form of an element and of its schema. If schema 'a' (default unqualified) has a complex type with an element with a ref= to schema (b) (default unqualified), JAXB seems to expect to see a qualifier, anyway.
So, if the element is local to a complex type, all we care about is the default element form of the schema and the local form of the element.
If, on the other hand, the element is global, we might need to compare namespaces.

Parameters:
attribute - the attribute
global - if this element is a global element (complex type ref= to it, or in a part)
localSchema - the schema of the complex type containing the reference, only used for the 'odd case'.
elementSchema - the schema for the element.
Returns:
if the element needs to be qualified.

getObjectParticle

public static org.apache.ws.commons.schema.XmlSchemaParticle getObjectParticle(org.apache.ws.commons.schema.XmlSchemaObject object,
                                                                               javax.xml.namespace.QName contextName)
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.

Parameters:
object -
Returns:

getObjectAnnotated

public static org.apache.ws.commons.schema.XmlSchemaAnnotated getObjectAnnotated(org.apache.ws.commons.schema.XmlSchemaObject object,
                                                                                 javax.xml.namespace.QName contextName)
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.

Parameters:
object -
Returns:

isParticleArray

public static boolean isParticleArray(org.apache.ws.commons.schema.XmlSchemaParticle particle)

isParticleOptional

public static boolean isParticleOptional(org.apache.ws.commons.schema.XmlSchemaParticle particle)

getReferredElement

public static org.apache.ws.commons.schema.XmlSchemaElement getReferredElement(org.apache.ws.commons.schema.XmlSchemaElement element,
                                                                               org.apache.cxf.common.xmlschema.SchemaCollection xmlSchemaCollection)


Apache CXF