[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to unescape slash character using xml-to-json

Subject: Re: How to unescape slash character using xml-to-json ?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 24 Oct 2019 05:14:16 -0000
Re:  How to unescape slash character using xml-to-json
Note: the reason that solidus is escaped by default is because the JSON can
then be embedded in an HTML5 script tag. See explanation here:

https://stackoverflow.com/questions/1580647/json-why-are-forward-slashes-esca
ped

There was considerable debate about this decision, as you can imagine: it's
one that suits some use cases and not others.

Michael Kay
Saxonica

> On 24 Oct 2019, at 01:25, Tim Thompson timathom@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hi, Matthieu,
>
> See Martin Honnen's answer here:
>
>
https://stackoverflow.com/questions/44610431/json-serialization-with-xpath-3-
1-fnserialize
<https://stackoverflow.com/questions/44610431/json-serialization-with-xpath-3
-1-fnserialize>
>
> Updated example: https://xsltfiddle.liberty-development.net/bwdwrV/2
<https://xsltfiddle.liberty-development.net/bwdwrV/2>
>
>
> --
> Tim A. Thompson
> Discovery Metadata Librarian
> Yale University Library
>
> On Wed, Oct 23, 2019 at 6:59 PM Matthieu RICAUD-DUSSARGET
m.ricaud-dussarget@xxxxxxxxxxxxxxxxxx
<mailto:m.ricaud-dussarget@xxxxxxxxxxxxxxxxxx>
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx
<mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>> wrote:
> Hi all,
>
>
>
> I need to generate this json output :
>
>
>
> {"test":"foo/bar"}
>
>
>
> I use XSLT3 function fn:xml-to-json to do this.
>
> My input is :
>
>
>
> <fn:map xmlns:fn="http://www.w3.org/2005/xpath-functions
<http://www.w3.org/2005/xpath-functions>">
>
>     <fn:string key="test" escaped="false">foo/bar</fn:string>
>
> </fn:map>
>
>
>
> But I always get this result with escaped slash :
>
>
>
> {"test":"foo\/bar"}
>
>
>
> Reading the spec at https://www.w3.org/TR/xslt-30/#func-xml-to-json
<https://www.w3.org/TR/xslt-30/#func-xml-to-json> at paragraph bStrings are
escaped as follows:b it looks like I canbt unescape b/b (solidus?)
character.
>
>
>
> Is there really no way to do that using XSLT3  json functionality ? Did I
missed something obvious ?
>
>
>
> Here is a running test : https://xsltfiddle.liberty-development.net/bwdwrV
<https://xsltfiddle.liberty-development.net/bwdwrV>
>
>
> Thanks in advance,
>
>
>
> Cordialement,
>
> <image002.jpg>Matthieu RICAUD-DUSSARGET
>
> Expert XML
> SI EDITORIAL
>
> TC)l. +33 6 63 25 95 58
> 80, avenue de la Marne 92120 Montrouge
>
>
>
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/885568> (by
email <applewebdata://EDAE016E-9A44-4EE5-8C78-0E0733D5ECF7>)
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by
email <>)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.