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 | OneOrMore
Construct an |
XdmSequenceType | ZeroOrMore
Construct an |
XdmSequenceType | ZeroOrOne
Construct an |
Method Summary |
|
---|---|
bool | Equals (object other) Compare two item types for equality |
static XdmItemType | ForItem (XdmItem item, Processor processor)
Get an |
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 |
bool | Subsumes (XdmItemType other)
Determine whether this ItemType subsumes another ItemType. Specifically,
|
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 ( |
Property Detail
One
Construct an XdmSequenceType
that allows a sequence to contain exactly one item of this
item type
Returns:
.Occurs(' ')
OneOrMore
Construct an XdmSequenceType
that allows a sequence to contain one or more items of this
item type
Returns:
.Occurs('+')
ZeroOrMore
Construct an XdmSequenceType
that allows a sequence to contain zero or more items of this
item type
Returns:
.Occurs('*')
ZeroOrOne
Construct an XdmSequenceType
that allows a sequence to contain zero or one items of this
item type
Returns:
.Occurs('?')
Method Detail
ForItem
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 requiredprocessor
- the Saxon Processor. This is needed because in some cases,
items are not tied to a particular Processor, but item types are.Returns:
GetHashCode
Get a hash code to support equality comparison
Returns:
Matches
Determine whether this item type matches a given item.
Parameters:
item
- the item to be tested against this item typeReturns:
Occurs
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:
XdmSequenceType
that combines this XdmItemType
with
the given occurrence indicator.Subsumes
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 ItemTypeReturns:
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:
Compare two item types for equality
Parameters:
other
- The object to be comparedReturns: