Saxon.Api

Class DocumentBuilder

Class DomDestination

Class DynamicContext

Class DynamicError

Class EmptyEnumerator

Class ExtensionFunctionCall

Class ExtensionFunctionDefinition

Class InvalidityHandlerWrapper

Class NamespaceConstant

Class NullDestination

Class Processor

Class QName

Class SchemaManager

Class SchemaValidator

Class Serializer

Class StandardLogger

Class StaticContext

Class StaticError

Class TextWriterDestination

Class XPathCompiler

Class XPathExecutable

Class XPathSelector

Class XQueryCompiler

Class XQueryEvaluator

Class XQueryExecutable

Class XdmAnyFunctionType

Class XdmAnyItemType

Class XdmAnyNodeType

Class XdmAtomicType

Class XdmAtomicValue

Class XdmDestination

  - Class TreeProtector

Class XdmEmptySequence

Class XdmFunctionItem

Class XdmItem

Class XdmItemType

Class XdmNode

Class XdmNodeKind

Class XdmSequenceType

Class XdmValue

Class XmlDestination

Class Xslt30Transformer

Class XsltCompiler

Class XsltExecutable

  - Class ParameterDetails

Class XsltPackage

Class XsltTransformer

Enum RecoveryPolicy

Enum SchemaValidationMode

Enum TreeModel

Enum WhitespacePolicy

Enum XdmAxis

Interface IInvalidityHandler

Interface IMessageListener

Interface IQueryResolver

Interface IResultDocumentHandler

Interface IXdmEnumerator

Interface IXmlLocation

Interface SchemaResolver

 

Saxon.Api
Class XdmAtomicValue


public class XdmAtomicValue
extends XdmItem

The class XdmAtomicValue represents an item in an XPath 2.0 sequence that is an atomic value. The value may belong to any of the 19 primitive types defined in XML Schema, or to a type derived from these primitive types, or to the XPath 2.0 type xs:untypedAtomic

Note that there is no guarantee that every XdmValue comprising a single atomic value will be an instance of this class. To force this, use the Simplify property of the XdmValue.


Constructor Summary
XdmAtomicValue(string str)

Construct an atomic value of type xs:string

XdmAtomicValue(long i)

Construct an atomic value of type xs:integer

XdmAtomicValue(decimal d)

Construct an atomic value of type xs:decimal

XdmAtomicValue(float f)

Construct an atomic value of type xs:float

XdmAtomicValue(double d)

Construct an atomic value of type xs:double

XdmAtomicValue(bool b)

Construct an atomic value of type xs:boolean

XdmAtomicValue(System.Uri u)

Construct an atomic value of type xs:anyURI

XdmAtomicValue(QName q)

Construct an atomic value of type xs:QName

XdmAtomicValue(string lexicalForm, QName type, Processor processor)

Construct an atomic value of a given built-in or user-defined type

 
Property Summary
 Object Value

Get the value as a CLI object of the nearest equivalent type.

 
Method Summary
 bool IsAtomic()

Determine whether the item is an atomic value

static XdmAtomicValue WrapExternalObject(object external)

Create an atomic value that wraps an external object. Such values can be used in conjunction with extension functions.

 bool GetBooleanValue()

Get the value converted to a boolean using the XPath casting rules

 long GetLongValue()

Get the value converted to a boolean using the XPath casting rules

 double GetDoubleValue()

Get the value converted to a double using the XPath casting rules.

If the value is a string, the XSD 1.1 rules are used, which means that the string "+INF" is recognised.

 Decimal GetDecimalValue()

Get the value converted to a decimal using the XPath casting rules

 String ToString()

Convert the atomic value to a string

 QName GetTypeName(Processor processor)

Get the name of the value's XDM type

 QName GetPrimitiveTypeName()

Get the name of the primitive type of the value

 
Constructor Detail

XdmAtomicValue

public XdmAtomicValue(string str)

Construct an atomic value of type xs:string

Parameters:
str -
The string value

XdmAtomicValue

public XdmAtomicValue(long i)

Construct an atomic value of type xs:integer

Parameters:
i -
The integer value

XdmAtomicValue

public XdmAtomicValue(decimal d)

Construct an atomic value of type xs:decimal

Parameters:
d -
The decimal value

XdmAtomicValue

public XdmAtomicValue(float f)

Construct an atomic value of type xs:float

Parameters:
f -
The float value

