Saxon.Api

 

 

Saxon.Api

Class XdmAtomicValue


public class XdmAtomicValue
extends XdmItem

The class XdmAtomicValue represents an item in an XDM 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 XDM-specific 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 from a supplied long

XdmAtomicValue (int i)

Construct an atomic value of type xs:integer from a supplied long

XdmAtomicValue (Byte i)

Construct an atomic value of type xs:integer from a supplied byte

XdmAtomicValue (decimal d)

Construct an atomic value of type xs:decimal

XdmAtomicValue (float f)

Construct an atomic value of type xs:float

XdmAtomicValue (DateTime dt)

Construct an atomic value of type xs:dateTime from a .NET DateTime object Here we probe the object for timezone offset information to create the resulting value.

XdmAtomicValue (DateTimeOffset offset)

Construct an atomic value of type xs:dateTime with a specific timezone offset from a DateTimeOffset object.

XdmAtomicValue (double d)

Construct an atomic value of type xs:double

XdmAtomicValue (bool b)

Construct an atomic value of type xs:boolean

XdmAtomicValue (Uri u)

Construct an atomic value of type xs:anyURI

XdmAtomicValue (QName q)

Construct an atomic value of type xs:QName

XdmAtomicValue (string lexicalForm, XdmAtomicType type)

Construct an atomic value of a given type

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 Equals(object other)

Compare two atomic values for equality

 bool GetBooleanValue()

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

 decimal GetDecimalValue()

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

 double GetDoubleValue()

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

 int GetHashCode()

Get a hash code to support equality comparison

 long GetLongValue()

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

 QName GetPrimitiveTypeName()

Get the name of the primitive type of the value

 QName GetTypeName()

Get the name of the value's XDM type

 QName GetTypeName(Processor processor)

Get the name of the value's XDM type

 bool IsAtomic()

Determine whether the item is an atomic value

static XdmAtomicValue MakeAtomicValue(object value)

Create an atomic value of a type appropriate to the supplied value.

 string ToString()

Convert the atomic value to a string

 

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 from a supplied long

Parameters:

i - The integer value

XdmAtomicValue

public XdmAtomicValue(int i)

Construct an atomic value of type xs:integer from a supplied long

Parameters:

i - The integer value

XdmAtomicValue

public XdmAtomicValue(Byte i)

Construct an atomic value of type xs:integer from a supplied byte

Parameters:

i - The integer value, in the range -128 to +127

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(DateTime dt)

Construct an atomic value of type xs:dateTime from a .NET DateTime object Here we probe the object for timezone offset information to create the resulting value.

Parameters:

dt - The DateTime object value

XdmAtomicValue

public XdmAtomicValue(DateTimeOffset offset)

Construct an atomic value of type xs:dateTime with a specific timezone offset from a DateTimeOffset object.

Parameters:

offset - The DateTimeOffset 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(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,
                      XdmAtomicType type)

Construct an atomic value of a given 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 type given as an XdmAtomicType

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

Equals

public override bool Equals(object other)

Compare two atomic values for equality

Parameters:

other - The object to be compared

Returns:

The result of the equality comparison, using the rules of the op:is-same-key() comparison used for comparing key values in maps.

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).

GetDecimalValue

public decimal GetDecimalValue()

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

Returns:

The result of converting to a decimal

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

GetHashCode

public override int GetHashCode()

Get a hash code to support equality comparison

Returns:

A suitable hash code

GetLongValue

public long GetLongValue()

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

Returns:

The result of converting to a long

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.

GetTypeName

public QName GetTypeName()

Get the name of the value's XDM type

Returns:

The type of the value, as a QName.

GetTypeName

public QName GetTypeName(Processor processor)

Get the name of the value's XDM type

Parameters:

processor - The Processor object. This parameter is no longer used, but is accepted for backwards compatibility.

Returns:

The type of the value, as a QName.

IsAtomic

public override bool IsAtomic()

Determine whether the item is an atomic value

Returns:

True (the item is an atomic value).

MakeAtomicValue

public static XdmAtomicValue MakeAtomicValue(object value)

Create an atomic value of a type appropriate to the supplied value.

The supplied value must be one of the following:

  • An instance of the Saxon Java class net.sf.saxon.value.AtomicValue
  • A Boolean - returns an instance of xs:boolean
  • A (signed) int, long, short, or byte - returns an instance of xs:integer
  • A Char - TODO ???????
  • A String - returns an instance of xs:string
  • A Double - returns an instance of xs:double
  • A Float - returns an instance of xs:float
  • A decimal - returns an instance of xs:decimal
  • A URI - returns an instance of xs:anyURI
  • A QName - returns an instance of xs:QName

Parameters:

value - The value to be converted.

Returns:

The converted value

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 cast expression