attribute

inline fun <TAttribute> attribute(name: String? = null, namespace: String? = null, defaultValue: TAttribute? = null, inherited: Boolean = false): AttributeDelegate<TAttribute, TAttribute>(source)

Creates an attribute delegate for an XML element property.

This function creates a delegate that can be used to access and modify attributes on an XML element using properties. The delegate ensures type safety and provides null-safety checks for required attributes. This variant assumes the attribute value doesn't require any transformation and directly uses the raw value.

Return

An AttributeDelegate instance for the specified types.

Parameters

TAttribute

The type of the attribute value (reified).

name

An optional custom name for the attribute (defaults to the property name).

namespace

An optional namespace for the attribute.

Throws

if a required attribute (non-nullable TAttribute) is not found on the XML element.


inline fun <TAttribute, TTransform> attribute(name: String? = null, namespace: String? = null, defaultValue: TTransform? = null, inherited: Boolean = false, noinline transform: (TAttribute) -> TTransform): AttributeDelegate<TAttribute, TTransform>(source)

Creates an attribute delegate for an XML element property.

This function creates a delegate that can be used to access and modify attributes on an XML element using properties. The delegate ensures type safety and provides null-safety checks for required attributes.

Return

An AttributeDelegate instance for the specified types.

Parameters

TAttribute

The type of the attribute value before transformation (reified).

TTransform

The type of the attribute value after transformation (reified).

name

An optional custom name for the attribute (defaults to the property name).

namespace

An optional namespace for the attribute.

transform

A transformation function applied to the raw attribute value before returning.

Throws

if a required attribute (non-nullable TAttribute) is not found on the XML element.