OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] The perils of using the @ symbol in JSON key name ...mapping JSON to XML, Schematron, XSLT, XPath, and/or XQuery

Hi Roger,

I think it depends on the use case. If you have full control over the
JSON documents at hand, you may consider introducing restrictions such
as the example you mention, which allows you to have a mapping from
JSON strings to XML names and have a more compact mapping. If however
you have no control, engineering wisdom would probably encourage you
to pick a mapping that is capable of mapping the entire JSON language
to a reasonable extent (issues with special characters may still
arise), in order to avoid spending hours on manual fixes. I have John
Snelson's mapping in mind, which if my recollection is correct creates
XML such as

<pair name="@bar" type="string">...</pair>

instead, where this special character poses no issue.

Also, there are JSON technologies for schemas and queries out there
already, which you can easily find on a search engine. My
understanding is that the main issue is more about getting them
standardized across all industry players, and taking the time to make
sure that the obtained standards are well engineered -- like XML
technologies at W3C.

Converting JSON to XML has a price in terms of performance. I do not
wish to enter the simplicity debate between XML and JSON here, I think
it suffices to say that the conversion back and forth itself costs
something. If performance is really important, you may find it
desirable to work directly in the JSON world and stick to working on
the/a JSON data model in memory and on the storage layer.

Kind regards,

On Mon, Aug 17, 2015 at 4:18 PM, Costello, Roger L. <costello@mitre.org> wrote:
> Hi Folks,
> In XML documents an element name cannot begin with the @ symbol; this is illegal:
>         <@foo />
> Likewise an attribute name cannot begin with an @ symbol; this is illegal:
>         <Document @id="..." />
> Schematron, XPath, and XQuery uses the @ symbol to denote "attribute"; for example:
>         Book/@id
> JSON places no restrictions on the symbols used in JSON object keys; in particular, a key name may start with the @ symbol. For example, this is perfectly legal:
>         {
>             "@bar": "..."
>         }
> At the present time in history XML has a  much richer suite of tools than JSON. For example, there is nothing in the JSON tool suite that can match the ability of Schematron to declaratively express codependency rules; there is nothing in the JSON tool suite analogous to XSLT, XPath, or XQuery. So I would imagine that at least for the foreseeable future people will convert JSON to XML, Schematron, XSLT, XPath, and/or XQuery to leverage the rich XML tool suite.
> In light of this it seems reasonable to me that when designing JSON documents it would be well-advised to heed some of the XML naming requirements such as, "a name must not begin with an @ symbol".
> Question: would you please provide a concrete example to illustrate a problem with converting JSON to XML, Schematron, XSLT, XPath, and/or XQuery when the JSON contains key names that start with an @ symbol?
> /Roger
> _______________________________________________________________________
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS