Saxon.Api
Class XdmValue
- Direct Known Subclasses
- XdmEmptySequence, XdmItem
-
public class XdmValue
- implements IEnumerable<XdmItem>
A value in the XDM data model. A value is a sequence of zero or more items, each item being an atomic value, a node, or a function item.
An XdmValue
is immutable.
A sequence consisting of a single item may be represented
as an instance of XdmItem, which is a subtype of XdmValue
. However,
there is no guarantee that all single-item sequences will be instances of
XdmItem
: if you want to ensure this, use the XdmValue.Simplify property.
There are various ways of creating an XdmValue
. To create an atomic
value, use one of the constructors on XdmAtomicValue (which is a subtype of XdmValue
).
To construct an XdmNode (another subtype) by parsing an XML document, or by wrapping a DOM document,
use a DocumentBuilder. To create a sequence of values, use the XdmValue.Append(XdmValue)
method on this class to form a list from individual items or sublists.
An XdmValue
is also returned as the result of evaluating a query
using the XQuery and XPath interfaces.
The subtype XdmEmptySequence represents an empty sequence: an
XdmValue
of length zero. Again, there is no guarantee that every empty sequence
will be represented as an instance of XdmEmptySequence
, unless you use
the Simplify
property.
Constructor Summary |
|
---|---|
XdmValue (IEnumerable<XdmItem> items) Create a value from a collection of items. |
|
XdmValue (IEnumerator<XdmItem> items)
Create an |
Property Summary |
|
---|---|
int | Count Get the number of items in the sequence. |
XdmValue | Simplify Simplify an XDM value: that is, reduce it to the simplest possible form. |
Method Summary |
|
---|---|
<T> bool | AllMatch(IPredicate<T> predicate)
Returns whether all items of this |
<T> bool | AnyMatch(IPredicate<T> predicate)
Returns whether any items of this |
XdmValue | Append(XdmValue otherValue)
Create a new |
static <TInput> IEnumerable<TInput> | Concat(IEnumerable<TInput> first, IEnumerable<TInput> second)
Concatenate two |
XdmValue | DocumentOrder()
Return a new |
IEnumerator<XdmItem> | GetEnumerator()
Get the sequence of items in the form of an |
IList<XdmItem> | GetList()
Get the sequence of items in the form of an |
XdmItem | ItemAt(int i) Get the i'th item in the value, counting from zero. |
static XdmValue | MakeValue(object o) Make an XDM value from a .NET object. |
<TInput, TResult> IEnumerable<TResult> | Select(Step<TInput, TResult> step)
Get an |
string | ToString() Create a string representation of the value. The is the result of serializing the value using the adaptive serialization method. |
net.sf.saxon.om.Sequence | Unwrap()
Extract the underlying Saxon |
<T> IEnumerable<T> | Where(IPredicate<T> predicate)
Get the enumerable object of items that satisfy a supplied |
static XdmValue | Wrap(net.sf.saxon.om.Sequence value)
Create an |
Constructor Detail
XdmValue
Create a value from a collection of items.
Parameters:
items
- An enumerable collection providing the items to make up the sequence. Every
member of this collection must be an instance of XdmItem
XdmValue
Create an XdmValue
from an enumerator of XdmItem
objects.
Parameters:
items
- An enumerator of XdmItem
objectsProperty Detail
Count
Get the number of items in the sequence.
Returns:
Simplify
Simplify an XDM value: that is, reduce it to the simplest possible form.
- If the sequence is empty, the result will be an instance of
XdmEmptySequence
- If the sequence is a single node, the result will be an instance of
XdmNode
- If it is a single atomic value, it will be an instance of
XdmAtomicValue
- If it is a map, it will be an instance of
XdmMap
- If it is an array, it will be an instance of
XdmArray
- If it is any other kind of function, it will be an instance of
XdmFunctionItem
- If it is a wrapper around a .NET object, it will be an instance of
XdmExternalObjectValue
Returns:
Method Detail
AllMatch
AnyMatch
Returns whether any items of this XdmValue
match the provided predicate.
May not evaluate the predicate on all items if not necessary for
determining the result.
Parameters:
predicate
- The predicate to apply to items of this XdmValue
Returns:
XdmValue
match the provided predicate, otherwise false.Append
Create a new XdmValue
by concatenating the sequences of items in
this XdmValue
and another XdmValue
.
Neither of the input XdmValue
objects is modified by this operation.
Parameters:
otherValue
-
The other XdmValue
, whose items are to be appended to the items from this XdmValue
.
Concat
IEnumerable<TInput> second)
Concatenate two IEnumerable
objects of XdmItem
objects or items of its subclass.
Parameters:
first
- The first enumerable objectsecond
- The second enumerable objectReturns:
DocumentOrder
Return a new XdmValue
containing the nodes present in this XdmValue
,
with duplicates eliminated, and sorted into document order.
Returns:
GetEnumerator
Get the sequence of items in the form of an IEnumerator
.
Returns:
XdmItem
.
GetList
Get the sequence of items in the form of an IList
.
Returns:
XdmItem
.
ItemAt
Get the i'th item in the value, counting from zero.
Parameters:
i
- The item that is required, counting the first item in the sequence as item zero.Returns:
MakeValue
Make an XDM value from a .NET object.
The supplied object may be any of the following:
- An instance of
XdmValue
(for example anXdmAtomicValue
,XdmMap
,XdmArray
orXdmNode
), which is returned unchanged - An instance of Saxon's Java class
net.sf.saxon.om.Sequence
, which is wrapped as anXdmValue
- An instance of
IDictionary
(which is wrapped as anXdmMap
using the method XdmMap.MakeMap(IDictionary)) - An array of objects, which are converted by applying these rules recursively,
and then wrapped as an
XdmArray
.
Parameters:
o
- The supplied objectReturns:
Select
Get an IEnumerable
by applying a Step
to the items in this value. This operation
is analogous to the SelectMany
operation in C#, or to the "!" operator
in XPath.
Parameters:
step
- The Step
to be applied to the items in this value.Returns:
IEnumerable
of items obtained by replacing each item X in this value by the items obtained
by applying the Step
function to X.ToString
Create a string representation of the value. The is the result of serializing the value using the adaptive serialization method.
Returns:
Unwrap
Extract the underlying Saxon Sequence
object from an XdmValue
.
This method is provided for the benefit of applications that need to mix
use of the Saxon .NET API with direct use of the underlying objects
and methods offered by the Java implementation.
Returns:
Where
Get the enumerable object of items that satisfy a supplied Predicate
.
Parameters:
predicate
- The predicate to be appliedReturns:
Predicate
.Wrap
Create an XdmValue
from an underlying Saxon Sequence
object.
This method is provided for the benefit of applications that need to mix
use of the Saxon .NET API with direct use of the underlying objects
and methods offered by the Java implementation.
Parameters:
value
- An object representing an XDM value in the
underlying Saxon implementation. If the parameter is null,
the method returns null.Returns:
XdmValue
that wraps the underlying Saxon XDM value
representation.
Returns whether all items of this
XdmValue
match the provided predicate. May not evaluate the predicate on all items if not necessary for determining the result.Parameters:
predicate
- The predicate to apply to items of thisXdmValue
Returns:
true
if either all items of theXdmValue
match the provided predicate or theXdmValue
is empty, otherwisefalse