Skip to content

r-lyeh-archived/JXMLex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 

Repository files navigation

JXMLex, revision 0
==================

JXMLex is an extended JXML file format.
JXMLex is an expressive and relatively small representation of JSON in XML, so data can be reused with XML tools.
JXMLex is based on JSONx and JXML (details at http://github.com/r-lyeh/JXML). 

Pros: JXMLex syntax provides natural and expressive XPath queries by adding attributes and duplicating information.
Cons: JXMLex files are larger than their JXML counterparts.

Pros: JXMLex is a richer superset of JXML. JXML tools can still parse JXMLex files.
Cons: JXMLex attributes are lossy converted from JSON. Read @son attribute to retrieve original name instead.

TL;DR
=====

- Use JXML when a lossless JSON representation is required (details at http://github.com/r-lyeh/JXML).
- Use JXML when size matters (details at http://github.com/r-lyeh/JXML).
- Use JXMLex when complex XPath statements are going to be made (details below).
- Use JXMLex when ease of use and flexibility are mandatory (details below).

Notes
=====

JXMLex syntax is subject to change.


Conversion guide
================

- Convert JSON to JXML by following conversion rules described at JXML reference document (details at http://github.com/r-lyeh/JXML).
- Then, for every XML target node that has a property name, add an attribute whereas propertyname="text()".
- Property name must be escaped to be compliant with XML attribute naming: all invalid characters are escaped to underscore characters.

JXMLex sample
=============

The following example document is a sample of the JSON structure.

    {
      "name/surname":"John Smith",
      "address": {
        "streetAddress": "21 2nd Street",
        "city": "New York",
        "state": "NY",
        "postal-code": 10021,
      },
      "IDs": [
        "2-111",
        "2-222"
      ],
      "additionalInfo": null,
      "remote": false,
      "height": 62.4,
      "ficoScore": "> 640"
    }

The following output is the result of the transformed document to JXMLex.

    <?xml version="1.0" encoding="UTF-8"?>
    <j son="o">
        <j son="s:name" name_surname="John Smith">John Smith</j>
        <j son="o:address" address="">
            <j son="s:streetAddress" streetAddress="21 2nd Street">21 2nd Street</j>
            <j son="s:city" city="New York">New York</j>
            <j son="s:state" state="NY">NY</j>
            <j son="n:postal-code" postal_code="10021">10021</j>
        </j>
        <j son="a:IDs" IDs="">
            <j son="s">2-111</j>
            <j son="s">2-222</j>
        </j>
        <j son="0:additionalInfo" additionalInfo="" />
        <j son="b:remote" remote="false">false</j>
        <j son="n:height" height="62.4">62.4</j>
        <j son="s:ficoScore" ficoScore="&gt; 640">&gt; 640</j>
    </j>

Credits
=======

- JXMLex was created by Mario "rlyeh" Rodriguez.
- JSONx is an IBM® standard format to represent JSON as XML.

About

JXMLex description format

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published