public class PreparedSchema extends SchemaStructure implements NotationSet
All components in the schema are indexed by name. In addition, elements, attributes, and types are indexed by their integer NamePool fingerprint.
Construction of the PreparedSchema is not thread-safe; all creation of new components must happen in a single thread.
Modifier and Type | Field and Description |
---|---|
static int |
NAMESPACE_KNOWN |
static int |
NAMESPACE_SEALED |
static int |
NAMESPACE_UNDER_CONSTRUCTION |
static int |
NAMESPACE_UNKNOWN |
Modifier | Constructor and Description |
---|---|
protected |
PreparedSchema()
Create a dummy schema definition.
|
|
PreparedSchema(EnterpriseConfiguration config)
Create a new Schema definition
|
Modifier and Type | Method and Description |
---|---|
void |
addAnonymousType(SchemaType type)
Register an anonymous type defined in this schema
|
void |
addAttributeDecl(AttributeDecl attribute)
Adds the given global attribute declaration to this Schema.
|
void |
addAttributeGroup(AttributeGroupDecl attributeGroup)
Adds the given attribute group declaration to this Schema.
|
void |
addComponent(UserSchemaComponent obj)
Add an object that might contain a forwards reference to be fixed up later
|
void |
addElementDecl(ElementDecl elementDecl)
Adds the given global element declaration to this Schema definition
|
void |
addGlobalParam(GlobalParam param)
Declare a global parameter for XPath expressions in this schema document (Saxon extension)
|
void |
addGroup(ModelGroupDefinition group)
Adds the given group (xs:group) to this Schema.
|
void |
addIdentityConstraint(IdentityConstraint constraint)
Add an identity constraint
|
void |
addNotation(Notation notation)
Adds the given Notation declaration to this Schema defintion
|
void |
addType(SchemaType type)
Adds the given type definition to this Schema.
|
void |
copyTo(PreparedSchema destination,
SchemaCompiler compiler)
Copy the components of this schema to another schema
|
AttributeDecl |
getAttributeDecl(int fingerprint)
Get the attribute declaration with a given name if there is one.
|
AttributeDecl |
getAttributeDecl(StructuredQName name)
Get the attribute declaration with a given name if there is one.
|
AttributeGroupDecl |
getAttributeGroup(StructuredQName name)
Get the attribute declaration with a given name if there is one.
|
EnterpriseConfiguration |
getConfiguration()
Get the configuration
|
ElementDecl |
getElementDecl(int fingerprint)
Get the global element declaration with a given fingerprint
|
ElementDecl |
getElementDecl(StructuredQName name)
Get the global element declaration with a given name
|
java.util.Set<UserComplexType> |
getExtensionsOfBuiltInType(int fp)
Get the set of user-defined complex types that extend a given built-in type
|
GlobalParam |
getGlobalParam(StructuredQName name)
Get the GlobalParam object representing a named parameter (Saxon extension)
|
java.util.Collection<GlobalParam> |
getGlobalParams()
Return the set of global parameters defined in this schema document
|
ModelGroupDefinition |
getGroup(StructuredQName name)
Get the model group with a given name if there is one.
|
IdentityConstraint |
getIdentityConstraint(StructuredQName name)
Get the identity constraint whose name has a given fingerprint
|
int |
getLocalLicenseId()
Get the local license id, identifying any local license in the case
where this package was loaded from a compiled package that contained its own
embedded license
|
NamePool |
getNamePool()
Get the NamePool used by this schema
|
Notation |
getNotation(StructuredQName notationName)
Get the notation with a given name
|
SchemaType |
getSchemaType(StructuredQName name)
Get the type with a given name if there is one.
|
SimpleType |
getSimpleType(StructuredQName name)
Get the simple type with a given name if there is one.
|
java.util.Set<java.lang.String> |
getTargetNamespaces()
Get the set of all target namespaces of components present in this schema
|
SchemaType |
getType(StructuredQName name)
Get type defined in this schema, searching both named and anonymous types
|
boolean |
isDeclaredNotation(java.lang.String uri,
java.lang.String local)
Ask whether a given notation name is present in this set of notations
|
java.util.Iterator<AttributeDecl> |
iterateAttributeDeclarations()
Get an iterator over all the global attribute declarations defined in this schema
|
java.util.Iterator<AttributeGroupDecl> |
iterateAttributeGroups()
Get an iterator over all the named attribute groups defined in this schema
|
java.util.Iterator<ElementDecl> |
iterateElementDeclarations()
Get an iterator over all the global element declarations defined in this schema.
|
java.util.Iterator<IdentityConstraint> |
iterateIdentityConstraints()
Get an iterator over all the identity constraints defined in this schema
(that is, unique, key, and keyref components).
|
java.util.Iterator<ModelGroupDefinition> |
iterateModelGroups()
Get an iterator over all the named model groups defined in this schema
|
java.util.Iterator<Notation> |
iterateNotations()
Get an iterator over all the notations defined in this schema.
|
java.util.Iterator<SchemaType> |
iterateTypes()
Get an iterator over all the named simple and complex types defined in this schema.
|
static PreparedSchema |
merge(PreparedSchema ps1,
PreparedSchema ps2)
Merge two PreparedSchemas into one, rejecting any components that are defined
in both.
|
void |
registerExtensionOfBuiltInType(int fp,
UserComplexType extension)
Register a complex type that extends a built-in simple type
|
void |
setConfiguration(EnterpriseConfiguration config)
Set the configuration
|
void |
setLocalLicenseId(int id)
Set the local license id, identifying any local license in the case
where this package was loaded from a compiled package that contained its own
embedded license
|
boolean |
validate(SchemaCompiler compiler)
Checks the validity of this Schema definition, and if valid, adds the schema to the
cache held by the EnterpriseConfiguration
|
static SchemaComponent |
validateReference(ComponentReference ref,
SchemaCompiler compiler,
boolean fatal)
Helper method to validate that a reference to a schema component can be resolved
|
elaborate, fixup, getColumnNumber, getFixupStatus, getGeneratedId, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, hasSameLocation, isValidationNeeded, lookForCycles, makeXPathExpressionPropertyRecord, saveLocation, setFixupStatus, setGeneratedId, setLineNumber, setLocator, setRedefinitionLevel, setSchemaDocumentURI, setSystemId, setValidationStatus
public static final int NAMESPACE_UNKNOWN
public static final int NAMESPACE_UNDER_CONSTRUCTION
public static final int NAMESPACE_KNOWN
public static final int NAMESPACE_SEALED
protected PreparedSchema()
public PreparedSchema(EnterpriseConfiguration config)
config
- The configuration object holding system configuration informationpublic void setConfiguration(EnterpriseConfiguration config)
setConfiguration
in class SchemaStructure
config
- the Saxon configurationpublic EnterpriseConfiguration getConfiguration()
getConfiguration
in class SchemaStructure
public void setLocalLicenseId(int id)
id
- identifier used to distinguish this local licensepublic int getLocalLicenseId()
public void addComponent(UserSchemaComponent obj)
obj
- the component to be added. The caller should ensure that the same component
is not added twice.public AttributeDecl getAttributeDecl(StructuredQName name)
name
- the name of the required attribute declarationpublic AttributeDecl getAttributeDecl(int fingerprint)
fingerprint
- the NamePool fingerprint of the name of the required attribute declarationpublic java.util.Iterator<AttributeDecl> iterateAttributeDeclarations()
AttributeDecl
public void addAttributeDecl(AttributeDecl attribute)
attribute
- the AttributeDecl to addpublic AttributeGroupDecl getAttributeGroup(StructuredQName name)
name
- the name of the required attribute grouppublic java.util.Iterator<AttributeGroupDecl> iterateAttributeGroups()
AttributeGroupDecl
public void addAttributeGroup(AttributeGroupDecl attributeGroup)
attributeGroup
- the AttributeDecl to addpublic ModelGroupDefinition getGroup(StructuredQName name)
name
- the name of the required named model grouppublic java.util.Iterator<ModelGroupDefinition> iterateModelGroups()
ModelGroupDefinition
public void addGroup(ModelGroupDefinition group)
group
- the group to addpublic SchemaType getSchemaType(StructuredQName name)
name
- the name of the required schema typepublic SimpleType getSimpleType(StructuredQName name)
name
- the name of the required simple typepublic java.util.Iterator<SchemaType> iterateTypes()
SchemaType
public void addType(SchemaType type)
type
- the type to add to this Schemapublic void addAnonymousType(SchemaType type)
type
- the anonymous type to be addedpublic SchemaType getType(StructuredQName name)
name
- the name of the required schema typepublic void registerExtensionOfBuiltInType(int fp, UserComplexType extension)
fp
- the fingerprint of the built-in typeextension
- the complex type that extends the built-in (directly or indirectly)public java.util.Set<UserComplexType> getExtensionsOfBuiltInType(int fp)
fp
- the fingerprint of the built-in typepublic void addElementDecl(ElementDecl elementDecl)
elementDecl
- the ElementDecl to add to this Schemapublic ElementDecl getElementDecl(StructuredQName name)
name
- the name of the elementpublic ElementDecl getElementDecl(int fingerprint)
fingerprint
- the NamePool fingerprint of the name of the elementpublic java.util.Iterator<ElementDecl> iterateElementDeclarations()
ElementDecl
public void addNotation(Notation notation)
notation
- the Notation to add to this Schemapublic Notation getNotation(StructuredQName notationName)
notationName
- identifies the name of the notationpublic java.util.Iterator<Notation> iterateNotations()
Notation
public void addIdentityConstraint(IdentityConstraint constraint)
constraint
- the identity constraint to be addedpublic IdentityConstraint getIdentityConstraint(StructuredQName name)
name
- the name of the required constraintpublic java.util.Iterator<IdentityConstraint> iterateIdentityConstraints()
IdentityConstraint
public java.util.Set<java.lang.String> getTargetNamespaces()
public NamePool getNamePool()
public void addGlobalParam(GlobalParam param) throws SchemaException
param
- the details of the parameterSchemaException
public GlobalParam getGlobalParam(StructuredQName name)
name
- the parameter namepublic java.util.Collection<GlobalParam> getGlobalParams()
public void copyTo(PreparedSchema destination, SchemaCompiler compiler) throws SchemaException
destination
- the destination of the copycompiler
- used for error reportingSchemaException
- if there are name clashes between this
schema and the destination schema (that is, the same name used to refer to different components.
Components are compared by checking their name and origin, where the origin is the SystemId and
line number of the schema document from which they were initially derived)public boolean validate(SchemaCompiler compiler) throws SchemaException
compiler
- a SchemaCompiler to which all errors should be reportedSchemaException
- if the SchemaCompiler decides that an error is fatalpublic static SchemaComponent validateReference(ComponentReference ref, SchemaCompiler compiler, boolean fatal) throws SchemaException
ref
- The Component reference that needs to be resolvedcompiler
- used for error reportingfatal
- True if failure to resolve the reference is an error rather than a warningSchemaException
- if the reference cannot be resolvedpublic static PreparedSchema merge(PreparedSchema ps1, PreparedSchema ps2) throws SchemaException
ps1
- the first PreparedSchemaps2
- the second PreparedSchemaSchemaException
- if there are inconsistencies between the two schemas,
for example different components with the same namepublic boolean isDeclaredNotation(java.lang.String uri, java.lang.String local)
NotationSet
isDeclaredNotation
in interface NotationSet
uri
- the URI part of the notation namelocal
- the local part of the notation nameCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.