CARVIEW |
Select Language
HTTP/2 200
server: GitHub.com
content-type: text/html; charset=utf-8
last-modified: Thu, 09 Oct 2025 13:57:28 GMT
access-control-allow-origin: *
etag: W/"68e7bf48-52b5"
expires: Thu, 09 Oct 2025 20:23:51 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: 6DD5:23EF38:F50BD:12071E:68E8177E
accept-ranges: bytes
age: 0
date: Thu, 09 Oct 2025 20:13:52 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210078-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1760040832.816253,VS0,VE330
vary: Accept-Encoding
x-fastly-request-id: 389a1cc78a7faaea664da3c39398f4f101e6ed67
content-length: 3074
Web of Things (WoT) XML Binding
To be defined
Introduction
The following is a draft introduction
This document describes how type definitions described using the Data Schema can be mapped to XML schema definitions by using examples. Given these Data Schemas, providing the mapping to XML schema allows XML tools to directly validate serialized XML data, for example. The XML structure for which this mapping is designed is based on EXI4JSON [exi-for-json].
This document is a work in progress
Binding
Below are some examples of payloads in JSON and their corresponding equivalent payloads in XML.
{ "brightness": 200, "frequency": "fast" }
<object>
<brightness>
<integer>200</integer>
</brightness>
<frequency>
<string>fast</string>
</frequency>
</object>
[ 520, 184, 1314 ]
<array>
<number>520</number>
<number>184</number>
<number>1314</number>
</array>
Object Definition to XML Schema
Shown below is an example Data Schema of an Object Schema. The object consists of two named literalsid
(of type integer
) and name
(of type string
) where
id
is required to be present.
{ "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" } }, "required": [ "id" ] }When the
object
is anonymous (i.e. it is the root, or participates in an
array
definition), the above object
definition transforms to the following XML Schema
element definition.
<xs:element name="object" xmlns:xs="https://www.w3.org/2001/XMLSchema">
<xs:complexType>
<xs:all>
<xs:element name="id">
<xs:complexType>
<xs:sequence>
<xs:element name="integer" type="xs:integer" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="name" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="string" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
Otherwise (i.e. the object
is a member of another object
definition, thus has a name),
the object definition transforms to the following XML schema element definition. Note
$name
represents the name of the object
, and needs to be replaced by the actual name
of the object
.
<xs:element name="$name" xmlns:xs="https://www.w3.org/2001/XMLSchema">
<xs:complexType>
<xs:sequence>
<!--Until the next comment, it is a copy of the previous example-->
<xs:element name="object">
<xs:complexType>
<xs:all>
<xs:element name="id">
<xs:complexType>
<xs:sequence>
<xs:element name="integer" type="xs:integer" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="name" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="string" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<!--Until here-->
</xs:sequence>
</xs:complexType>
</xs:element>
Array Schema to XML Schema
Shown below is an example Data Schema of an Array Schema. Thearray
consists of exactly three
number literals with each value within the value range of [ 0 ... 2047 ].
{ "type": "array", "items": { "type": "number", "minimum": 0, "maximum": 2047 }, "minItems": 3, "maxItems": 3 }When the
array
is anonymous (i.e. it is the root, or participates in another
array
definition), the above array
definition transforms to the following XML Schema
element definition.
<xs:element name="array" xmlns:xs="https://www.w3.org/2001/XMLSchema">
<xs:complexType>
<xs:sequence>
<xs:element name="double" minOccurs="3" maxOccurs="3">
<xs:simpleType name="minInclusive">
<xs:restriction base="xs:double">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="2047"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Otherwise (i.e. the array
is a member of an object
definition, thus has a name), the
array
definition transforms to the following XML schema element definition. Note
$name
represents the name of the array
, and needs to be replaced by the actual name of
the array
.
<xs:element name="$name" xmlns:xs="https://www.w3.org/2001/XMLSchema">
<xs:complexType>
<xs:sequence>
<!--Until the next comment, it is a copy of the previous example-->
<xs:element name="array">
<xs:complexType>
<xs:sequence>
<xs:element name="double" minOccurs="3" maxOccurs="3" >
<xs:simpleType name="minInclusive">
<xs:restriction base="xs:double">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="2047"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!--Until here-->
</xs:sequence>
</xs:complexType>
</xs:element>