Skip to main content

XmlValue

Struct XmlValue 

Source
pub struct XmlValue {
    pub type_code: XmlTypeCode,
    pub schema_type: Option<SimpleTypeKey>,
    pub value: XmlValueKind,
}
Expand description

A typed XSD value with type information.

This is the primary value type for XPath2/XQuery operations. It carries both the value and its type information.

Fields§

§type_code: XmlTypeCode

The type code identifying the value’s type

§schema_type: Option<SimpleTypeKey>

Optional reference to a schema-defined type

§value: XmlValueKind

The actual value

Implementations§

Source§

impl XmlValue

Source

pub fn new(type_code: XmlTypeCode, value: XmlValueKind) -> Self

Create a new XmlValue with the given type code and value

Source

pub fn with_schema_type( type_code: XmlTypeCode, schema_type: SimpleTypeKey, value: XmlValueKind, ) -> Self

Create a new XmlValue with schema type reference

Source

pub fn untyped(s: impl Into<String>) -> Self

Create an untyped atomic value

Source

pub fn string(s: impl Into<String>) -> Self

Create a string value

Source

pub fn boolean(b: bool) -> Self

Create a boolean value

Source

pub fn decimal(d: Decimal) -> Self

Create a decimal value

Source

pub fn integer(i: BigInt) -> Self

Create an integer value

Source

pub fn float(f: f32) -> Self

Create a float value

Source

pub fn double(d: f64) -> Self

Create a double value

Source

pub fn is_atomic(&self) -> bool

Check if this is an atomic value

Source

pub fn is_list(&self) -> bool

Check if this is a list value

Source

pub fn is_union(&self) -> bool

Check if this is a union value

Source

pub fn is_untyped(&self) -> bool

Check if this is an untyped atomic value

Source

pub fn primitive_type(&self) -> Option<PrimitiveTypeCode>

Get the primitive type code for this value

Source

pub fn to_string_value(&self) -> String

Get the string value (canonical representation)

Source

pub fn as_boolean(&self) -> Option<bool>

Try to get as boolean

Source

pub fn as_string(&self) -> Option<&str>

Try to get as string

Source

pub fn as_decimal(&self) -> Option<Decimal>

Try to get as decimal

Source

pub fn as_integer(&self) -> Option<&BigInt>

Try to get as integer

Source

pub fn as_double(&self) -> Option<f64>

Try to get as double

Source

pub fn as_qname(&self) -> Option<&QualifiedName>

Try to get as QName

Source

pub fn to_xpath_value<N: DomNavigator>( &self, item_schema_type: Option<SimpleTypeKey>, ) -> XPathValue<N>

Convert this XmlValue to an XPathValue for use as $value in assertion evaluation.

  • Atomic/UntypedAtomic → single XPathValue::Item
  • ListXPathValue::Sequence of atomic items, each with item_schema_type
  • Union → recursively converts the inner value

The item_schema_type parameter is needed because XmlValueKind::List stores bare XmlAtomicValue items without per-item schema_type. Callers pass it from the list type’s resolved_item_type.

Trait Implementations§

Source§

impl Clone for XmlValue

Source§

fn clone(&self) -> XmlValue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for XmlValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<N: DomNavigator> From<XmlValue> for XmlItem<N>

Source§

fn from(value: XmlValue) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for XmlValue

Source§

fn eq(&self, other: &XmlValue) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for XmlValue

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.