com.saxonica.schema

## Class IdentityConstraint

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

- All Implemented Interfaces:
    SerializableSchemaComponent, UserSchemaComponent, Serializable, SourceLocator, SchemaComponent
  Direct Known Subclasses:
    Key, KeyRef, Unique

      public abstract class IdentityConstraint
      extends SchemaStructure
      implements UserSchemaComponent, SerializableSchemaComponent

  The base class for the XML Schema Identity Constraints (key, keyref, unique).
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from interface net.sf.saxon.type.SchemaComponent

      `COMPONENT_FUNCTION_TYPE, FIXED_UP, INCOMPLETE, INVALID, UNVALIDATED, VALIDATED, VALIDATING`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `IdentityConstraint()` Constructor used by sub-classes.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addField(IdentityField field)` Adds the given IdentityField to this IdentityConstraint
    `void` | `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)` Check references from this component to other components
    `FunctionItem` | `getComponentAsFunction()` Get the schema component in the form of a function item.
    `List<IdentityField>` | `getFields()` Returns the List of Fields contained within this IdentityConstraint.
    `int` | `getFingerprint()` Get the fingerprint of the name of this identity constraint
    `String` | `getName()` Return the name of this IdentityConstraint.
    `IdentitySelector` | `getSelector()` Returns the selector of this IdentityConstraint.
    `String` | `getTargetNamespace()` Return the target namespace of this IdentityConstraint.
    `void` | `serialize(SchemaModelSerializer serializer)` Serialize the identity constraint as part of the serialized Schema Component Model
    `void` | `setNameCode(int nc)` Set the integer cdde of the name of this identity constraint
    `void` | `setSelector(IdentitySelector selector)` Sets the selector for this IdentityConstraint.
    `void` | `typeCheck(SchemaCompiler compiler, SchemaType contextType)` Typecheck the selector and the fields.
    `boolean` | `validate(SchemaCompiler compiler)` Checks the validity of this Schema defintion.

    - ### Methods inherited from class com.saxonica.schema.SchemaStructure

      `getColumnNumber, getConfiguration, getFixupStatus, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, lookForCycles, makeXPathExpressionPropertyRecord, setConfiguration, setFixupStatus, 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.schema.UserSchemaComponent

      `lookForCycles`

    - ### Methods inherited from interface net.sf.saxon.type.SchemaComponent

      `getRedefinitionLevel, getValidationStatus`

- - ### Constructor Detail

    - #### IdentityConstraint

          protected IdentityConstraint()

      Constructor used by sub-classes. Creates a new IdentityConstraint.

  - ### Method Detail

    - #### addField

          public void addField(IdentityField field)

      Adds the given IdentityField to this IdentityConstraint
      Parameters:
        `field` - the IdentityField to add.

    - #### getFields

          public List<IdentityField> getFields()

      Returns the List of Fields contained within this IdentityConstraint.
      Returns:
        the List of fields

    - #### getName

          public String getName()

      Return the name of this IdentityConstraint. This value will never be null.
      Returns:
        the name of this IdentityConstraint

    - #### getTargetNamespace

          public String getTargetNamespace()

      Return the target namespace of this IdentityConstraint.
      Returns:
        the target namespace of this IdentityConstraint. Return null if the target namespace is "absent".

    - #### getSelector

          public IdentitySelector getSelector()

      Returns the selector of this IdentityConstraint.
      Returns:
        the IdentitySelector of this IdentityConstraint

    - #### setSelector

          public void setSelector(IdentitySelector selector)
                           throws SchemaException

      Sets the selector for this IdentityConstraint.
      Parameters:
        `selector` - the Selector for this IdentityConstraint. Must not be null.
      Throws:
        `SchemaException` - if selector is null.

    - #### setNameCode

          public void setNameCode(int nc)

      Set the integer cdde of the name of this identity constraint
      Parameters:
        `nc` - the namecode

    - #### getFingerprint

          public int getFingerprint()

      Get the fingerprint of the name of this identity constraint
      Returns:
        the integer fingerprint of the component's name

    - #### 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 `SchemaStructure`
      Parameters:
        `compiler` - the schema 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`
      Returns:
        true when this Schema definition is valid, otherwise false.
      Throws:
        `SchemaException`

    - #### typeCheck

          public void typeCheck(SchemaCompiler compiler,
                       SchemaType contextType)
                         throws XPathException

      Typecheck the selector and the fields. This reports warnings if the XPath expressions used in defining the constraint cannot select anything, or under similar conditions
      Parameters:
        `compiler` - the schema compiler
        `contextType` - the type of the element whose constraint is being defined
      Throws:
        `XPathException` - if a type error is found

    - #### elaborate

          public void elaborate(SchemaCompiler compiler)
                         throws SchemaException

      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 interface `UserSchemaComponent`
      Overrides:
        `elaborate` in class `SchemaStructure`
      Parameters:
        `compiler` - the schema compiler
      Throws:
        `SchemaException`

    - #### serialize

          public void serialize(SchemaModelSerializer serializer)
                         throws XPathException

      Serialize the identity constraint as part of the serialized Schema Component Model
      Specified by:
        `serialize` in interface `SerializableSchemaComponent`
      Parameters:
        `serializer` - the object responsible for performing the serialization
      Throws:
        `XPathException` - if serialization fails

    - #### getComponentAsFunction

          public FunctionItem 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 interface `SchemaComponent`
      Returns:
        the schema component represented as a function from property names to property values.

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.