Saxon.Api

 

 

Saxon.Api

Class XdmItemType

Direct Known Subclasses
XdmAnyArrayType, XdmAnyFunctionType, XdmAnyItemType, XdmAnyMapType, XdmAnyNodeType, XdmAtomicType, XdmNodeKind

public abstract class XdmItemType

Abstract class representing an item type. This may be the generic item type item(), an atomic type, the generic node type node(), a specific node kind such as element() or text(), or the generic function type function().

More specific node types (such as element(E) or schema-element(E)) cannot currently be instantiated directly in this API.

An XdmItemType may however be constructed using the method Processor.ParseItemType()

Property Summary

 XdmSequenceType One

Construct an XdmSequenceType that allows a sequence to contain exactly one item of this item type

 XdmSequenceType OneOrMore

Construct an XdmSequenceType that allows a sequence to contain one or more items of this item type

 XdmSequenceType ZeroOrMore

Construct an XdmSequenceType that allows a sequence to contain zero or more items of this item type

 XdmSequenceType ZeroOrOne

Construct an XdmSequenceType that allows a sequence to contain zero or one items of this item type

 

Method Summary

 bool Equals (object other)

Compare two item types for equality

static XdmItemType ForItem (XdmItem item, Processor processor)

Get an XdmItemType representing the type of a supplied XdmItem.

 int GetHashCode ()

Get a hash code to support equality comparison

 bool Matches (XdmItem item)

Determine whether this item type matches a given item.

 XdmSequenceType Occurs (char indicator)

Construct an XdmSequenceType from an XdmItemType and an occurrence indicator

 bool Subsumes (XdmItemType other)

Determine whether this ItemType subsumes another ItemType. Specifically, A.subsumes(B) is true if every value that matches the ItemType B also matches the ItemType A.

 string ToString ()

Get a string representation of the type. This will be generally a string that conforms to XPath ItemType production, for example a QName for an atomic type, or a construct such as 'node()' or 'map(*)'). If the type is an anonymous schema type, the name of the nearest named base type will be given, preceded by the character '<'. QNames in the XML Schema namespace use the prefix "xs" (for example "xs:boolean"); other QNames are expressed using EQName notation (Q{uri}local).

 

Property Detail

One

public XdmSequenceType One {get; }

Construct an XdmSequenceType that allows a sequence to contain exactly one item of this item type

Returns:

the result of .Occurs(' ')

OneOrMore

public XdmSequenceType OneOrMore {get; }

Construct an XdmSequenceType that allows a sequence to contain one or more items of this item type

Returns:

the result of .Occurs('+')

ZeroOrMore

public XdmSequenceType ZeroOrMore {get; }

Construct an XdmSequenceType that allows a sequence to contain zero or more items of this item type

Returns:

the result of .Occurs('*')

ZeroOrOne

public XdmSequenceType ZeroOrOne {get; }

Construct an XdmSequenceType that allows a sequence to contain zero or one items of this item type

Returns:

the result of .Occurs('?')

Method Detail

Equals

public override bool Equals(object other)

Compare two item types for equality

Parameters:

other - The object to be compared

Returns:

The result of the equality comparison.

ForItem

public static XdmItemType ForItem(XdmItem item,
Processor processor)

Get an XdmItemType representing the type of a supplied XdmItem.

Note that the results are to some extent arbitrary, since an item may conform to many different item types, and none of them is necessarily more specific than all the others.

If the supplied item is an atomic value, the returned ItemType will reflect the most specific atomic type of the item.

For a map, the result is simply {@link net.sf.saxon.s9api.ItemType#ANY_MAP}. For an array, the result is simply {@link net.sf.saxon.s9api.ItemType#ANY_ARRAY}. For any other function, it is an instance of {@link XdmFunctionItem} that reflects the signature of the function.

Future versions of Saxon may return a more precise type.

Parameters:

item - item the supplied item whose type is required
processor - the Saxon Processor. This is needed because in some cases, items are not tied to a particular Processor, but item types are.

Returns:

a type that matches the supplied item

GetHashCode

public override int GetHashCode()

Get a hash code to support equality comparison

Returns:

A suitable hash code

Matches

public abstract bool Matches(XdmItem item)

Determine whether this item type matches a given item.

Parameters:

item - the item to be tested against this item type

Returns:

true if the item matches this item type, false if it does not match.

Occurs

public XdmSequenceType Occurs(char indicator)

Construct an XdmSequenceType from an XdmItemType and an occurrence indicator

Parameters:

indicator - The occurrence indicator. The values '*', '?', and '!' have their usual meaning. A single space (' ') indicates "exactly one", and digit zero ('0') indicates "exactly zero". These values are also available as constants in class XdmSequenceType.

Returns:

An XdmSequenceType that combines this XdmItemType with the given occurrence indicator.

Subsumes

public abstract bool Subsumes(XdmItemType other)

Determine whether this ItemType subsumes another ItemType. Specifically, A.subsumes(B) is true if every value that matches the ItemType B also matches the ItemType A.

Parameters:

other - the other ItemType

Returns:

true if this ItemType subsumes the other ItemType. This includes the case where A and B represent the same ItemType.

ToString

public override string ToString()

Get a string representation of the type. This will be generally a string that conforms to XPath ItemType production, for example a QName for an atomic type, or a construct such as 'node()' or 'map(*)'). If the type is an anonymous schema type, the name of the nearest named base type will be given, preceded by the character '<'. QNames in the XML Schema namespace use the prefix "xs" (for example "xs:boolean"); other QNames are expressed using EQName notation (Q{uri}local).

Returns:

a string representation of the type