Class SchemaElementType

All Implemented Interfaces:
NodePredicate, NodeTest, SchemaNodeTest, ItemType, ItemTypeWithSequenceTypeCache

public class SchemaElementType extends XNodeType implements SchemaNodeTest
A Node type of the form schema-element(element-name)
Since:
9.3
  • Constructor Details

  • Method Details

    • getAllowedNodeNames

      public QNameTest getAllowedNodeNames()
      Get the set of allowed node names that this type if capable of matching
      Specified by:
      getAllowedNodeNames in class XNodeType
      Returns:
      the allowed node names
    • getRequiredFingerprint

      public int getRequiredFingerprint(int nodeKind)
      For an XNodeType that can only match one kind of node and one node name, return that node name, as an integer fingerprint. In other cases, return -1.
      Overrides:
      getRequiredFingerprint in class XNodeType
      Parameters:
      nodeKind - the kind of node required. If the XNodeType does not match this node kind, return -1.
      Returns:
      an integer fingerprint in the case of a node type that only matches one node kind and one qualified name. In other cases return -1.
    • getElementDeclaration

      public ElementDecl getElementDeclaration()
      Get the element declaration
      Returns:
      the element declaration that this schema-element relates to (the head of the substitution group)
    • getSchema

      public Schema getSchema()
      Get the schema from the static context of this type designation
      Returns:
      the in-scope schema
    • getNodeName

      public StructuredQName getNodeName()
      Specified by:
      getNodeName in interface SchemaNodeTest
    • getUType

      public UType getUType()
      Get the corresponding UType. A UType is a union of primitive item types.
      Specified by:
      getUType in interface ItemType
      Specified by:
      getUType in interface NodeTest
      Overrides:
      getUType in class XNodeType
      Returns:
      the smallest UType that subsumes this item type
    • matches

      public boolean matches(Item item)
      Test whether this node test is satisfied by a given node. This alternative method is used in the case of nodes where calculating the fingerprint is expensive, for example DOM or JDOM nodes.
      Specified by:
      matches in interface ItemType
      Specified by:
      matches in class GNodeType
      Parameters:
      item - the item to be matched
      Returns:
      true if the item is an instance of this type; false otherwise
    • matchesAnnotation

      public static boolean matchesAnnotation(SchemaType required, SchemaType actual, TypeHierarchy th)
      Determine whether the type annotation of an element or attribute instances matches the required type of the element or attribute declaration named in a schema-element() or schema-attribute() test
      Parameters:
      required - the required type of the declaration named in the schema-element() or schema-attribute test
      actual - the actual type annotation of the instance
      th - the type hierarchy cache
      Returns:
      true if there is a match, false otherwise
    • getDefaultPriority

      public final double getDefaultPriority()
      Determine the default priority of this node test when used on its own as a Pattern
      Specified by:
      getDefaultPriority in interface ItemType
      Specified by:
      getDefaultPriority in interface NodeTest
      Returns:
      the default priority
    • getPrimitiveType

      public int getPrimitiveType()
      Determine the types of nodes to which this pattern applies. Used for optimisation. For patterns that match nodes of several types, return Type.NODE
      Specified by:
      getPrimitiveType in interface ItemType
      Overrides:
      getPrimitiveType in class GNodeType
      Returns:
      the type of node matched by this pattern. e.g. Type.ELEMENT or Type.TEXT
    • getContentType

      public SchemaType getContentType()
      Get the content type allowed by this NodeTest (that is, the type annotation of the matched nodes). Return AnyType if there are no restrictions. The default implementation returns AnyType.
      Overrides:
      getContentType in class XNodeType
      Returns:
      the allowed content type
    • isNillable

      public boolean isNillable()
      Determine whether nilled nodes can match this node test
      Specified by:
      isNillable in interface NodeTest
      Overrides:
      isNillable in class XNodeType
      Returns:
      true if nilled nodes can match this node test
    • isNillable

      public boolean isNillable(int fingerprint)
      Determine if nilled nodes named N can match this node test
      Parameters:
      fingerprint - the element name
      Returns:
      true if nilled nodes with the given name can match the node test
    • getHeadFingerprint

      public int getHeadFingerprint()
      Get the fingerprint of the head of the substitution group
      Returns:
      the fingerprint of the head of the substitution group
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Returns a hash code value for the object.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • getBasicAlphaCode

      public String getBasicAlphaCode()
      Description copied from interface: ItemType
      Get an alphabetic code representing the type, or at any rate, the nearest built-in type from which this type is derived. The codes are designed so that for any two built-in types A and B, alphaCode(A) is a prefix of alphaCode(B) if and only if A is a supertype of B.
      Specified by:
      getBasicAlphaCode in interface ItemType
      Returns:
      the alphacode for the nearest containing built-in type. For example: for xs:string return "AS", for xs:boolean "AB", for node() "N", for element() "NE", for map(*) "FM", for array(*) "FA".
    • explainMismatch

      public Optional<String> explainMismatch(Item item, TypeHierarchy th)
      Get extra diagnostic information about why a supplied item does not conform to this item type, if available. If extra information is returned, it should be in the form of a complete sentence, minus the closing full stop. No information should be returned for obvious cases.
      Specified by:
      explainMismatch in interface ItemType
      Specified by:
      explainMismatch in interface NodeTest
      Overrides:
      explainMismatch in class GNodeType
      Parameters:
      item - the item that doesn't match this type
      th - the type hierarchy cache
      Returns:
      optionally, a message explaining why the item does not match the type