Package com.saxonica.ee.schema
Class KeyRef
- java.lang.Object
-
- com.saxonica.ee.schema.SchemaStructure
-
- com.saxonica.ee.schema.IdentityConstraint
-
- com.saxonica.ee.schema.KeyRef
-
- All Implemented Interfaces:
ComponentReference
,SerializableSchemaComponent
,UserSchemaComponent
,javax.xml.transform.SourceLocator
,Location
,SchemaComponent
,org.xml.sax.Locator
public class KeyRef extends IdentityConstraint implements ComponentReference
This class represents an xs:keyRef identity constraint in a schema
-
-
Constructor Summary
Constructors Constructor Description KeyRef()
Create a KeyRef object representing an xs:keyref constraintsKeyRef(EnterpriseConfiguration config, StructuredQName refer)
Create a new KeyRef Identity-Constraint.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
fixup(SchemaCompiler compiler)
Check references from this component to other componentsjava.lang.String
getConstraintCategory()
The type of constraint: one of "key", "unique", or "keyref"int
getSymbolSpace()
Get the symbol space of the target of this referenceSchemaComponent
getTarget()
Get the schema component identified by this reference.StructuredQName
getTargetComponentName()
Get the name of the target of this referenceboolean
isDangling()
Ask whether this is known to be a dangling referenceboolean
isResolved()
Determine whether this reference has been resolvedvoid
setTargetComponentName(StructuredQName target)
Sets the name of the key being referenced.void
setTargetKey(IdentityConstraint key)
Set the target key or unique constraintvoid
tryToResolve(SchemaCompiler compiler, boolean fatal)
Try to resolve the reference if possible, relative to components present in a given schema.boolean
validate(SchemaCompiler compiler)
Checks the validity of this Schema defintion.-
Methods inherited from class com.saxonica.ee.schema.IdentityConstraint
addField, elaborate, getComponentAsFunction, getConstraintName, getFields, getName, getSelector, getTargetNamespace, isOrdered, isSameDeclaration, serialize, setConstraintName, setOrdered, setSelector, typeCheck
-
Methods inherited from class com.saxonica.ee.schema.SchemaStructure
getColumnNumber, getConfiguration, getFixupStatus, getGeneratedId, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, hasSameLocation, isValidationNeeded, lookForCycles, makeXPathExpressionPropertyRecord, saveLocation, setConfiguration, setFixupStatus, setGeneratedId, setLineNumber, setLocator, setRedefinitionLevel, setSchemaDocumentURI, setSystemId, setValidationStatus
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.saxonica.ee.schema.ComponentReference
getConfiguration
-
Methods inherited from interface net.sf.saxon.s9api.Location
getColumnNumber, getLineNumber, getPublicId, getSystemId, saveLocation
-
Methods inherited from interface net.sf.saxon.type.SchemaComponent
getRedefinitionLevel, getValidationStatus
-
Methods inherited from interface com.saxonica.ee.schema.UserSchemaComponent
lookForCycles
-
-
-
-
Constructor Detail
-
KeyRef
public KeyRef()
Create a KeyRef object representing an xs:keyref constraints
-
KeyRef
public KeyRef(EnterpriseConfiguration config, StructuredQName refer)
Create a new KeyRef Identity-Constraint.- Parameters:
config
- the configurationrefer
- the name of the referenced key.
-
-
Method Detail
-
getConstraintCategory
public java.lang.String getConstraintCategory()
Description copied from class:IdentityConstraint
The type of constraint: one of "key", "unique", or "keyref"- Specified by:
getConstraintCategory
in classIdentityConstraint
- Returns:
- one of "key", "unique", or "keyref" (note the spelling)
-
getTargetComponentName
public StructuredQName getTargetComponentName()
Get the name of the target of this reference- Specified by:
getTargetComponentName
in interfaceComponentReference
- Returns:
- the component name
-
setTargetComponentName
public void setTargetComponentName(StructuredQName target)
Sets the name of the key being referenced.- Parameters:
target
- the fingerprint of the name of the key to reference.
-
setTargetKey
public void setTargetKey(IdentityConstraint key)
Set the target key or unique constraint- Parameters:
key
- the target key definition or unique constraint
-
tryToResolve
public void tryToResolve(SchemaCompiler compiler, boolean fatal)
Try to resolve the reference if possible, relative to components present in a given schema. No error occurs if the reference cannot yet be resolved.- Specified by:
tryToResolve
in interfaceComponentReference
- Parameters:
compiler
- The schema containing the candidate target components for the reference. If null, the schema containing the reference is used.fatal
- true if a failure to resolve is to be treated as fatal
-
isResolved
public boolean isResolved()
Determine whether this reference has been resolved- Specified by:
isResolved
in interfaceComponentReference
- Returns:
- true if the reference has been resolved to a schema component
-
isDangling
public boolean isDangling()
Ask whether this is known to be a dangling reference- Specified by:
isDangling
in interfaceComponentReference
- Returns:
- true if the target of this component reference is known to be absent, and if a warning has been issued to this effect
-
getTarget
public SchemaComponent getTarget() throws MissingComponentException
Get the schema component identified by this reference.- Specified by:
getTarget
in interfaceComponentReference
- Returns:
- the schema component if the reference has been resolved.
- Throws:
MissingComponentException
- if the reference has not been resolved. Note that this is an unchecked exception.
-
getSymbolSpace
public int getSymbolSpace()
Get the symbol space of the target of this reference- Specified by:
getSymbolSpace
in interfaceComponentReference
- Returns:
- an integer code identifying the symbol space
-
fixup
public boolean fixup(SchemaCompiler compiler) throws SchemaException
Check references from this component to other components- Specified by:
fixup
in interfaceUserSchemaComponent
- Overrides:
fixup
in classIdentityConstraint
- Parameters:
compiler
- used for reporting error messages- Returns:
- true if all is well, false if errors found
- Throws:
SchemaException
-
validate
public boolean validate(SchemaCompiler compiler) throws SchemaException
Checks the validity of this Schema defintion.- Specified by:
validate
in interfaceUserSchemaComponent
- Overrides:
validate
in classIdentityConstraint
- Parameters:
compiler
- the schema compiler- Returns:
- true when this Schema definition is valid, otherwise false.
- Throws:
SchemaException
- when this Schema definition is invalid.
-
-