Converting XML to JSON

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Converting XML to JSON

cmarchand
Hello,


I try to convert a XML piece to JSON. I use fn:serialize, but without
success, it still produces escaped anchors...

Attached, the XSL, the XML. The command I use is :

java -jar saxon9ee.jar -xsl:xml-to-json.xsl -s:simple.xml -o:/dev/null

Thanks in advance or your help,
Christophe


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 

simple.xml (101 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Converting XML to JSON

Martin Honnen-2
On 27.10.2016 16:43, Christophe Marchand wrote:

> I try to convert a XML piece to JSON. I use fn:serialize, but without
> success, it still produces escaped anchors...
>
> Attached, the XSL, the XML.

It seems the XSL did not come through, the message I have received only
has the XML attached.


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Converting XML to JSON

cmarchand
In reply to this post by cmarchand

With the attachments...

Thanks, Martin


Le 27/10/2016 à 16:43, Christophe Marchand a écrit :
Hello,


I try to convert a XML piece to JSON. I use fn:serialize, but without success, it still produces escaped anchors...

Attached, the XSL, the XML. The command I use is :

java -jar saxon9ee.jar -xsl:xml-to-json.xsl -s:simple.xml -o:/dev/null

Thanks in advance or your help,
Christophe



------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 

xml-to-json.xsl (1K) Download Attachment
simple.xml (101 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Converting XML to JSON

Martin Honnen-2
On 27.10.2016 17:06, Christophe Marchand wrote:
> With the attachments...

>> I try to convert a XML piece to JSON. I use fn:serialize, but without
>> success, it still produces escaped anchors...
>>
>> Attached, the XSL, the XML. The command I use is :
>>
>> java -jar saxon9ee.jar -xsl:xml-to-json.xsl -s:simple.xml -o:/dev/null

So which result do you want? I don't think there is a unique
representation of XML as JSON and the output method 'json' is in my
understanding mainly useful to directly serialize XSLT/XPath 3.1 maps
and arrays as JSON.

If you have arbitrary XML and want a certain JSON representation then
you need to transform it to maps/arrays or to the XML format supported
by the xml-to-json function
https://www.w3.org/XML/Group/qtspecs/specifications/xslt-30/html/#xml-to-json-transformation.


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Converting XML to JSON

cmarchand
Ok, I see.

I thought there was a "magic" transform from any kind of XML to json.

Thanks Martin, I now have to code the magic...


Best regards,
Christophe


Le 27/10/2016 à 17:16, Martin Honnen a écrit :

> On 27.10.2016 17:06, Christophe Marchand wrote:
>> With the attachments...
>>> I try to convert a XML piece to JSON. I use fn:serialize, but without
>>> success, it still produces escaped anchors...
>>>
>>> Attached, the XSL, the XML. The command I use is :
>>>
>>> java -jar saxon9ee.jar -xsl:xml-to-json.xsl -s:simple.xml -o:/dev/null
> So which result do you want? I don't think there is a unique
> representation of XML as JSON and the output method 'json' is in my
> understanding mainly useful to directly serialize XSLT/XPath 3.1 maps
> and arrays as JSON.
>
> If you have arbitrary XML and want a certain JSON representation then
> you need to transform it to maps/arrays or to the XML format supported
> by the xml-to-json function
> https://www.w3.org/XML/Group/qtspecs/specifications/xslt-30/html/#xml-to-json-transformation.
>
>
> ------------------------------------------------------------------------------
> The Command Line: Reinvented for Modern Developers
> Did the resurgence of CLI tooling catch you by surprise?
> Reconnect with the command line and become more productive.
> Learn the new .NET and ASP.NET CLI. Get your free copy!
> http://sdm.link/telerik
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Converting XML to JSON

Michael Kay

> On 27 Oct 2016, at 16:35, Christophe Marchand <[hidden email]> wrote:
>
> Ok, I see.
>
> I thought there was a "magic" transform from any kind of XML to json.
>

I think that will turn out to be a widely-held misconception.

Michael Kay
Saxonica



------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Converting XML to JSON

cmarchand
Yes !


Le 27/10/2016 à 17:58, Michael Kay a écrit :

>> On 27 Oct 2016, at 16:35, Christophe Marchand <[hidden email]> wrote:
>>
>> Ok, I see.
>>
>> I thought there was a "magic" transform from any kind of XML to json.
>>
> I think that will turn out to be a widely-held misconception.
>
> Michael Kay
> Saxonica
>
>
>
> ------------------------------------------------------------------------------
> The Command Line: Reinvented for Modern Developers
> Did the resurgence of CLI tooling catch you by surprise?
> Reconnect with the command line and become more productive.
> Learn the new .NET and ASP.NET CLI. Get your free copy!
> http://sdm.link/telerik
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help