Treating JSON as a subset of XML
XForms 1.0 was an XML technology originally designed as a replacement for HTML Forms. In addressing certain shortcomings of XForms 1.0, the next version, XForms 1.1 became far more than a forms language, but a declarative application language where application production time could be reduced by an order of magnitude compared with traditional procedural programming. Although XForms treats its data internally as if it is XML, using XPath both to address data and to calculate new values, it is not the intention that external data necessarily be only in XML. An obvious data format widely in use on the web is JSON. There are several mappings defined in both directions between XML and JSON, but largely because JSON can only represent a subset of what XML can represent, many of the mappings are cumbersome, and make data-references both JSON-specific, and difficult to write. Ideally, an XForm processing JSON data shouldn't have to know which data format has been used, so that JSON data can be selected with natural XPath selectors. Furthermore, XForms doesn't need the full generality of translating any XML to JSON, since the only need is to read and write data to and from existing JSON sources. In other words, it only needs to process existing JSON. This simplifies the mapping, and makes the selectors needed with minor exceptions opaque to the data format. This paper presents the mapping proposed for XForms 2.0, the special cases that have had to be dealt with, and discusses generalisation to other formats, such as VCARD.
|Keywords||XML, JSON, Web, XForms|
|THEME||Software (theme 1), Information (theme 2)|
|Publisher||University of Economics, Prague Prague, Czech Republic|
Pemberton, S. (2012). Treating JSON as a subset of XML. In Proceedings of XML Prague 2012 (pp. 81–90). University of Economics, Prague Prague, Czech Republic.