Lookups and arrows

Saturday, 9 January 2016 · 6 messages · last reply 10 Jan 2016
JW
Joe Wicentowskiin reply to Tim Thompson, 9 Jan 2016, 22:119 Jan 2016 21:53 #
Hi Tim, For your first question, I think your example falls into what the spec calls "funky looking" keys. See the 3rd bullet point example under http://www.w3.org/TR/xquery-31/#id-lookup:
Quoted text · Tim Thompson · 1 line
> funky / <looking @string") is equivalent to .("$funky / <looking @string"), an appropriate lookup for a map with rather odd conventions for keys.
In other words, I think you're stuck with the ("@context") approach. As to your second question, it looks like what you're proposing should work - but am I reading you as saying you get an error with your proposed approach? If so, what's the error? Joe Sent from my iPad _____________________________
Quoted text · Tim Thompson · 26 lines
From: Tim Thompson <timathom at gmail.com> Sent: Saturday, January 9, 2016 3:11 PM Subject: [basex-talk] Lookups and arrows To: BaseX <basex-talk at mailman.uni-konstanz.de> Hello, I'm testing some XQuery 3.1 features against a JSON-LD[1] document and had a few questions. In the JSON-LD format, the "@" symbol has special semantics in key names, but seems to cause problems with the 3.1 lookup operator. For example: json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") works as expected, but json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")?@context throws an error: [XPST0003] No specifier after lookup operator: '@'. Also, when using the "=>" operator, should it be possible to perform a lookup on the last expression in a chain, if that expression returns a map? For example: json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") evaluates to " http://iiif.io/api/presentation/2/context.json" and json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") => json-doc() returns another map object. So, how would one achieve this: json-doc(json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context"))("@context") using the arrow operator? Thanks, Tim [1] http://www.w3.org/TR/json-ld/ -- Tim A. Thompson Metadata Librarian (Spanish/Portuguese Specialty) Princeton University Library
TT
Tim Thompson9 Jan 2016 22:11 #
Hello, I'm testing some XQuery 3.1 features against a JSON-LD[1] document and had a few questions. In the JSON-LD format, the "@" symbol has special semantics in key names, but seems to cause problems with the 3.1 lookup operator. For example: json-doc("http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") works as expected, but json-doc("http://lae.princeton.edu/catalog/0bp35.jsonld")?@context throws an error: [XPST0003] No specifier after lookup operator: '@'. Also, when using the "=>" operator, should it be possible to perform a lookup on the last expression in a chain, if that expression returns a map? For example: json-doc("http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") evaluates to "http://iiif.io/api/presentation/2/context.json" and json-doc("http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") => json-doc() returns another map object. So, how would one achieve this: json-doc(json-doc("http://lae.princeton.edu/catalog/0bp35.jsonld ")("@context"))("@context") using the arrow operator? Thanks, Tim [1] http://www.w3.org/TR/json-ld/
-- Tim A. Thompson Metadata Librarian (Spanish/Portuguese Specialty) Princeton University Library
TT
Tim Thompsonin reply to Joe Wicentowski, 9 Jan 2016, 21:5310 Jan 2016 02:20 #
Thanks, Joe! I guess I'd glossed over the "funky" example ;-) Regarding the arrow operator, I was wondering whether something like this was possible: json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") => json-doc()("@context") which throws an error: [XPST0003] Unexpected end of query: '("@context")'. Tim
Quoted text · Joe Wicentowski · 81 lines
On Sat, Jan 9, 2016 at 3:53 PM, Joe Wicentowski <joewiz at gmail.com> wrote: > Hi Tim, > > For your first question, I think your example falls into what the spec > calls "funky looking" keys. See the 3rd bullet point example under > http://www.w3.org/TR/xquery-31/#id-lookup: > > > funky / <looking @string") is equivalent to .("$funky / <looking > @string"), an appropriate lookup for a map with rather odd conventions for > keys. > > In other words, I think you're stuck with the ("@context") approach. > > As to your second question, it looks like what you're proposing should > work - but am I reading you as saying you get an error with your proposed > approach? If so, what's the error? > > Joe > > Sent from my iPad > > _____________________________ > From: Tim Thompson <timathom at gmail.com> > Sent: Saturday, January 9, 2016 3:11 PM > Subject: [basex-talk] Lookups and arrows > To: BaseX <basex-talk at mailman.uni-konstanz.de> > > > > Hello, > > I'm testing some XQuery 3.1 features against a JSON-LD[1] document and had > a few questions. In the JSON-LD format, the "@" symbol has special > semantics in key names, but seems to cause problems with the 3.1 lookup > operator. > > For example: > > json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") > > works as expected, but > > json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")?@context > > throws an error: [XPST0003] No specifier after lookup operator: '@'. > > Also, when using the "=>" operator, should it be possible to perform a > lookup on the last expression in a chain, if that expression returns a map? > > For example: > > json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") > evaluates to " http://iiif.io/api/presentation/2/context.json" > > and > > json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") => > json-doc() > > returns another map object. So, how would one achieve this: > > json-doc(json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context"))("@context") > > > using the arrow operator? > > Thanks, > Tim > > > [1] http://www.w3.org/TR/json-ld/ > > > -- > Tim A. Thompson > Metadata Librarian (Spanish/Portuguese Specialty) > Princeton University Library > > > >
JW
Joe Wicentowski10 Jan 2016 05:55 #
Hi Tim, "Funky" made me chuckle too! I tested your code with the closest thing at hand - a local build of branch of Wolfgang Meier's eXist repo with support for the arrow operator (https://github.com/wolfgangmm/exist/tree/feature/arrowop) - and your code worked fine there. So my hunch is that there's a bug in BaseX or some syntax error I'm not seeing in your code. For the record, here's the code I'm running:
-- xquery version "3.1"; json-doc("http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") => json-doc()("@context") -- To check the results I actually use `=> serialize(<serialization-parameters xmlns="http://www.w3.org/2010/xslt-xquery-serialization"><method>json</method><indent>yes</indent></serialization-parameters>)` on the results since eXist doesn't support adaptive serialization. I hope this is helpful. Joe
Quoted text · Tim Thompson · 92 lines
On Sat, Jan 9, 2016 at 6:20 PM, Tim Thompson <timathom at gmail.com> wrote: > Thanks, Joe! I guess I'd glossed over the "funky" example ;-) Regarding the > arrow operator, I was wondering whether something like this was possible: > > json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") => > json-doc()("@context") > > which throws an error: [XPST0003] Unexpected end of query: '("@context")'. > > Tim > > On Sat, Jan 9, 2016 at 3:53 PM, Joe Wicentowski <joewiz at gmail.com> wrote: >> >> Hi Tim, >> >> For your first question, I think your example falls into what the spec >> calls "funky looking" keys. See the 3rd bullet point example under >> http://www.w3.org/TR/xquery-31/#id-lookup: >> >> > funky / <looking @string") is equivalent to .("$funky / <looking >> > @string"), an appropriate lookup for a map with rather odd conventions for >> > keys. >> >> In other words, I think you're stuck with the ("@context") approach. >> >> As to your second question, it looks like what you're proposing should >> work - but am I reading you as saying you get an error with your proposed >> approach? If so, what's the error? >> >> Joe >> >> Sent from my iPad >> >> _____________________________ >> From: Tim Thompson <timathom at gmail.com> >> Sent: Saturday, January 9, 2016 3:11 PM >> Subject: [basex-talk] Lookups and arrows >> To: BaseX <basex-talk at mailman.uni-konstanz.de> >> >> >> >> Hello, >> >> I'm testing some XQuery 3.1 features against a JSON-LD[1] document and had >> a few questions. In the JSON-LD format, the "@" symbol has special semantics >> in key names, but seems to cause problems with the 3.1 lookup operator. >> >> For example: >> >> json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") >> >> works as expected, but >> >> json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")?@context >> >> throws an error: [XPST0003] No specifier after lookup operator: '@'. >> >> Also, when using the "=>" operator, should it be possible to perform a >> lookup on the last expression in a chain, if that expression returns a map? >> >> For example: >> >> json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") >> evaluates to " http://iiif.io/api/presentation/2/context.json" >> >> and >> >> json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") => >> json-doc() >> >> returns another map object. So, how would one achieve this: >> >> json-doc(json-doc(" >> http://lae.princeton.edu/catalog/0bp35.jsonld")("@context"))("@context") >> >> using the arrow operator? >> >> Thanks, >> Tim >> >> >> [1] http://www.w3.org/TR/json-ld/ >> >> >> -- >> Tim A. Thompson >> Metadata Librarian (Spanish/Portuguese Specialty) >> Princeton University Library >> >> >> >
CG
Christian Grün10 Jan 2016 09:50 #
Hi Tim, hi Joe, The query works if you use parentheses around the arrow operands: (json-doc("http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") => json-doc())("@context") This is in compliance with the XQuery 3.1 spec [1]. Out of interest, I spent some time and looked up the W3 bug tracker history, and I spotted a change in the precedence of the arrow operator [2]. Maybe this change is not reflected in eXist? Hope this helps, Christian [1] http://www.w3.org/TR/xquery-31/#doc-xquery31-ArrowExpr [2] https://www.w3.org/Bugs/Public/show_bug.cgi?id=27537
Quoted text · Joe Wicentowski · 115 lines
> I tested your code with the closest thing at hand - a local build of > branch of Wolfgang Meier's eXist repo with support for the arrow > operator (https://github.com/wolfgangmm/exist/tree/feature/arrowop) - > and your code worked fine there. So my hunch is that there's a bug in > BaseX or some syntax error I'm not seeing in your code. For the > record, here's the code I'm running: > > -- > xquery version "3.1"; > > json-doc("http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") > => json-doc()("@context") > -- > > To check the results I actually use `=> > serialize(<serialization-parameters > xmlns="http://www.w3.org/2010/xslt-xquery-serialization"><method>json</method><indent>yes</indent></serialization-parameters>)` > on the results since eXist doesn't support adaptive serialization. > > I hope this is helpful. > > Joe > > On Sat, Jan 9, 2016 at 6:20 PM, Tim Thompson <timathom at gmail.com> wrote: >> Thanks, Joe! I guess I'd glossed over the "funky" example ;-) Regarding the >> arrow operator, I was wondering whether something like this was possible: >> >> json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") => >> json-doc()("@context") >> >> which throws an error: [XPST0003] Unexpected end of query: '("@context")'. >> >> Tim >> >> On Sat, Jan 9, 2016 at 3:53 PM, Joe Wicentowski <joewiz at gmail.com> wrote: >>> >>> Hi Tim, >>> >>> For your first question, I think your example falls into what the spec >>> calls "funky looking" keys. See the 3rd bullet point example under >>> http://www.w3.org/TR/xquery-31/#id-lookup: >>> >>> > funky / <looking @string") is equivalent to .("$funky / <looking >>> > @string"), an appropriate lookup for a map with rather odd conventions for >>> > keys. >>> >>> In other words, I think you're stuck with the ("@context") approach. >>> >>> As to your second question, it looks like what you're proposing should >>> work - but am I reading you as saying you get an error with your proposed >>> approach? If so, what's the error? >>> >>> Joe >>> >>> Sent from my iPad >>> >>> _____________________________ >>> From: Tim Thompson <timathom at gmail.com> >>> Sent: Saturday, January 9, 2016 3:11 PM >>> Subject: [basex-talk] Lookups and arrows >>> To: BaseX <basex-talk at mailman.uni-konstanz.de> >>> >>> >>> >>> Hello, >>> >>> I'm testing some XQuery 3.1 features against a JSON-LD[1] document and had >>> a few questions. In the JSON-LD format, the "@" symbol has special semantics >>> in key names, but seems to cause problems with the 3.1 lookup operator. >>> >>> For example: >>> >>> json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") >>> >>> works as expected, but >>> >>> json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")?@context >>> >>> throws an error: [XPST0003] No specifier after lookup operator: '@'. >>> >>> Also, when using the "=>" operator, should it be possible to perform a >>> lookup on the last expression in a chain, if that expression returns a map? >>> >>> For example: >>> >>> json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") >>> evaluates to " http://iiif.io/api/presentation/2/context.json" >>> >>> and >>> >>> json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") => >>> json-doc() >>> >>> returns another map object. So, how would one achieve this: >>> >>> json-doc(json-doc(" >>> http://lae.princeton.edu/catalog/0bp35.jsonld")("@context"))("@context") >>> >>> using the arrow operator? >>> >>> Thanks, >>> Tim >>> >>> >>> [1] http://www.w3.org/TR/json-ld/ >>> >>> >>> -- >>> Tim A. Thompson >>> Metadata Librarian (Spanish/Portuguese Specialty) >>> Princeton University Library >>> >>> >>> >>
JW
Joe Wicentowski10 Jan 2016 12:13 #
Thanks very much for this info, Christian! I'll pass your observations on to the eXist team. Joe
Quoted text · Christian Grün · 139 lines
On Sun, Jan 10, 2016 at 3:50 AM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Tim, hi Joe, > > The query works if you use parentheses around the arrow operands: > > (json-doc("http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") > => json-doc())("@context") > > This is in compliance with the XQuery 3.1 spec [1]. > > Out of interest, I spent some time and looked up the W3 bug tracker > history, and I spotted a change in the precedence of the arrow > operator [2]. Maybe this change is not reflected in eXist? > > Hope this helps, > Christian > > [1] http://www.w3.org/TR/xquery-31/#doc-xquery31-ArrowExpr > [2] https://www.w3.org/Bugs/Public/show_bug.cgi?id=27537 > > > > >> I tested your code with the closest thing at hand - a local build of >> branch of Wolfgang Meier's eXist repo with support for the arrow >> operator (https://github.com/wolfgangmm/exist/tree/feature/arrowop) - >> and your code worked fine there. So my hunch is that there's a bug in >> BaseX or some syntax error I'm not seeing in your code. For the >> record, here's the code I'm running: >> >> -- >> xquery version "3.1"; >> >> json-doc("http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") >> => json-doc()("@context") >> -- >> >> To check the results I actually use `=> >> serialize(<serialization-parameters >> xmlns="http://www.w3.org/2010/xslt-xquery-serialization"><method>json</method><indent>yes</indent></serialization-parameters>)` >> on the results since eXist doesn't support adaptive serialization. >> >> I hope this is helpful. >> >> Joe >> >> On Sat, Jan 9, 2016 at 6:20 PM, Tim Thompson <timathom at gmail.com> wrote: >>> Thanks, Joe! I guess I'd glossed over the "funky" example ;-) Regarding the >>> arrow operator, I was wondering whether something like this was possible: >>> >>> json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") => >>> json-doc()("@context") >>> >>> which throws an error: [XPST0003] Unexpected end of query: '("@context")'. >>> >>> Tim >>> >>> On Sat, Jan 9, 2016 at 3:53 PM, Joe Wicentowski <joewiz at gmail.com> wrote: >>>> >>>> Hi Tim, >>>> >>>> For your first question, I think your example falls into what the spec >>>> calls "funky looking" keys. See the 3rd bullet point example under >>>> http://www.w3.org/TR/xquery-31/#id-lookup: >>>> >>>> > funky / <looking @string") is equivalent to .("$funky / <looking >>>> > @string"), an appropriate lookup for a map with rather odd conventions for >>>> > keys. >>>> >>>> In other words, I think you're stuck with the ("@context") approach. >>>> >>>> As to your second question, it looks like what you're proposing should >>>> work - but am I reading you as saying you get an error with your proposed >>>> approach? If so, what's the error? >>>> >>>> Joe >>>> >>>> Sent from my iPad >>>> >>>> _____________________________ >>>> From: Tim Thompson <timathom at gmail.com> >>>> Sent: Saturday, January 9, 2016 3:11 PM >>>> Subject: [basex-talk] Lookups and arrows >>>> To: BaseX <basex-talk at mailman.uni-konstanz.de> >>>> >>>> >>>> >>>> Hello, >>>> >>>> I'm testing some XQuery 3.1 features against a JSON-LD[1] document and had >>>> a few questions. In the JSON-LD format, the "@" symbol has special semantics >>>> in key names, but seems to cause problems with the 3.1 lookup operator. >>>> >>>> For example: >>>> >>>> json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") >>>> >>>> works as expected, but >>>> >>>> json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")?@context >>>> >>>> throws an error: [XPST0003] No specifier after lookup operator: '@'. >>>> >>>> Also, when using the "=>" operator, should it be possible to perform a >>>> lookup on the last expression in a chain, if that expression returns a map? >>>> >>>> For example: >>>> >>>> json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") >>>> evaluates to " http://iiif.io/api/presentation/2/context.json" >>>> >>>> and >>>> >>>> json-doc(" http://lae.princeton.edu/catalog/0bp35.jsonld")("@context") => >>>> json-doc() >>>> >>>> returns another map object. So, how would one achieve this: >>>> >>>> json-doc(json-doc(" >>>> http://lae.princeton.edu/catalog/0bp35.jsonld")("@context"))("@context") >>>> >>>> using the arrow operator? >>>> >>>> Thanks, >>>> Tim >>>> >>>> >>>> [1] http://www.w3.org/TR/json-ld/ >>>> >>>> >>>> -- >>>> Tim A. Thompson >>>> Metadata Librarian (Spanish/Portuguese Specialty) >>>> Princeton University Library >>>> >>>> >>>> >>>

⚡Generated with XQuery