basic JSON problem
Monday, 9 November 2015 · 6 messages · last reply 10 Nov 2015
FG
Florent Gallaire9 Nov 2015 04:19 #
I would like to use the new "basic" JSON via REST.
With basex 8.3.1 and 8.3.2beta,
my_request&method=json&json=format=jsonml
works fine, but
my_request&method=json&json=format=basic
returns :
[FOJS0006] Element 'article' has invalid namespace: ''.
What's the problem ?
Best regards
Florent
--
FLOSS Engineer & Lawyer
CG
Christian Grün9 Nov 2015 10:17 #
Hi Florent,
When using a JSON format other than jsonml, your XML document to be output must comply with the rules specified in the particular format [1,2]:
xml-to-json(<string
xmlns="http://www.w3.org/2005/xpath-functions">JSON</string>) ...versus...
xml-to-json(<string>JSON</string>)Quoted text · Florent Gallaire · 17 lines
On Mon, Nov 9, 2015 at 4:19 AM, Florent Gallaire <fgallaire at gmail.com> wrote: > I would like to use the new "basic" JSON via REST. > With basex 8.3.1 and 8.3.2beta, > my_request&method=json&json=format=jsonml > works fine, but > my_request&method=json&json=format=basic > returns : > [FOJS0006] Element 'article' has invalid namespace: ''. > > What's the problem ? > > Best regards > > Florent > > -- > FLOSS Engineer & Lawyer
FG
Florent Gallaire10 Nov 2015 00:49 #
Hi Christian,
that's what I was afraid,
http://www.w3.org/TR/xslt-30/#func-xml-to-json
is just too complex to understand for me.
What about your simple-json try ?
to have an easy:
my_request&method=json&json=format=simple
Best regards
Florent
2015-11-09 10:17 GMT+01:00 Christian Grün <christian.gruen at gmail.com>:
Quoted text · Christian Grün · 34 lines
> Hi Florent, > > When using a JSON format other than jsonml, your XML document to be > output must comply with the rules specified in the particular format > [1,2]: > > xml-to-json(<string > xmlns="http://www.w3.org/2005/xpath-functions">JSON</string>) > > ...versus... > > xml-to-json(<string>JSON</string>) > > [1] http://docs.basex.org/wiki/Json_Module > [2] http://docs.basex.org/wiki/XQuery_3.1#fn:json-to-xml > > > On Mon, Nov 9, 2015 at 4:19 AM, Florent Gallaire <fgallaire at gmail.com> wrote: >> I would like to use the new "basic" JSON via REST. >> With basex 8.3.1 and 8.3.2beta, >> my_request&method=json&json=format=jsonml >> works fine, but >> my_request&method=json&json=format=basic >> returns : >> [FOJS0006] Element 'article' has invalid namespace: ''. >> >> What's the problem ? >> >> Best regards >> >> Florent >> >> -- >> FLOSS Engineer & Lawyer
--
FLOSS Engineer & Lawyer
--
FLOSS Engineer & Lawyer
CG
Christian Grün10 Nov 2015 09:46 #
Quoted text · Florent Gallaire · 7 lines
> that's what I was afraid, > http://www.w3.org/TR/xslt-30/#func-xml-to-json > is just too complex to understand for me. > > What about your simple-json try ? > to have an easy: > my_request&method=json&json=format=simple
The reason for all those complex conversion rules is that the conversions are lossless. With the simple conversion that we discussed earlier, it won't be possible to convert JSON back to the original XML document.
Did you try my XQuery conversion code back then? Does it solve your problems?
Christian
Quoted text · Florent Gallaire · 49 lines
> > Best regards > > Florent > > 2015-11-09 10:17 GMT+01:00 Christian Grün <christian.gruen at gmail.com>: >> Hi Florent, >> >> When using a JSON format other than jsonml, your XML document to be >> output must comply with the rules specified in the particular format >> [1,2]: >> >> xml-to-json(<string >> xmlns="http://www.w3.org/2005/xpath-functions">JSON</string>) >> >> ...versus... >> >> xml-to-json(<string>JSON</string>) >> >> [1] http://docs.basex.org/wiki/Json_Module >> [2] http://docs.basex.org/wiki/XQuery_3.1#fn:json-to-xml >> >> >> On Mon, Nov 9, 2015 at 4:19 AM, Florent Gallaire <fgallaire at gmail.com> wrote: >>> I would like to use the new "basic" JSON via REST. >>> With basex 8.3.1 and 8.3.2beta, >>> my_request&method=json&json=format=jsonml >>> works fine, but >>> my_request&method=json&json=format=basic >>> returns : >>> [FOJS0006] Element 'article' has invalid namespace: ''. >>> >>> What's the problem ? >>> >>> Best regards >>> >>> Florent >>> >>> -- >>> FLOSS Engineer & Lawyer > > > > -- > FLOSS Engineer & Lawyer > > > -- > FLOSS Engineer & Lawyer
FG
Florent Gallaire10 Nov 2015 10:19 #
Quoted text · Christian Grün · 1 line
> Did you try my XQuery conversion code back then? Does it solve your problems?
Not heavily tested, but yes it works great for me.
It should be included in BaseX.
Florent
Quoted text · Christian Grün · 52 lines
> Christian > > >> >> Best regards >> >> Florent >> >> 2015-11-09 10:17 GMT+01:00 Christian Grün <christian.gruen at gmail.com>: >>> Hi Florent, >>> >>> When using a JSON format other than jsonml, your XML document to be >>> output must comply with the rules specified in the particular format >>> [1,2]: >>> >>> xml-to-json(<string >>> xmlns="http://www.w3.org/2005/xpath-functions">JSON</string>) >>> >>> ...versus... >>> >>> xml-to-json(<string>JSON</string>) >>> >>> [1] http://docs.basex.org/wiki/Json_Module >>> [2] http://docs.basex.org/wiki/XQuery_3.1#fn:json-to-xml >>> >>> >>> On Mon, Nov 9, 2015 at 4:19 AM, Florent Gallaire <fgallaire at gmail.com> wrote: >>>> I would like to use the new "basic" JSON via REST. >>>> With basex 8.3.1 and 8.3.2beta, >>>> my_request&method=json&json=format=jsonml >>>> works fine, but >>>> my_request&method=json&json=format=basic >>>> returns : >>>> [FOJS0006] Element 'article' has invalid namespace: ''. >>>> >>>> What's the problem ? >>>> >>>> Best regards >>>> >>>> Florent >>>> >>>> -- >>>> FLOSS Engineer & Lawyer >> >> >> >> -- >> FLOSS Engineer & Lawyer >> >> >> -- >> FLOSS Engineer & Lawyer
--
FLOSS Engineer & Lawyer
CG
Christian Grün10 Nov 2015 10:20 #
Quoted text · Florent Gallaire · 2 lines
> Not heavily tested, but yes it works great for me. > It should be included in BaseX.
In order to include it, I would need to do more testing. If you experience unexpected behavior, feel free to tell us.
Quoted text · Florent Gallaire · 60 lines
> > Florent > >> Christian >> >> >>> >>> Best regards >>> >>> Florent >>> >>> 2015-11-09 10:17 GMT+01:00 Christian Grün <christian.gruen at gmail.com>: >>>> Hi Florent, >>>> >>>> When using a JSON format other than jsonml, your XML document to be >>>> output must comply with the rules specified in the particular format >>>> [1,2]: >>>> >>>> xml-to-json(<string >>>> xmlns="http://www.w3.org/2005/xpath-functions">JSON</string>) >>>> >>>> ...versus... >>>> >>>> xml-to-json(<string>JSON</string>) >>>> >>>> [1] http://docs.basex.org/wiki/Json_Module >>>> [2] http://docs.basex.org/wiki/XQuery_3.1#fn:json-to-xml >>>> >>>> >>>> On Mon, Nov 9, 2015 at 4:19 AM, Florent Gallaire <fgallaire at gmail.com> wrote: >>>>> I would like to use the new "basic" JSON via REST. >>>>> With basex 8.3.1 and 8.3.2beta, >>>>> my_request&method=json&json=format=jsonml >>>>> works fine, but >>>>> my_request&method=json&json=format=basic >>>>> returns : >>>>> [FOJS0006] Element 'article' has invalid namespace: ''. >>>>> >>>>> What's the problem ? >>>>> >>>>> Best regards >>>>> >>>>> Florent >>>>> >>>>> -- >>>>> FLOSS Engineer & Lawyer >>> >>> >>> >>> -- >>> FLOSS Engineer & Lawyer >>> >>> >>> -- >>> FLOSS Engineer & Lawyer > > > > -- > FLOSS Engineer & Lawyer
Written for BaseX 8.3. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery