4.2 YAML
The same data from Chapter 4.1 can be recorded in the YAML format:
cities:
- from:
- Brussels
- {to: London, distance: 322}
- {to: Paris, distance: 265}
- from:
- London
- {to: Brussels, distance: 322}
- {to: Paris, distance: 344}
Since the YAML format is just a different structure notation than JSON,
the X-definition will be the same as in the previous Chapter 4.1:
<xd:def xmlns:xd="http://www.xdef.org/xdef/4.2" name="Test" root="Distancies" >
<xd:json name="test">
{ "cities" : [
{ %script = "occurs 1..*;",
"from": [ "string();",
{ %script = "occurs 1..*;",
"to": "jstring();", "distance": "int();"
}
]
}
]
}
</xd:json>
</xd:def>
You can try it
HERE