XdmAtomicValue

public XdmAtomicValue(double d)

Construct an atomic value of type xs:double

Parameters:
d -
The double value

XdmAtomicValue

public XdmAtomicValue(bool b)

Construct an atomic value of type xs:boolean

Parameters:
b -
The boolean value

XdmAtomicValue

public XdmAtomicValue(System.Uri u)

Construct an atomic value of type xs:anyURI

Parameters:
u -
The uri value

XdmAtomicValue

public XdmAtomicValue(QName q)

Construct an atomic value of type xs:QName

Parameters:
q -
The QName value

XdmAtomicValue

public XdmAtomicValue(string lexicalForm,
                      QName type,
                      Processor processor)

Construct an atomic value of a given built-in or user-defined type

Parameters:
lexicalForm -
The string representation of the value (any value that is acceptable in the lexical space, as defined by XML Schema Part 2). Whitespace normalization as defined by the target type will be applied to the value.
type -
The QName giving the name of the target type. This must be an atomic type, and it must not be a type that is namespace-sensitive (QName, NOTATION, or types derived from these). If the type is a user-defined type then its definition must be present in the schema cache maintained by the SchemaManager.
processor -
The Processor object. This is needed for looking up user-defined types, and also because some conversions are context-sensitive, for example they depend on the implicit timezone or the choice of XML 1.0 versus XML 1.1 for validating names.
Throws:
ArgumentException - Thrown if the type is unknown or unsuitable, or if the supplied string is not a valid lexical representation of a value of the given type.

Property Detail

Value

public Object Value {get; }

Get the value as a CLI object of the nearest equivalent type.

The return type is as follows:

xs:string - String

xs:integer - Long

xs:decimal - Decimal

xs:double - Double

xs:float - Float

xs:boolean - Bool

xs:QName - QName

xs:anyURI - Uri

xs:untypedAtomic - String

wrapped external object - the original external object

Other types - currently String, but this may change in the future

Returns:
The value converted to the most appropriate CLI type

Method Detail

IsAtomic

public override bool IsAtomic()

Determine whether the item is an atomic value

Returns:
true (the item is an atomic value)

WrapExternalObject

public static XdmAtomicValue WrapExternalObject(object external)

Create an atomic value that wraps an external object. Such values can be used in conjunction with extension functions.

This method should not be used to create simple atomic values representing strings, numbers, booleans, and so on. For that purpose, use the relevant constructor. Wrapped external objects are used only when calling .NET native code external to a query or stylesheet.

In releases prior to 9.2, this method also existed with the alternative spelling wrapExternalObject (lower-case "w"). This was retained for backwards compatibility, but caused problems for Visual Basic users, where it is not permitted to have two methods whose names differ only in case. Any applications using wrapExternalObject must therefore be changed to use WrapExternalObject. Apologies for the inconvenience.

Parameters:
external -
The object to be wrapped.
Returns:
The wrapped object

GetBooleanValue

public bool GetBooleanValue()

Get the value converted to a boolean using the XPath casting rules

Returns:
the result of converting to a boolean (Note: this is not the same as the effective boolean value).

GetLongValue

public long GetLongValue()

Get the value converted to a boolean using the XPath casting rules

Returns:
the result of converting to an integer

GetDoubleValue

public double GetDoubleValue()

Get the value converted to a double using the XPath casting rules.

If the value is a string, the XSD 1.1 rules are used, which means that the string "+INF" is recognised.

Returns:
the result of converting to a double

GetDecimalValue

public Decimal GetDecimalValue()

Get the value converted to a decimal using the XPath casting rules

Returns:
return the result of converting to a decimal

ToString

public override String ToString()

Convert the atomic value to a string

Returns:
The value converted to a string, according to the rules of the XPath 2.0 cast operator

GetTypeName

public QName GetTypeName(Processor processor)

Get the name of the value's XDM type

Parameters:
processor -
The Processor object. This is needed for access to the NamePool, which maps the internal form of type names to their external form.
Returns:
The type of the value, as a QName. This may be a built-in type or a user-defined atomic type.

GetPrimitiveTypeName

public QName GetPrimitiveTypeName()

Get the name of the primitive type of the value

Returns:
The primitive type of the value, as a QName. This will be the name of one of the primitive types defined in XML Schema Part 2, or the XPath-defined type xs:untypedAtomic. For the purposes of this method, xs:integer is considered to be a primitive type.