Class XmlSchemaUtils

java.lang.Object
org.apache.cxf.common.xmlschema.XmlSchemaUtils

public final class XmlSchemaUtils extends Object
Some functions that avoid problems with Commons XML Schema.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addImportIfNeeded(org.apache.ws.commons.schema.XmlSchema schema, String namespaceUri)
    Assist in managing the required for imports of peer schemas.
    static void
    addImportIfNeeded(org.apache.ws.commons.schema.XmlSchema schema, QName qname)
    For convenience, start from a qname, and add the import if it is non-null and has a namespace.
    static List<String>
    enumeratorValues(org.apache.ws.commons.schema.XmlSchemaSimpleType type)
    Retrieve the string values for an enumeration.
    static org.apache.ws.commons.schema.XmlSchemaElement
    findElementByRefName(SchemaCollection xmlSchemaCollection, QName name, String referencingURI)
    This copes with an observed phenomenon in the schema built by the ReflectionServiceFactoryBean.
    static QName
    getBaseType(org.apache.ws.commons.schema.XmlSchemaComplexType type)
     
    static List<org.apache.ws.commons.schema.XmlSchemaAttributeOrGroupRef>
    getContentAttributes(org.apache.ws.commons.schema.XmlSchemaComplexType type)
     
    static List<org.apache.ws.commons.schema.XmlSchemaAnnotated>
    getContentAttributes(org.apache.ws.commons.schema.XmlSchemaComplexType type, SchemaCollection collection)
     
    static QName
    getElementQualifiedName(org.apache.ws.commons.schema.XmlSchemaElement element, org.apache.ws.commons.schema.XmlSchema schema)
    By convention, an element that is named in its schema's TNS can have a 'name' but no QName.
    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
    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
    isEumeration(org.apache.ws.commons.schema.XmlSchemaSimpleType type)
    Return true if a simple type is a straightforward XML Schema representation of an enumeration.
    static boolean
    isParticleArray(org.apache.ws.commons.schema.XmlSchemaParticle particle)
     
    static boolean
    isParticleOptional(org.apache.ws.commons.schema.XmlSchemaParticle particle)
     
    static boolean
    schemaImportsNamespace(org.apache.ws.commons.schema.XmlSchema schema, String namespaceUri)
    Is there an import for a particular namespace in a schema?
    static void
    setElementRefName(org.apache.ws.commons.schema.XmlSchemaElement element, QName name)
    Wrapper around XmlSchemaElement.setRefName that checks for inconsistency with name and QName.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • setElementRefName

      public static void setElementRefName(org.apache.ws.commons.schema.XmlSchemaElement element, QName name)
      Wrapper around XmlSchemaElement.setRefName that checks for inconsistency with name and QName.
      Parameters:
      element -
      name -
    • isEumeration

      public static boolean isEumeration(org.apache.ws.commons.schema.XmlSchemaSimpleType type)
      Return true if a simple type is a straightforward XML Schema representation of an enumeration. If we discover schemas that are 'enum-like' with more complex structures, we might make this deal with them.
      Parameters:
      type - Simple type, possible an enumeration.
      Returns:
      true for an enumeration.
    • enumeratorValues

      public static List<String> enumeratorValues(org.apache.ws.commons.schema.XmlSchemaSimpleType type)
      Retrieve the string values for an enumeration.
      Parameters:
      type -
    • schemaImportsNamespace

      public static boolean schemaImportsNamespace(org.apache.ws.commons.schema.XmlSchema schema, String namespaceUri)
      Is there an import for a particular namespace in a schema?
      Parameters:
      schema -
      namespaceUri -
    • addImportIfNeeded

      public static void addImportIfNeeded(org.apache.ws.commons.schema.XmlSchema schema, String namespaceUri)
      Assist in managing the required for imports of peer schemas.
      Parameters:
      schema -
      namespaceUri -
    • addImportIfNeeded

      public static void addImportIfNeeded(org.apache.ws.commons.schema.XmlSchema schema, QName qname)
      For convenience, start from a qname, and add the import if it is non-null and has a namespace.
      Parameters:
      schema -
      qname -
      See Also:
    • findElementByRefName

      public static org.apache.ws.commons.schema.XmlSchemaElement findElementByRefName(SchemaCollection xmlSchemaCollection, QName name, 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 -
    • getBaseType

      public static QName getBaseType(org.apache.ws.commons.schema.XmlSchemaComplexType type)
    • getContentAttributes

      public static List<org.apache.ws.commons.schema.XmlSchemaAttributeOrGroupRef> getContentAttributes(org.apache.ws.commons.schema.XmlSchemaComplexType type)
    • getContentAttributes

      public static List<org.apache.ws.commons.schema.XmlSchemaAnnotated> getContentAttributes(org.apache.ws.commons.schema.XmlSchemaComplexType type, SchemaCollection collection)
    • getElementQualifiedName

      public static QName getElementQualifiedName(org.apache.ws.commons.schema.XmlSchemaElement element, org.apache.ws.commons.schema.XmlSchema schema)
      By convention, an element that is named in its schema's TNS can have a 'name' but no QName. This can get inconvenient for consumers who want to think about qualified names. Unfortunately, XmlSchema elements, unlike types, don't store a reference to their containing schema.
      Parameters:
      element -
      schema -
    • isAttributeNameQualified

      public static boolean isAttributeNameQualified(org.apache.ws.commons.schema.XmlSchemaAttribute attribute, org.apache.ws.commons.schema.XmlSchema schema)
    • 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'.
      attributeSchema - the schema for the element.
      Returns:
      if the element needs to be qualified.
    • isElementNameQualified

      public static boolean isElementNameQualified(org.apache.ws.commons.schema.XmlSchemaElement element, 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.
    • isParticleArray

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

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