Package com.saxonica.ee.schema
Class SchemaStructure
java.lang.Object
com.saxonica.ee.schema.SchemaStructure
- All Implemented Interfaces:
UserSchemaComponent
,SourceLocator
,Location
,SchemaComponent
,Locator
- Direct Known Subclasses:
Assertion
,AttributeDecl
,AttributeGroupDecl
,AttributeGroupReference
,AttributeWildcard
,ElementDecl
,FieldOrSelector
,IdentityConstraint
,IdentityConstraintReference
,ModelGroup
,Notation
,SimpleComponentReference
,TypeAlternative
,TypeReference
,UserDefinedType
,Wildcard
The base class for all XML Schema stuctures. Generally represents a schema component
in the sense of the XML Schema specification, though the correspondence is not always
one to one. Maintains information about the location of the schema construct in an
XML Schema document, for diagnostic purposes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
elaborate
(SchemaCompiler compiler) Elaborate the schema component: after reloading a serialized schema component model, this expands the component with derived information needed during validation episodes.boolean
fixup
(SchemaCompiler compiler) Fixup references from this schema component to othersint
Get the column number of the element defining this schema component.Get the schema component in the form of a function item.Get the schema containing this structureGet the current fixup statusGet the generated ID, used to test whether two components are "identical"int
Get the line number of the element defining this schema component, within its module.Get the public ID of the containing module, if known.int
Get the redefinition level.Get the base URI of the containing xs:schema element.Get the system identifier (URI) of the schema module (XML document) containing the definition of this component.Get the current validation statusboolean
hasSameLocation
(SchemaStructure other) Ask whether this schema component should be considered identical to another schema componentboolean
Ask if validation is neededvoid
lookForCycles
(Stack<SchemaComponent> references, SchemaCompiler compiler) This method is called to look for cycles.protected static FunctionItem
makeXPathExpressionPropertyRecord
(String conditionText, NamespaceResolver nsResolver, String baseURI) Helper method to make an XPathExpression property recordGet an immutable copy of this Location object.void
Set the configuration containing this structurevoid
setFixupStatus
(SchemaValidationStatus status) Set the fixup statusvoid
setGeneratedId
(String generatedId) Set the generated ID, used to test whether two components are "identical"void
setLineNumber
(int lineNumber) Set the line numbervoid
setLocator
(SourceLocator locator) Set the location information for this schema component.void
setRedefinitionLevel
(int level) Set the redefinition level.void
Set the base URI of the containing xs:schema element.void
setSystemId
(String systemId) Set the system Idvoid
Set the validation statusboolean
validate
(SchemaCompiler compiler) Checks the validity of this Schema component.
-
Constructor Details
-
SchemaStructure
public SchemaStructure()
-
-
Method Details
-
getSystemId
Get the system identifier (URI) of the schema module (XML document) containing the definition of this component.- Specified by:
getSystemId
in interfaceLocation
- Specified by:
getSystemId
in interfaceLocator
- Specified by:
getSystemId
in interfaceSourceLocator
- Returns:
- the URI of the containing module.
-
getPublicId
Get the public ID of the containing module, if known.- Specified by:
getPublicId
in interfaceLocation
- Specified by:
getPublicId
in interfaceLocator
- Specified by:
getPublicId
in interfaceSourceLocator
- Returns:
- This information is not currently maintained, the method always returns null.
-
getLineNumber
public int getLineNumber()Get the line number of the element defining this schema component, within its module. This will be as delivered by the SAX2 parser: that is, the line number of an element is generally the line number on which its start tag ends.- Specified by:
getLineNumber
in interfaceLocation
- Specified by:
getLineNumber
in interfaceLocator
- Specified by:
getLineNumber
in interfaceSourceLocator
- Returns:
- the line number where the relevant element can be found.
-
getColumnNumber
public int getColumnNumber()Get the column number of the element defining this schema component.- Specified by:
getColumnNumber
in interfaceLocation
- Specified by:
getColumnNumber
in interfaceLocator
- Specified by:
getColumnNumber
in interfaceSourceLocator
- Returns:
- -1: this information is not maintained.
-
saveLocation
Get an immutable copy of this Location object. By default Location objects may be mutable, so they should not be saved for later use. The result of this operation holds the same location information, but in an immutable form.- Specified by:
saveLocation
in interfaceLocation
- Returns:
- an immutable copy (which may be the original object, if it is already immutable)
-
setLocator
Set the location information for this schema component.- Parameters:
locator
- the location information.
-
setSystemId
Set the system Id- Parameters:
systemId
- the systemId (the URI of the schema document in which the component is declared)
-
setLineNumber
public void setLineNumber(int lineNumber) Set the line number- Parameters:
lineNumber
- the line number of the declaration of the component within its schema document
-
setSchemaDocumentURI
Set the base URI of the containing xs:schema element. This will normally be the same as the systemId, unless the schema document is made up of multiple XML entities- Parameters:
uri
- the base URI of the schema document
-
getSchemaDocumentURI
Get the base URI of the containing xs:schema element. This will normally be the same as the systemId, unless the schema document is made up of multiple XML entities- Returns:
- the base URI of the containing schema document
-
setGeneratedId
Set the generated ID, used to test whether two components are "identical"- Parameters:
generatedId
- the ID acting as a unique identifier
-
getGeneratedId
Get the generated ID, used to test whether two components are "identical"- Returns:
- the generated ID
-
validate
Checks the validity of this Schema component.- Specified by:
validate
in interfaceUserSchemaComponent
- Parameters:
compiler
- the schema compiler- Returns:
- true when this Schema definition is valid, otherwise false.
- Throws:
SchemaException
- if the ErrorListener decides that an error is fatal.
-
getComponentAsFunction
Description copied from interface:SchemaComponent
Get the schema component in the form of a function item. This allows schema information to be made visible to XSLT or XQuery code. The function makes available the contents of the schema component as defined in the XSD specification. The function takes a string as argument representing a property name, and returns the corresponding property of the schema component. There is also a property "class" which returns the kind of schema component, for example "Attribute Declaration".- Specified by:
getComponentAsFunction
in interfaceSchemaComponent
- Returns:
- the schema component represented as a function from property names to property values.
-
getValidationStatus
Get the current validation status- Specified by:
getValidationStatus
in interfaceSchemaComponent
- Returns:
- an integer code indicating whether validation has not yet been started, is underway, has completed successfully, or has completed unsuccessfully
-
isValidationNeeded
public boolean isValidationNeeded()Ask if validation is needed- Returns:
- true if the component has not yet been validated
-
setValidationStatus
Set the validation status- Parameters:
status
- an integer code indicating whether validation has not yet been started, is underway, has completed successfully, or has completed unsuccessfully
-
getFixupStatus
Get the current fixup status- Returns:
- an integer code indicating whether fixup of component references has not yet been started, is underway, has completed successfully, or has completed unsuccessfully
-
setFixupStatus
Set the fixup status- Parameters:
status
- an integer code indicating whether fixup of component references has not yet been started, is underway, has completed successfully, or has completed unsuccessfully
-
setConfiguration
Set the configuration containing this structure- Parameters:
config
- the Saxon configuration
-
getConfiguration
Get the schema containing this structure- Returns:
- the Saxon configuration
-
setRedefinitionLevel
public void setRedefinitionLevel(int level) Set the redefinition level. This is zero for a component that has not been redefined; for a redefinition of a level-0 component, it is 1; for a redefinition of a level-N component, it is N+1. This concept is used to support the notion of "pervasive" redefinition: if a component is redefined at several levels, the top level wins, but it is an error to have two versions of the component at the same redefinition level.- Parameters:
level
- the redefinition level
-
getRedefinitionLevel
public int getRedefinitionLevel()Get the redefinition level. This is zero for a component that has not been redefined; for a redefinition of a level-0 component, it is 1; for a redefinition of a level-N component, it is N+1. This concept is used to support the notion of "pervasive" redefinition: if a component is redefined at several levels, the top level wins, but it is an error to have two versions of the component at the same redefinition level.- Specified by:
getRedefinitionLevel
in interfaceSchemaComponent
- Returns:
- the redefinition level
-
lookForCycles
public void lookForCycles(Stack<SchemaComponent> references, SchemaCompiler compiler) throws SchemaException This method is called to look for cycles. The object implementing this method is required (a) to raise an exception if the object itself appears in the list of references, (b) to add itself to the list of references, and (c) to call the lookForCycles method on all the objects that it references. This is a dummy implementation that does nothing; it must be overridden for components that can participate in cycles.- Specified by:
lookForCycles
in interfaceUserSchemaComponent
- Parameters:
references
- A stack of objects that contain direct or indirect references to this object, and that must therefore not be referred to from this object.compiler
- the schema compiler- Throws:
SchemaException
- if cycles are found
-
fixup
Fixup references from this schema component to others- Specified by:
fixup
in interfaceUserSchemaComponent
- Parameters:
compiler
- the SchemaCompiler, used primarily for reporting errors- Returns:
- true if all references were fixed up successfully, false if dangling references were found
- Throws:
SchemaException
-
elaborate
Elaborate the schema component: after reloading a serialized schema component model, this expands the component with derived information needed during validation episodes. The model is assumed to be valid.- Specified by:
elaborate
in interfaceUserSchemaComponent
- Parameters:
compiler
- the schema compiler- Throws:
SchemaException
-
makeXPathExpressionPropertyRecord
protected static FunctionItem makeXPathExpressionPropertyRecord(String conditionText, NamespaceResolver nsResolver, String baseURI) Helper method to make an XPathExpression property record- Returns:
- a function that delivers the information in this component
-
hasSameLocation
Ask whether this schema component should be considered identical to another schema component- Parameters:
other
- the other schema component- Returns:
- true if (on balance of probabilities...) these two structures represent the same schema component. This is considered to be the case if they appear to derive from the same source declaration
-