Re: ANN: XML Schema to JSON Schema XQuery transform

There is JSON Schema http://json-schema.org/ <http://json-schema.org/>

The code is currently draft 4.  It will have a flag for draft 7 that has been submitted to IETF.

> On Dec 21, 2017, at 11:02 PM, Mukul Gandhi <gandhi.mukul@gmail.com> wrote:
> 
> Thanks, for your reply.
> 
> I thought that JSON didn't had a standard for its schema representation. What standard for JSON, are you complying with?
> 
> 
> On 19 December 2017 at 00:04, Loren Cahlander <loren.cahlander@gmail.com <mailto:loren.cahlander@gmail.com>> wrote:
> The library module relies on XQuery 3.1 due to the use of maps.  
> 
> It can be used in MarkLogic with the version of ML that incorporates maps.
> 
> It can also be run in eXist-db.
> 
> To run this from the command line would be:
> 
> java -cp saxon9ee.jar net.sf.saxon.Query -q:load-xsd.xqy -s:schema2translate.xsd -o:translated-schema.json
> 
> NOTE:
>  I have also added a flag for preserving namespace prefixes in the JSON Schema
> 
> Create an XQuery file called load-xsd.xqy with the following:
> 
> xquery version "3.1";
> import module namespace xsd2json="http://easymetahub.com/ns/xsd2json <http://easymetahub.com/ns/xsd2json>" at "xsd2json.xqy";
> declare namespace map = "http://www.w3.org/2005/xpath-functions/map <http://www.w3.org/2005/xpath-functions/map>";
> declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization <http://www.w3.org/2010/xslt-xquery-serialization>";
> declare namespace xs="http://www.w3.org/2001/XMLSchema <http://www.w3.org/2001/XMLSchema>";
> declare option output:method "json";
> declare option output:indent "yes";
> xsd2json:run(.//xs:schema, map { ‘keepNamespace’: Fn:true() } )
> 
>  
> 
>> On Dec 15, 2017, at 1:36 AM, Mukul Gandhi <gandhi.mukul@gmail.com <mailto:gandhi.mukul@gmail.com>> wrote:
>> 
>> I'm trying to run the utility you've created.
>> 
>> Can you please let me know the command line for same (for e.g, XQueryProcessor <arguments>)?
>> 
>> On 14 December 2017 at 02:21, Loren Cahlander <loren.cahlander@gmail.com <mailto:loren.cahlander@gmail.com>> wrote:
>> Hello folks,
>> 
>> I have started the creation of an XML Schema to JSON Schema transform written in XQuery.  I would appreciate the reporting of any issues that you find and any suggestions that you may have for the codebase.
>> 
>> One question that I received today is how am I handling namespaces.  The script, currently, strips out the namespaces.  One suggestion was to put the prefix in the property’s name.  
>> 
>> I am figuring that I will need to add the passing of options to the process.  Suggestions of options to control the transform are also appreciated.
>> 
>> It is a work in progress.
>> 
>> https://gist.github.com/lcahlander/0eecf499dfe307d7aecbb15f775bd4f2 <https://gist.github.com/lcahlander/0eecf499dfe307d7aecbb15f775bd4f2>
>> 
>> Thank you,
>> 
>> Loren Cahlander
> 
> 
> 
> 
> -- 
> Regards,
> Mukul Gandhi

Received on Friday, 22 December 2017 05:20:51 UTC