data.xmldata
Module data.xmldata
ballerina/data.xmldata Ballerina library
This package does not have any public APIs.
Functions
parseAsType
function parseAsType(xml v, SourceOptions options, typedesc<record {}> t) returns t|Error
Converts XML to record type with projection.
Parameters
- v xml - Source XML value
- options SourceOptions (default {}) - Options to be used for filtering in the projection
- t typedesc<record {}> (default <>) - Target type to be used for filtering in the projection
Return Type
- t|Error - On success, returns the given target type value, else returns an
xmldata:Error
value
parseBytes
function parseBytes(byte[] s, SourceOptions options, typedesc<record {}> t) returns t|Error
Converts XML byte[] to record type with projection.
Parameters
- s byte[] - Source XML byte[]
- options SourceOptions (default {}) - Options to be used for filtering in the projection
- t typedesc<record {}> (default <>) - Target type to be used for filtering in the projection
Return Type
- t|Error - On success, returns the given target type value, else returns an
xmldata:Error
value
parseStream
function parseStream(stream<byte[], error?> s, SourceOptions options, typedesc<record {}> t) returns t|Error
Converts XML byte-block-stream to record type with projection.
Parameters
- options SourceOptions (default {}) - Options to be used for filtering in the projection
- t typedesc<record {}> (default <>) - Target type to be used for filtering in the projection
Return Type
- t|Error - On success, returns the given target type value, else returns an
xmldata:Error
value
parseString
function parseString(string s, SourceOptions options, typedesc<record {}> t) returns t|Error
Converts XML string to record type with projection.
Parameters
- s string - Source XML string value
- options SourceOptions (default {}) - Options to be used for filtering in the projection
- t typedesc<record {}> (default <>) - Target type to be used for filtering in the projection
Return Type
- t|Error - On success, returns the given target type value, else returns an
xmldata:Error
value
toXml
Converts a Map
or Record
representation to its XML representation.
Additionally, when converting from a record, the xmldata:Namespace
, xmldata:Name
, and xmldata:Attribute
annotations can be used to add namespaces
, name of elements
, and attributes
to XML representation.
Annotations
data.xmldata: Attribute
The annotation is used to denote the field that is considered an attribute.
When using parseString
, parseBytes
, parseStream
, parseAsType
, this annotation can be used to
indicate the record field as an attribute.
When using toXml
, this annotation can be used to add the attribute to the XML element.
data.xmldata: Name
The annotation is used to specify the new name of the existing record name or field name according to the XML format.
When using parseString
, parseBytes
, parseStream
, parseAsType
, this annotation can be used to
validate the name of the XML element with the record field or type.
When using toXml
, this annotation can be used to override the name of field or type.
data.xmldata: Namespace
The annotation is used to specify the namespace's prefix and URI of the XML element.
When using parseString
, parseBytes
, parseStream
, parseAsType
, this annotation can be used to
validate the namespace of the XML element with the record field or type.
When using toXml
, this annotation can be used to add the namespace to the XML element.
Records
data.xmldata: NameConfig
Defines the name of the XML element.
Fields
- value string - The name of the XML element
data.xmldata: NamespaceConfig
Defines the namespace of the XML element.
Fields
- prefix string? - The value of the prefix of the namespace
- uri string - The value of the URI of the namespace
data.xmldata: Options
Represent the options that can be used to modify the behaviour of projection.
Fields
- attributePrefix string(default EMPTY_STRING) - prefix added for attribute fields in the record
- textFieldName string(default "#content") - field name for the text field
data.xmldata: SourceOptions
Represent the options that can be used to modify the behaviour of projection.
Fields
- Fields Included from * Options
- allowDataProjection boolean(default true) - enable or disable projection
Errors
data.xmldata: Error
Represents the error type of the ballerina/data.xmldata module. This error type represents any error that can occur during the execution of xmldata APIs.
Import
import ballerina/data.xmldata;
Metadata
Released date: 17 days ago
Version: 0.1.0
License: Apache-2.0
Compatibility
Platform: java17
Ballerina version: 2201.9.0
Pull count
Total: 0
Current verison: 0
Weekly downloads
Keywords
xml
Contributors
Other versions
0.1.0