By default, DOMDeserializer generates qualified XML document with namespaces. To generate unqualified XML document use DOMDeserializer function setQualified with false value.
XSI Types
DOMSerializer can use XML XSI attribute to convert XML value to specific primitive Candid type.
Here is mapping table between Candid and XML Schema.
Candid
XML Schema
bool
boolean
int
integer
int8
byte
int16
short
int32
int
int64
long
nat
posiiveInteger
nat8
unsignedByte
nat16
unsignedShort
nat32
unsignedInt
nat64
unsignedLong
float32
float
float64
double
text
string
principal
ID
Using Candid XML Attributes
The developer can also use Candid XML attributes name and type to define Candid name and type. If XML document is qualified then it requires candid namespace definition http://ic4j.org/candid.
By default, DOMSerializer and DOMDeserializer will assume that name of array item is item. To modify this name use function arrayItem in DOMSerializer and DOMDeserializer.
The example uses the file with payload as an input.
The Serializer input is the variable type DOM .
To be able to properly map names and values to Candid name types for DOMDeserializer, declare the structure as follows:
Use, or to call the Canister and deserialize output to DOM . Function rootElement is used to define root element of the XML structure. To set in XML output use setAttributes function with true value.
XSI XML namespace is http://www.w3.org/2001/XMLSchema-instance. Type is defined as XML Schema type .