Package org.apache.ws.commons.schema
Class XmlSchema
java.lang.Object
org.apache.ws.commons.schema.XmlSchemaObject
org.apache.ws.commons.schema.XmlSchemaAnnotated
org.apache.ws.commons.schema.XmlSchema
- All Implemented Interfaces:
NamespaceContextOwner,XmlSchemaObjectBase
Contains the definition of a schema. All XML Schema definition language (XSD) elements are children of the
schema element.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate XmlSchemaFormprivate Map<QName, XmlSchemaAttributeGroup> private Map<QName, XmlSchemaAttribute> private XmlSchemaDerivationMethodprivate XmlSchemaFormprivate Map<QName, XmlSchemaElement> private List<XmlSchemaExternal> private XmlSchemaDerivationMethodprivate Map<QName, XmlSchemaGroup> private Stringprivate List<XmlSchemaObject> private Stringprivate NamespacePrefixListprivate Map<QName, XmlSchemaNotation> private XmlSchemaCollection(package private) static final Stringprivate Stringprivate Map<QName, XmlSchemaType> private Stringprivate static final Stringprivate StringFields inherited from class org.apache.ws.commons.schema.XmlSchemaObject
lineNumber, linePosition, sourceURI -
Constructor Summary
ConstructorsConstructorDescriptionCreate a schema that is not a member of a collection and has no target namespace or system ID.XmlSchema(String namespace, String systemId, XmlSchemaCollection parent) Create a new schema with a target namespace and system ID, and record it as a member of a schema collection.XmlSchema(String namespace, XmlSchemaCollection parent) Create a new schema in a collection with a target namespace. -
Method Summary
Modifier and TypeMethodDescriptionDocument[]Return an array of DOM documents consisting of this schema and any schemas that it references.getAttributeByName(String name) Look for an attribute by its local name.getAttributeByName(QName name) Retrieve a global attribute by its QName.protected XmlSchemaAttributegetAttributeByName(QName name, boolean deep, Stack<XmlSchema> schemaStack) getAttributeGroupByName(QName name) Retrieve an attribute group by QName.protected XmlSchemaAttributeGroupgetAttributeGroupByName(QName name, boolean deep, Stack<XmlSchema> schemaStack) Return a map containing all the defined attribute groups of this schema.Return a map containing all the defined attributes of this schema.Return the default block value for this schema.getElementByName(String name) get an element by its local name.getElementByName(QName name) Look for a element by its QName.protected XmlSchemaElementgetElementByName(QName name, boolean deep, Stack<XmlSchema> schemaStack) Return a map containing all the defined elements of this schema.Return all of the includes, imports, and redefines for this schema.getGroupByName(QName name) Retrieve a group by QName.protected XmlSchemaGroupgetGroupByName(QName name, boolean deep, Stack<XmlSchema> schemaStack) Return a map containing all the defined groups of this schema.Return the character encoding for this schema.getItems()Return all of the global items in this schema.
If org.apache.ws.commons.schema.protectReadOnlyCollections is 'true', this will return a map that checks at runtime.Return the logical target namespace.Returns the objects namespace context.getNotationByName(QName name) Retrieve a notation by QName.protected XmlSchemaNotationgetNotationByName(QName name, boolean deep, Stack<XmlSchema> schemaStack) Return a map containing all the defined notations of this schema.Return the parent XmlSchemaCollection.private XmlSchemaGet a schema from an importRetrieve a DOM tree for this one schema, independent of any included or related schemas.Return a map containing all the defined types of this schema.(package private) StringReturn the declared target namespace of this schema.getTypeByName(String name) Retrieve a named type from this schema.getTypeByName(QName name) Search this schema, and its peers in its parent collection, for a schema type specified by QName.protected XmlSchemaTypegetTypeByName(QName name, boolean deep, Stack<XmlSchema> schemaStack) Protected method that allows safe (non-recursive schema loading).Return the declared XML Schema version of this schema.private voidloadDefaultOptions(Map<String, String> options) Load the default optionsprivate voidserializeInternal(Writer out, Map<String, String> options) serialize the schema - this is the method tht does to workvoidSet the default attribute form for this schema.voidsetBlockDefault(XmlSchemaDerivationMethod blockDefault) Set the default block value for this schema.voidsetElementFormDefault(XmlSchemaForm elementFormDefault) Set the default element form for this schema.voidsetFinalDefault(XmlSchemaDerivationMethod finalDefault) Set the default 'final' value for this schema.voidsetInputEncoding(String encoding) Set the character encoding name for the schema.(package private) voidsetLogicalTargetNamespace(String logicalTargetNamespace) voidsetNamespaceContext(NamespacePrefixList namespaceContext) Sets the schema elements namespace context.(package private) voidsetParent(XmlSchemaCollection parent) voidsetSchemaNamespacePrefix(String schemaNamespacePrefix) Set the namespace prefix corresponding to the target namespace.(package private) voidsetSyntacticalTargetNamespace(String syntacticalTargetNamespace) voidsetTargetNamespace(String targetNamespace) Set the target namespace for this schema.voidsetVersion(String version) Set the declared XML Schema version of this schematoString()voidwrite(OutputStream out) Serialize the schema as XML to the specified stream using the encoding established withsetInputEncoding(String).voidwrite(OutputStream out, Map<String, String> options) Serialize the schema as XML to the specified stream using the encoding established withsetInputEncoding(String).voidSerialize the schema to aWriter.voidSerialize the schema to aWriter.Methods inherited from class org.apache.ws.commons.schema.XmlSchemaAnnotated
getAnnotation, getId, getUnhandledAttributes, setAnnotation, setId, setUnhandledAttributesMethods inherited from class org.apache.ws.commons.schema.XmlSchemaObject
addMetaInfo, equals, getLineNumber, getLinePosition, getMetaInfoMap, getSourceURI, hashCode, setLineNumber, setLinePosition, setMetaInfoMap, setSourceURI
-
Field Details
-
SCHEMA_NS
- See Also:
-
UTF_8_ENCODING
- See Also:
-
items
-
parent
-
blockDefault
-
finalDefault
-
elementFormDefault
-
attributeFormDefault
-
externals
-
attributeGroups
-
attributes
-
elements
-
groups
-
notations
-
schemaTypes
-
syntacticalTargetNamespace
-
schemaNamespacePrefix
-
logicalTargetNamespace
-
version
-
namespaceContext
-
inputEncoding
-
-
Constructor Details
-
XmlSchema
public XmlSchema()Create a schema that is not a member of a collection and has no target namespace or system ID. -
XmlSchema
Create a new schema with a target namespace and system ID, and record it as a member of a schema collection.- Parameters:
namespace- the target namespace.systemId- the system ID for the schema. This is used to resolve references to other schemas.parent- the parent collection.
-
XmlSchema
Create a new schema in a collection with a target namespace.- Parameters:
namespace- the target namespace.parent- the containing collection.
-
-
Method Details
-
getAllSchemas
Return an array of DOM documents consisting of this schema and any schemas that it references. Referenced schemas are only returned if theXmlSchemaExternalobjects corresponding to them have their 'schema' fields filled in.- Returns:
- DOM documents.
-
getAttributeByName
Retrieve a global attribute by its QName.- Parameters:
name-- Returns:
- the attribute.
-
getAttributeByName
Look for an attribute by its local name.- Parameters:
name-- Returns:
- the attribute
-
getAttributeFormDefault
- Returns:
- the default attribute form for this schema.
-
getAttributeGroupByName
Retrieve an attribute group by QName.- Parameters:
name-- Returns:
-
getAttributeGroups
Return a map containing all the defined attribute groups of this schema. The keys are QNames, where the namespace will always be the target namespace of this schema. This makes it easier to look up items for cross-schema references.
If org.apache.ws.commons.schema.protectReadOnlyCollections is 'true', this will return a map that checks at runtime.- Returns:
- the map of attribute groups.
-
getAttributes
Return a map containing all the defined attributes of this schema. The keys are QNames, where the namespace will always be the target namespace of this schema. This makes it easier to look up items for cross-schema references.
If org.apache.ws.commons.schema.protectReadOnlyCollections is 'true', this will return a map that checks at runtime.- Returns:
- the map of attributes.
-
getBlockDefault
Return the default block value for this schema.- Returns:
- the default block value.
-
getElementByName
Look for a element by its QName.- Parameters:
name-- Returns:
- the element.
-
getElementByName
get an element by its local name.- Parameters:
name-- Returns:
- the element.
-
getElementFormDefault
- Returns:
- the default element form for this schema.
-
getElements
Return a map containing all the defined elements of this schema. The keys are QNames, where the namespace will always be the target namespace of this schema. This makes it easier to look up items for cross-schema references.
If org.apache.ws.commons.schema.protectReadOnlyCollections is 'true', this will return a map that checks at runtime- Returns:
- the map of elements.
-
getExternals
Return all of the includes, imports, and redefines for this schema.
If org.apache.ws.commons.schema.protectReadOnlyCollections is 'true', this will return a list that checks at runtime- Returns:
- a list of the objects representing includes, imports, and redefines.
-
getFinalDefault
- Returns:
- the default 'final' value for this schema.
-
getGroupByName
Retrieve a group by QName.- Parameters:
name-- Returns:
-
getGroups
Return a map containing all the defined groups of this schema. The keys are QNames, where the namespace will always be the target namespace of this schema. This makes it easier to look up items for cross-schema references.
If org.apache.ws.commons.schema.protectReadOnlyCollections is 'true', this will return a map that checks at runtime- Returns:
- the map of groups.
-
getInputEncoding
Return the character encoding for this schema. This will only be present if either the schema was read from an XML document or there was a call tosetInputEncoding(String).- Returns:
-
getItems
Return all of the global items in this schema.
If org.apache.ws.commons.schema.protectReadOnlyCollections is 'true', this will return a map that checks at runtime.- Returns:
- all of the global items from this schema.
-
getLogicalTargetNamespace
Return the logical target namespace. If a schema document has no target namespace, but it is referenced via an xs:include or xs:redefine, its logical target namespace is the target namespace of the including schema.- Returns:
- the logical target namespace.
-
getNamespaceContext
Returns the objects namespace context.- Specified by:
getNamespaceContextin interfaceNamespaceContextOwner
-
getNotationByName
Retrieve a notation by QName.- Parameters:
name-- Returns:
- the notation
-
getNotations
Return a map containing all the defined notations of this schema. The keys are QNames, where the namespace will always be the target namespace of this schema. This makes it easier to look up items for cross-schema references.
If org.apache.ws.commons.schema.protectReadOnlyCollections is 'true', this will return a map that checks at runtime.- Returns:
- the map of notations.
-
getParent
Return the parent XmlSchemaCollection. If this schema was not initialized in a collection the return value will be null.- Returns:
- the parent collection.
-
getSchemaDocument
Retrieve a DOM tree for this one schema, independent of any included or related schemas.- Returns:
- The DOM document.
- Throws:
XmlSchemaSerializer.XmlSchemaSerializerException
-
getSchemaNamespacePrefix
- Returns:
- the namespace prefix for the target namespace.
-
getSchemaTypes
Return a map containing all the defined types of this schema. The keys are QNames, where the namespace will always be the target namespace of this schema. This makes it easier to look up items for cross-schema references.- Returns:
- the map of types.
-
getTargetNamespace
Return the declared target namespace of this schema.- Returns:
- the namespace URI.
- See Also:
-
getTypeByName
Search this schema, and its peers in its parent collection, for a schema type specified by QName.- Parameters:
name- the type name.- Returns:
- the type.
-
getTypeByName
Retrieve a named type from this schema.- Parameters:
name-- Returns:
- the type.
-
getVersion
Return the declared XML Schema version of this schema. XmlSchema supports only version 1.0.- Returns:
-
setVersion
Set the declared XML Schema version of this schema- Parameters:
version- the new version.
-
setAttributeFormDefault
Set the default attribute form for this schema.- Parameters:
value- the form. This may not be null.
-
setBlockDefault
Set the default block value for this schema.- Parameters:
blockDefault- the new block value.
-
setElementFormDefault
Set the default element form for this schema.- Parameters:
elementFormDefault- the element form. This may not be null.
-
setFinalDefault
Set the default 'final' value for this schema. The value may not be null.- Parameters:
finalDefault- the new final value.
-
setInputEncoding
Set the character encoding name for the schema. This is typically set when reading a schema from an XML file, so that it can be written back out in the same encoding.- Parameters:
encoding- Character encoding name.
-
setNamespaceContext
Sets the schema elements namespace context. This may be used for schema serialization, until a better mechanism was found. -
setSchemaNamespacePrefix
Set the namespace prefix corresponding to the target namespace.- Parameters:
schemaNamespacePrefix-
-
setTargetNamespace
Set the target namespace for this schema.- Parameters:
targetNamespace- the new target namespace URI. A value of "" is ignored.
-
toString
- Overrides:
toStringin classXmlSchemaAnnotated
-
write
Serialize the schema as XML to the specified stream using the encoding established withsetInputEncoding(String).- Parameters:
out- - the output stream to write to- Throws:
UnsupportedEncodingException- for an invalid encoding.
-
write
Serialize the schema as XML to the specified stream using the encoding established withsetInputEncoding(String).- Parameters:
out- - the output stream to write tooptions- - a map of options- Throws:
UnsupportedEncodingException
-
write
Serialize the schema to aWriter.- Parameters:
writer- - the writer to write this
-
write
Serialize the schema to aWriter.- Parameters:
writer- - the writer to write this
-
getAttributeByName
protected XmlSchemaAttribute getAttributeByName(QName name, boolean deep, Stack<XmlSchema> schemaStack) -
getAttributeGroupByName
protected XmlSchemaAttributeGroup getAttributeGroupByName(QName name, boolean deep, Stack<XmlSchema> schemaStack) -
getElementByName
-
getGroupByName
-
getNotationByName
protected XmlSchemaNotation getNotationByName(QName name, boolean deep, Stack<XmlSchema> schemaStack) -
getTypeByName
Protected method that allows safe (non-recursive schema loading). It looks for a type with constraints.- Parameters:
name-deep-schemaStack-- Returns:
- the type.
-
getSyntacticalTargetNamespace
String getSyntacticalTargetNamespace() -
setLogicalTargetNamespace
-
setParent
-
setSyntacticalTargetNamespace
-
getSchema
Get a schema from an import- Parameters:
includeOrImport-- Returns:
- return the schema object.
-
loadDefaultOptions
Load the default options- Parameters:
options- - the map of
-
serializeInternal
serialize the schema - this is the method tht does to work- Parameters:
out-options-
-