Saxon.Api

 

 

Saxon.Api

Class XdmItem

Direct Known Subclasses
XdmAtomicValue, XdmExternalObject, XdmFunctionItem, XdmNode

public abstract class XdmItem
extends XdmValue

The class XdmItem represents an item in a sequence, as defined by the XDM data model. An item may be an atomic value, a node, a function (including maps and arrays), or an external object.

An item is a member of a sequence, but it can also be considered as a sequence (of length one) in its own right. XdmItem is a subtype of XdmValue because every item in the XDM data model is also a value.

It cannot be assumed that every sequence of length one will always be represented by an XdmItem. It is quite possible for an XdmValue that is not an XdmItem to hold a singleton sequence. Use XdmValue.Simplify to ensure that a singleton is represented as an XdmItem.

Property Summary

 string StringValue

Get the string value of the item.

 

Method Summary

 bool IsAtomic ()

Ask whether the item is an atomic value.

 bool IsNode ()

Ask whether the item is a node or some other type of item.

 bool Matches (XdmItemType typei)

Ask whether this item matches a given item type.

static XdmItem WrapItem (net.sf.saxon.om.Item value)

Create an XdmItem from an underlying Saxon Saxon.Hej.om.Item object. The result is the same as applying the XdmValue.Wrap method, but it is returned more conveniently as an instance of XdmItem

static XdmNode WrapItem (net.sf.saxon.om.NodeInfo value)

Create an XdmNode from an underlying Saxon Saxon.Hej.om.NodeInfo object. The result is the same as applying the XdmValue.Wrap method, but it is returned more conveniently as an instance of XdmNode

static XdmAtomicValue WrapItem (net.sf.saxon.value.AtomicValue value)

Create an XdmAtomicValue from an underlying Saxon Saxon.Hej.value.AtomicValue object. The result is the same as applying the XdmValue.Wrap method, but it is returned more conveniently as an instance of XdmAtomicValue

 

Property Detail

StringValue

public string StringValue {get; }

Get the string value of the item.

  • For an atomic value, the result is the same as casting the value to a string.
  • For a node, the method returns the string value of the node. This is not the same as the result of XdmNode.ToString, which returns the result of serializing the node.
  • For a function, including a map or array, the result is an error.
  • For an external object, the result is the same as the result of calling ToString() on the external object.

In all cases the result is the same as applying the XPath string() function.

Returns:

The result of converting the item to a string.

Method Detail

IsAtomic

public abstract bool IsAtomic()

Ask whether the item is an atomic value.

Returns:

True if the item is an atomic value, false if it is a node, function, or external object.

IsNode

public bool IsNode()

Ask whether the item is a node or some other type of item.

Returns:

True if the item is a node, false if it is an atomic value or a function (including maps and arrays).

Matches

public bool Matches(XdmItemType typei)

Ask whether this item matches a given item type.

Parameters:

typei - The item type to be tested against this item

Returns:

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

WrapItem

public static XdmItem WrapItem(net.sf.saxon.om.Item value)

Create an XdmItem from an underlying Saxon Saxon.Hej.om.Item object. The result is the same as applying the XdmValue.Wrap method, but it is returned more conveniently as an instance of XdmItem

Parameters:

value - An object representing an XDM value in the underlying Saxon implementation. Must not be null.

Returns:

An XdmItem that wraps the underlying Saxon XDM item representation.

WrapItem

public static XdmNode WrapItem(net.sf.saxon.om.NodeInfo value)

Create an XdmNode from an underlying Saxon Saxon.Hej.om.NodeInfo object. The result is the same as applying the XdmValue.Wrap method, but it is returned more conveniently as an instance of XdmNode

Parameters:

value - An object representing an XDM node in the underlying Saxon implementation. Must not be null.

Returns:

An XdmNode that wraps the underlying Saxon XDM node representation.

WrapItem

public static XdmAtomicValue WrapItem(net.sf.saxon.value.AtomicValue value)

Create an XdmAtomicValue from an underlying Saxon Saxon.Hej.value.AtomicValue object. The result is the same as applying the XdmValue.Wrap method, but it is returned more conveniently as an instance of XdmAtomicValue

Parameters:

value - An object representing an XDM atomic value in the underlying Saxon implementation. Must not be null.

Returns:

An XdmAtomicValue that wraps the underlying Saxon atomic value representation.