Please don't send presently mails to me I will contact to u later
Thanks, Himalaya -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of [email protected] Sent: Friday, March 13, 2015 11:17 AM To: [email protected] Subject: General Digest, Vol 129, Issue 20 Send General mailing list submissions to [email protected] To subscribe or unsubscribe via the World Wide Web, visit http://developer.marklogic.com/mailman/listinfo/general or, via email, send a message with subject or body 'help' to [email protected] You can reach the person managing the list at [email protected] When replying, please edit your Subject line so it is more specific than "Re: Contents of General digest..." Today's Topics: 1. Re: Constructing JSON objects (Sudhakar Reddy) 2. Re: Constructing JSON objects (Will Thompson) 3. Re: Constructing JSON objects (Michael Blakeley) 4. Re: Constructing JSON objects (David Lee) 5. Nested cts:search() functions over JSON documents (Nick Ardlie) 6. Re: Nested cts:search() functions over JSON documents (Geert Josten) ---------------------------------------------------------------------- Message: 1 Date: Thu, 12 Mar 2015 21:38:38 +0000 From: Sudhakar Reddy <[email protected]> Subject: Re: [MarkLogic Dev General] Constructing JSON objects To: MarkLogic Developer Discussion <[email protected]> Message-ID: <d1275498.3ef88%[email protected]> Content-Type: text/plain; charset="us-ascii" You can also build using JSON node constructors available in ML 8 let $json-node := object-node { "id": number-node {12345}, "a" : array-node {1,2,3} , "b" : fn:true(), "c" : number-node {1234}, "d" : array-node{ number-node {12345}, text {"test"}, boolean-node {fn:true()}, array-node {'aaa','bbb','ccc'}}, "e" : object-node { "x": "hello world", "y": fn:false(), "z" : array-node {1, 'a', fn:true()} }, "g": null-node {} } return $json-node Thanks Sudhakar On 3/11/15, 6:52 PM, "Erik Hennum" <[email protected]> wrote: >Hi, Will: > >You can use json:object() instead of map:map() for a mutable object >where order is important. > >I think the API is the same as that of map:map otherwise. > >JSON nodes, like XML nodes, are immutable. > >Erik Hennum > >________________________________________ >From: [email protected] >[[email protected]] on behalf of Will Thompson >[[email protected]] >Sent: Tuesday, March 10, 2015 5:09 PM >To: MarkLogic Developer Discussion >Subject: [MarkLogic Dev General] Constructing JSON objects > >Is there a nice way to construct a JSON object similar to how maps can >be constructed? Typically I would just do it this way: > >xdmp:to-json( > map:new(( > map:entry('x', 1), > map:entry('y', 2) > ))) > >Except that order is important in this specific scenario, and this >ruins ordering. > >-Will >_______________________________________________ >General mailing list >[email protected] >http://developer.marklogic.com/mailman/listinfo/general >_______________________________________________ >General mailing list >[email protected] >http://developer.marklogic.com/mailman/listinfo/general ------------------------------ Message: 2 Date: Fri, 13 Mar 2015 00:35:59 +0000 From: Will Thompson <[email protected]> Subject: Re: [MarkLogic Dev General] Constructing JSON objects To: MarkLogic Developer Discussion <[email protected]> Message-ID: <[email protected]> Content-Type: text/plain; charset="us-ascii" Thanks all. The ML8 constructors look very nice. Mike - That's what I was looking for, thanks. I ended up writing something similar using json:array before I saw the reply, but I like your implementation better. Also, I appropriated the json: prefix because it looked nicer...for example, is there any reason why this would be bad (other than ML might decide implement it at some later date)? declare function json:new(...) -W > On Mar 12, 2015, at 4:38 PM, Sudhakar Reddy <[email protected]> > wrote: > > You can also build using JSON node constructors available in ML 8 let > $json-node := object-node { "id": number-node {12345}, > "a" : array-node {1,2,3} , > "b" : fn:true(), > "c" : number-node {1234}, > "d" : array-node{ > number-node {12345}, > text {"test"}, > boolean-node {fn:true()}, > array-node {'aaa','bbb','ccc'}}, > "e" : object-node { "x": "hello > world", > "y": fn:false(), > "z" : array-node {1, 'a', > fn:true()} > }, > "g": null-node {} > } > return $json-node > > Thanks > Sudhakar > > > > On 3/11/15, 6:52 PM, "Erik Hennum" <[email protected]> wrote: > >> Hi, Will: >> >> You can use json:object() instead of map:map() for a mutable object >> where order is important. >> >> I think the API is the same as that of map:map otherwise. >> >> JSON nodes, like XML nodes, are immutable. >> >> Erik Hennum >> >> ________________________________________ >> From: [email protected] >> [[email protected]] on behalf of Will Thompson >> [[email protected]] >> Sent: Tuesday, March 10, 2015 5:09 PM >> To: MarkLogic Developer Discussion >> Subject: [MarkLogic Dev General] Constructing JSON objects >> >> Is there a nice way to construct a JSON object similar to how maps >> can be constructed? Typically I would just do it this way: >> >> xdmp:to-json( >> map:new(( >> map:entry('x', 1), >> map:entry('y', 2) >> ))) >> >> Except that order is important in this specific scenario, and this >> ruins ordering. >> >> -Will >> _______________________________________________ >> General mailing list >> [email protected] >> http://developer.marklogic.com/mailman/listinfo/general >> _______________________________________________ >> General mailing list >> [email protected] >> http://developer.marklogic.com/mailman/listinfo/general > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general ------------------------------ Message: 3 Date: Thu, 12 Mar 2015 18:51:40 -0700 From: Michael Blakeley <[email protected]> Subject: Re: [MarkLogic Dev General] Constructing JSON objects To: MarkLogic Developer Discussion <[email protected]> Message-ID: <[email protected]> Content-Type: text/plain; charset=us-ascii I tend to avoid declaring functions or variables in any namespace that I know other code is using. But you're doing it with your eyes open, and that's probably ok. Someday a server update may conflict. But if that happens, I'm sure you'll catch it in testing, and fix it before it breaks production. Right? -- Mike > On 12 Mar 2015, at 17:35 , Will Thompson <[email protected]> wrote: > > Thanks all. The ML8 constructors look very nice. > > Mike - That's what I was looking for, thanks. I ended up writing something > similar using json:array before I saw the reply, but I like your > implementation better. Also, I appropriated the json: prefix because it > looked nicer...for example, is there any reason why this would be bad (other > than ML might decide implement it at some later date)? > > declare function json:new(...) > > -W > >> On Mar 12, 2015, at 4:38 PM, Sudhakar Reddy <[email protected]> >> wrote: >> >> You can also build using JSON node constructors available in ML 8 let >> $json-node := object-node { "id": number-node {12345}, >> "a" : array-node {1,2,3} , >> "b" : fn:true(), >> "c" : number-node {1234}, >> "d" : array-node{ >> number-node {12345}, >> text {"test"}, >> boolean-node {fn:true()}, >> array-node {'aaa','bbb','ccc'}}, >> "e" : object-node { "x": "hello >> world", >> "y": fn:false(), >> "z" : array-node {1, 'a', >> fn:true()} >> }, >> "g": null-node {} >> } >> return $json-node >> >> Thanks >> Sudhakar >> >> >> >> On 3/11/15, 6:52 PM, "Erik Hennum" <[email protected]> wrote: >> >>> Hi, Will: >>> >>> You can use json:object() instead of map:map() for a mutable object >>> where order is important. >>> >>> I think the API is the same as that of map:map otherwise. >>> >>> JSON nodes, like XML nodes, are immutable. >>> >>> Erik Hennum >>> >>> ________________________________________ >>> From: [email protected] >>> [[email protected]] on behalf of Will Thompson >>> [[email protected]] >>> Sent: Tuesday, March 10, 2015 5:09 PM >>> To: MarkLogic Developer Discussion >>> Subject: [MarkLogic Dev General] Constructing JSON objects >>> >>> Is there a nice way to construct a JSON object similar to how maps >>> can be constructed? Typically I would just do it this way: >>> >>> xdmp:to-json( >>> map:new(( >>> map:entry('x', 1), >>> map:entry('y', 2) >>> ))) >>> >>> Except that order is important in this specific scenario, and this >>> ruins ordering. >>> >>> -Will >>> _______________________________________________ >>> General mailing list >>> [email protected] >>> http://developer.marklogic.com/mailman/listinfo/general >>> _______________________________________________ >>> General mailing list >>> [email protected] >>> http://developer.marklogic.com/mailman/listinfo/general >> >> _______________________________________________ >> General mailing list >> [email protected] >> http://developer.marklogic.com/mailman/listinfo/general > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > ------------------------------ Message: 4 Date: Fri, 13 Mar 2015 02:36:03 +0000 From: David Lee <[email protected]> Subject: Re: [MarkLogic Dev General] Constructing JSON objects To: MarkLogic Developer Discussion <[email protected]> Message-ID: <[email protected]> Content-Type: text/plain; charset="us-ascii" Making an XQuery function to call the explicit constructor with variable key names or number of keys is not possible directly There isn't the equivalent of map:entry , field names are constant expressions and the number of fields is constant, unlike element {}{} You would have to resort to string conversions, in memory node operations or evals ... Or stick with json:object() /json:array() Or write it in Javascript In all cases what would the signature be? A fundamental mismatch between XQuery an JSON is sequences vs arrays there are no vararg functions and any construct to nest or bound sequences involves a lot of syntax and temporary objects. If you come up with something let us know! Sent from my iPad (excuse the terseness) David A Lee [email protected] > On Mar 12, 2015, at 9:51 PM, Michael Blakeley <[email protected]> wrote: > > I tend to avoid declaring functions or variables in any namespace that I know > other code is using. But you're doing it with your eyes open, and that's > probably ok. Someday a server update may conflict. But if that happens, I'm > sure you'll catch it in testing, and fix it before it breaks production. > > Right? > > -- Mike > >> On 12 Mar 2015, at 17:35 , Will Thompson <[email protected]> wrote: >> >> Thanks all. The ML8 constructors look very nice. >> >> Mike - That's what I was looking for, thanks. I ended up writing something >> similar using json:array before I saw the reply, but I like your >> implementation better. Also, I appropriated the json: prefix because it >> looked nicer...for example, is there any reason why this would be bad (other >> than ML might decide implement it at some later date)? >> >> declare function json:new(...) >> >> -W >> >>> On Mar 12, 2015, at 4:38 PM, Sudhakar Reddy <[email protected]> >>> wrote: >>> >>> You can also build using JSON node constructors available in ML 8 >>> let $json-node := object-node { "id": number-node {12345}, >>> "a" : array-node {1,2,3} , >>> "b" : fn:true(), >>> "c" : number-node {1234}, >>> "d" : array-node{ >>> number-node {12345}, >>> text {"test"}, >>> boolean-node {fn:true()}, >>> array-node {'aaa','bbb','ccc'}}, >>> "e" : object-node { "x": "hello world", >>> "y": fn:false(), >>> "z" : array-node {1, 'a', fn:true()} >>> }, >>> "g": null-node {} >>> } >>> return $json-node >>> >>> Thanks >>> Sudhakar >>> >>> >>> >>>> On 3/11/15, 6:52 PM, "Erik Hennum" <[email protected]> wrote: >>>> >>>> Hi, Will: >>>> >>>> You can use json:object() instead of map:map() for a mutable object where >>>> order is important. >>>> >>>> I think the API is the same as that of map:map otherwise. >>>> >>>> JSON nodes, like XML nodes, are immutable. >>>> >>>> Erik Hennum >>>> >>>> ________________________________________ >>>> From: [email protected] >>>> [[email protected]] on behalf of Will Thompson >>>> [[email protected]] >>>> Sent: Tuesday, March 10, 2015 5:09 PM >>>> To: MarkLogic Developer Discussion >>>> Subject: [MarkLogic Dev General] Constructing JSON objects >>>> >>>> Is there a nice way to construct a JSON object similar to how maps can be >>>> constructed? Typically I would just do it this way: >>>> >>>> xdmp:to-json( >>>> map:new(( >>>> map:entry('x', 1), >>>> map:entry('y', 2) >>>> ))) >>>> >>>> Except that order is important in this specific scenario, and this ruins >>>> ordering. >>>> >>>> -Will >>>> _______________________________________________ >>>> General mailing list >>>> [email protected] >>>> http://developer.marklogic.com/mailman/listinfo/general >>>> _______________________________________________ >>>> General mailing list >>>> [email protected] >>>> http://developer.marklogic.com/mailman/listinfo/general >>> >>> _______________________________________________ >>> General mailing list >>> [email protected] >>> http://developer.marklogic.com/mailman/listinfo/general >> >> _______________________________________________ >> General mailing list >> [email protected] >> http://developer.marklogic.com/mailman/listinfo/general > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general ------------------------------ Message: 5 Date: Fri, 13 Mar 2015 16:34:18 +1100 From: Nick Ardlie <[email protected]> Subject: [MarkLogic Dev General] Nested cts:search() functions over JSON documents To: [email protected] Message-ID: <CANf16qd=A=qwja+iq9q1_cfkykb91dzjgsgdpjsvz0d8oeq...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Is it possible to define nested (i.e. path constrained) queries in cts:search() over JSON document types in MarkLogic 8? With XML document types I can nest cts:element-query() functions to achieve this. But I don't seem to be able to use the cts:element-query() function for JSON. Unless I'm missing something? It requires an xs:QName() parameter and a local-name only version of a QName doesn't seem to work for JSON documents. To describe with an example, say I have the following documents (one XML, the other JSON): let $xml-doc := <doc> <foo> <bar>UP HERE</bar> </foo> <baz> <foo> <bar>DOWN HERE</bar> </foo> </baz> </doc> let $json-doc := xdmp:unquote( '{ "foo": { "bar": "UP HERE" }, "baz": { "foo": { "bar": "DOWN HERE" } } }') let $insert-result := (xdmp:document-insert("ID-1", $json-doc), xdmp:document-insert("ID-2", $xml-doc)) With the XML document I can search for foo/bar elements that contain the word "here" like this: return cts:search(doc(), cts:element-query(xs:QName("foo"), cts:element-query(xs:QName("bar"), "here"))) After the above insert this will match the XML document but not the JSON document. I'd like to do the equivalent with the JSON document but the similar cts functions for JSON don't appear to support cts:query nesting (e.g. cts:json-property-value-query()). Is there a way to do this with JSON documents? I know I can constrain the first expression argument to cts:search with an XPath. But I'm interested to know if I can achieve this entirely within cts:query constructs/functions. Regards, Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://developer.marklogic.com/pipermail/general/attachments/20150313/cb442f47/attachment-0001.html ------------------------------ Message: 6 Date: Fri, 13 Mar 2015 05:47:12 +0000 From: Geert Josten <[email protected]> Subject: Re: [MarkLogic Dev General] Nested cts:search() functions over JSON documents To: MarkLogic Developer Discussion <[email protected]> Message-ID: <d1283851.85f5a%[email protected]> Content-Type: text/plain; charset="us-ascii" Hi Nick, I think you are looking cts:json-property-scope-query: xquery version "1.0-ml"; let $json-doc := xdmp:unquote( '{ "foo": { "bar": "UP HERE" }, "baz": { "foo": { "bar": "DOWN HERE" } } }') return xdmp:document-insert("/doc.json", $json-doc) ; "element search", cts:search(doc(), cts:element-query(xs:QName("foo"), cts:element-query(xs:QName("bar"), "here"))), "json search", cts:search(doc(), cts:json-property-scope-query("foo", cts:json-property-scope-query("bar", "here"))) Cheers, Geert From: Nick Ardlie <[email protected]<mailto:[email protected]>> Reply-To: MarkLogic Developer Discussion <[email protected]<mailto:[email protected]>> Date: Friday, March 13, 2015 at 6:34 AM To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Subject: [MarkLogic Dev General] Nested cts:search() functions over JSON documents Is it possible to define nested (i.e. path constrained) queries in cts:search() over JSON document types in MarkLogic 8? With XML document types I can nest cts:element-query() functions to achieve this. But I don't seem to be able to use the cts:element-query() function for JSON. Unless I'm missing something? It requires an xs:QName() parameter and a local-name only version of a QName doesn't seem to work for JSON documents. To describe with an example, say I have the following documents (one XML, the other JSON): let $xml-doc := <doc> <foo> <bar>UP HERE</bar> </foo> <baz> <foo> <bar>DOWN HERE</bar> </foo> </baz> </doc> let $json-doc := xdmp:unquote( '{ "foo": { "bar": "UP HERE" }, "baz": { "foo": { "bar": "DOWN HERE" } } }') let $insert-result := (xdmp:document-insert("ID-1", $json-doc), xdmp:document-insert("ID-2", $xml-doc)) With the XML document I can search for foo/bar elements that contain the word "here" like this: return cts:search(doc(), cts:element-query(xs:QName("foo"), cts:element-query(xs:QName("bar"), "here"))) After the above insert this will match the XML document but not the JSON document. I'd like to do the equivalent with the JSON document but the similar cts functions for JSON don't appear to support cts:query nesting (e.g. cts:json-property-value-query()). Is there a way to do this with JSON documents? I know I can constrain the first expression argument to cts:search with an XPath. But I'm interested to know if I can achieve this entirely within cts:query constructs/functions. Regards, Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://developer.marklogic.com/pipermail/general/attachments/20150313/cb4dbfac/attachment.html ------------------------------ _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general End of General Digest, Vol 129, Issue 20 **************************************** **************** CAUTION - Disclaimer ***************** This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system. ***INFOSYS******** End of Disclaimer ********INFOSYS*** _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
