## net.sf.saxon.trans
Class KeyDefinition

    java.lang.Object
      net.sf.saxon.instruct.Procedure
          net.sf.saxon.trans.KeyDefinition

All Implemented Interfaces:
  Serializable, SourceLocator, LocationProvider, Container, InstructionInfoProvider

    public class KeyDefinition

extends Procedure
implements Serializable, InstructionInfoProvider

Corresponds to a single xsl:key declaration.

Author:
  Michael H. Kay
See Also:
  Serialized Form

Constructor Summary
`KeyDefinition(PatternFinder match, SequenceIterable use, String collationName, StringCollator collation)` Constructor to create a key definition

Method Summary
`StringCollator` `getCollation()` Get the collation.
`String` `getCollationName()` Get the collation name for this key definition.
`BuiltInAtomicType` `getIndexedItemType()` Get the primitive item type of the values returned by the use expression
`InstructionInfo` `getInstructionInfo()` Get the InstructionInfo details about the construct.
`PatternFinder` `getMatch()` Get the match pattern for the key definition
`SequenceIterable` `getUse()` Get the use expression for the key definition
`boolean` `isBackwardsCompatible()` Test backwards compatibility mode
`boolean` `isConvertUntypedToOther()` Determine whether untypedAtomic values are converted to the type of the other operand.
`boolean` `isStrictComparison()` Get whether strict comparison is needed.
`void` `setBackwardsCompatible(boolean bc)` Set backwards compatibility mode.
`void` `setConvertUntypedToOther(boolean convertToOther)` Indicate that untypedAtomic values should be converted to the type of the other operand, rather than to strings.
`void` `setIndexedItemType(BuiltInAtomicType itemType)` Set the primitive item type of the values returned by the use expression
`void` `setLocation(String systemId, int lineNumber)` Set the system Id and line number of the source xsl:key definition
`void` `setStackFrameMap(SlotManager map)` Set the map of local variables needed while evaluating the "use" expression
`void` `setStrictComparison(boolean strict)` Set whether strict comparison is needed.

Methods inherited from class net.sf.saxon.instruct.Procedure
`getBody, getColumnNumber, getExecutable, getHostLanguage, getLineNumber, getLineNumber, getLocationProvider, getPublicId, getStackFrameMap, getSystemId, getSystemId, replaceSubExpression, setBody, setExecutable, setHostLanguage, setLineNumber, setSystemId`

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

Constructor Detail

### KeyDefinition

    public KeyDefinition(PatternFinder match,
                         SequenceIterable use,
                         String collationName,
                         StringCollator collation)

  Constructor to create a key definition

  Parameters:
    `match` - the pattern in the xsl:key match attribute
    `use` - the expression in the xsl:key use attribute, or the expression that results from compiling the xsl:key contained instructions. Note that a KeyDefinition constructed by the XSLT or XQuery parser will always use an Expression here; however, a KeyDefinition constructed at run-time by a compiled stylesheet or XQuery might use a simple ExpressionEvaluator that lacks all the compile-time information associated with an Expression
    `collationName` - the name of the collation being used
    `collation` - the actual collation. This must be one that supports generation of collation keys.

Method Detail

### setIndexedItemType

    public void setIndexedItemType(BuiltInAtomicType itemType)

  Set the primitive item type of the values returned by the use expression

### getIndexedItemType

    public BuiltInAtomicType getIndexedItemType()

  Get the primitive item type of the values returned by the use expression

### setBackwardsCompatible

    public void setBackwardsCompatible(boolean bc)

  Set backwards compatibility mode. The key definition is backwards compatible if ANY of the xsl:key declarations has version="1.0" in scope.

### isBackwardsCompatible

    public boolean isBackwardsCompatible()

  Test backwards compatibility mode

### setStrictComparison

    public void setStrictComparison(boolean strict)

  Set whether strict comparison is needed. Strict comparison treats non-comparable values as an error rather than a no-match. This is used for internal keys that support value comparisons in Saxon-SA, it is not used for user-defined XSLT keys.

### isStrictComparison

    public boolean isStrictComparison()

  Get whether strict comparison is needed.

### setConvertUntypedToOther

    public void setConvertUntypedToOther(boolean convertToOther)

  Indicate that untypedAtomic values should be converted to the type of the other operand, rather than to strings. This is used for indexes constructed internally by Saxon-SA to support filter expressions that use the "=" operator, as distinct from "eq".

  Parameters:
    `convertToOther` - true if comparisons follow the semantics of the "=" operator rather than the "eq" operator

### isConvertUntypedToOther

    public boolean isConvertUntypedToOther()

  Determine whether untypedAtomic values are converted to the type of the other operand.

  Returns:
    true if comparisons follow the semantics of the "=" operator rather than the "eq" operator

### setStackFrameMap

    public void setStackFrameMap(SlotManager map)

  Set the map of local variables needed while evaluating the "use" expression

  Overrides:
    `setStackFrameMap` in class `Procedure`

### setLocation

    public void setLocation(String systemId,
                            int lineNumber)

  Set the system Id and line number of the source xsl:key definition

### getMatch

    public PatternFinder getMatch()

  Get the match pattern for the key definition

  Returns:
    the pattern specified in the "match" attribute of the xsl:key declaration

### getUse

    public SequenceIterable getUse()

  Get the use expression for the key definition

  Returns:
    the expression specified in the "use" attribute of the xsl:key declaration

### getCollationName

    public String getCollationName()

  Get the collation name for this key definition.

  Returns:
    the collation name (the collation URI)

### getCollation

    public StringCollator getCollation()

  Get the collation.

  Returns:
    the collation

### getInstructionInfo

    public InstructionInfo getInstructionInfo()

  Get the InstructionInfo details about the construct. This information isn't used for tracing, but it is available when inspecting the context stack.

  Specified by:
    `getInstructionInfo` in interface `InstructionInfoProvider`

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