## com.saxonica.schema
Class KeyRef

    java.lang.Object
      com.saxonica.schema.SchemaStructure
          com.saxonica.schema.IdentityConstraint
              com.saxonica.schema.KeyRef

All Implemented Interfaces:
  ComponentReference, SerializableSchemaComponent, UserSchemaComponent, Serializable, SourceLocator, SchemaComponent

    public class KeyRef

extends IdentityConstraint
implements ComponentReference

This class represents an xs:keyRef identity constraint in a schema

See Also:
  Serialized Form

Field Summary

Fields inherited from interface net.sf.saxon.type.SchemaComponent
`FIXED_UP, INCOMPLETE, INVALID, UNVALIDATED, VALIDATED, VALIDATING`

Fields inherited from interface com.saxonica.schema.SerializableSchemaComponent
`ALL_COMPOSITOR, ATOMIC_TYPE, ATTRIBUTE_DECL, ATTRIBUTE_GROUP, ATTRIBUTE_GROUP_REF, ATTRIBUTE_USE, ATTRIBUTE_WILDCARD, CHOICE_COMPOSITOR, COMPLEX_TYPE, ELEMENT_DECL, ELEMENT_PARTICLE, ELEMENT_WILDCARD, FACET, KEY, KEYREF, LIST_TYPE, MODEL_GROUP, MODEL_GROUP_REF, NOTATION, SEQUENCE_COMPOSITOR, UNION_TYPE, UNIQUE`

Constructor Summary
`KeyRef(String name, int refer)` Create a new KeyRef Identity-Constraint.

Method Summary
`boolean` `fixup(SchemaCompiler compiler)` Check references from this component to other components
`int` `getComponentTypeCode()` Get a unique number identifying the type of component
`int` `getReferFingerprint()` Gets the fingerprint of the name of the key being referenced).
`int` `getSymbolSpace()` Get the symbol space of the target of this reference
`SchemaComponent` `getTarget()` Get the schema component identified by this reference.
`boolean` `isResolved()` Determine whether this reference has been resolved
`void` `serialize(SchemaSerializer serializer)` Serialize the schema component
`void` `setReferFingerprint(int referFingerprint)` Sets the fingerprint of the name of the key being referenced.
`void` `tryToResolve(SchemaCompiler compiler)` 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.schema.IdentityConstraint
`addField, getFields, getFingerprint, getName, getSelector, iterateFields, setFingerprint, setName, setSelector, typeCheck`

Methods inherited from class com.saxonica.schema.SchemaStructure
`getColumnNumber, getConfiguration, getFixupStatus, getLineNumber, getPublicId, getSystemId, getValidationStatus, lookForCycles, setConfiguration, setFixupStatus, setLineNumber, setLocator, setSystemId, setValidationStatus`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.saxonica.schema.ComponentReference
`getConfiguration, getFingerprint`

Methods inherited from interface javax.xml.transform.SourceLocator
`getColumnNumber, getLineNumber, getPublicId, getSystemId`

Methods inherited from interface com.saxonica.schema.UserSchemaComponent
`lookForCycles`

Methods inherited from interface net.sf.saxon.type.SchemaComponent
`getValidationStatus`

Constructor Detail

### KeyRef

    public KeyRef(String name,
                  int refer)
           throws SchemaException

  Create a new KeyRef Identity-Constraint.

  Parameters:
    `name` - the name for the IdentityConstraint. Must not be null.
  Throws:
    `SchemaException`

Method Detail

### getReferFingerprint

    public int getReferFingerprint()

  Gets the fingerprint of the name of the key being referenced).

  Returns:
    the fingerprint of the name of the key to reference.

### setReferFingerprint

    public void setReferFingerprint(int referFingerprint)

  Sets the fingerprint of the name of the key being referenced.

  Parameters:
    `referFingerprint` - the fingerprint of the name of the key to reference.

### tryToResolve

    public void tryToResolve(SchemaCompiler compiler)

  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 interface `ComponentReference`
  Parameters:
    `compiler` - The schema containing the candidate target components for the reference. If null, the schema containing the reference is used.

### isResolved

    public boolean isResolved()

  Determine whether this reference has been resolved

  Specified by:
    `isResolved` in interface `ComponentReference`

### getTarget

    public SchemaComponent getTarget()
                              throws UnresolvedReferenceException

  Get the schema component identified by this reference.

  Specified by:
    `getTarget` in interface `ComponentReference`
  Returns:
    the schema component if the reference has been resolved.
  Throws:
    `UnresolvedReferenceException` - 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 interface `ComponentReference`

### fixup

    public boolean fixup(SchemaCompiler compiler)
                  throws SchemaException

  Check references from this component to other components

  Specified by:
    `fixup` in interface `UserSchemaComponent`
  Overrides:
    `fixup` in class `IdentityConstraint`
  Parameters:
    `compiler` -
  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 interface `UserSchemaComponent`
  Overrides:
    `validate` in class `IdentityConstraint`
  Returns:
    true when this Schema definition is valid, otherwise false.
  Throws:
    `SchemaException` - when this Schema definition is invalid.

### serialize

    public void serialize(SchemaSerializer serializer)
                   throws IOException

  Serialize the schema component

  Specified by:
    `serialize` in interface `SerializableSchemaComponent`
  Throws:
    `IOException`

### getComponentTypeCode

    public int getComponentTypeCode()

  Get a unique number identifying the type of component

  Specified by:
    `getComponentTypeCode` in interface `SerializableSchemaComponent`

Copyright (C) Michael H. Kay. All rights reserved.