[MarkLogic Dev General] General Digest, Vol 129, Issue 26

John Archer jarcher at gmail.com
Tue Mar 17 08:37:39 PDT 2015


R



—
Sent from Mailbox

On Tue, Mar 17, 2015 at 10:15 AM, null
<general-request at developer.marklogic.com> wrote:

> Send General mailing list submissions to
> 	general at developer.marklogic.com
> 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
> 	general-request at developer.marklogic.com
> You can reach the person managing the list at
> 	general-owner at developer.marklogic.com
> 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 (Will Thompson)
>    2. Re: Constructing JSON objects (William Sawyer)
>    3. Creating Powerpoint files with ML content (Danny Sinang)
>    4. Re: Creating Powerpoint files with ML content (Rob Szkutak)
> ----------------------------------------------------------------------
> Message: 1
> Date: Mon, 16 Mar 2015 20:03:06 +0000
> From: Will Thompson <wthompson at jonesmcclure.com>
> Subject: Re: [MarkLogic Dev General] Constructing JSON objects
> To: MarkLogic Developer Discussion <general at developer.marklogic.com>
> Message-ID: <21263D81-670F-41C1-AE8A-C4577D17DC1D at jonesmcclure.com>
> Content-Type: text/plain; charset="us-ascii"
> In this case, json:object and json:array are fine - I just wanted nicer syntax so that, say, a recursive typeswitch to transform XML to JSON wouldn't turn into a mess with all the temp objects. I guess it's also probably nice for building arbitrary JSON if there is any nesting involved.
> Mike - Right. And best-case scenario, if there is a conflict, I just remove the utility functions and everything works :)
> -W
>> On Mar 12, 2015, at 9:36 PM, David Lee <David.Lee at marklogic.com> wrote:
>> 
>> 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
>> dlee at marklogic.com
>> 
>> 
>>> On Mar 12, 2015, at 9:51 PM, Michael Blakeley <mike at blakeley.com> 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 <wthompson at jonesmcclure.com> 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 <Sudhakar.Reddy at marklogic.com> 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" <Erik.Hennum at marklogic.com> 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: general-bounces at developer.marklogic.com
>>>>>> [general-bounces at developer.marklogic.com] on behalf of Will Thompson
>>>>>> [wthompson at jonesmcclure.com]
>>>>>> 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
>>>>>> General at developer.marklogic.com
>>>>>> http://developer.marklogic.com/mailman/listinfo/general
>>>>>> _______________________________________________
>>>>>> General mailing list
>>>>>> General at developer.marklogic.com
>>>>>> http://developer.marklogic.com/mailman/listinfo/general
>>>>> 
>>>>> _______________________________________________
>>>>> General mailing list
>>>>> General at developer.marklogic.com
>>>>> http://developer.marklogic.com/mailman/listinfo/general
>>>> 
>>>> _______________________________________________
>>>> General mailing list
>>>> General at developer.marklogic.com
>>>> http://developer.marklogic.com/mailman/listinfo/general
>>> 
>>> _______________________________________________
>>> General mailing list
>>> General at developer.marklogic.com
>>> http://developer.marklogic.com/mailman/listinfo/general
>> _______________________________________________
>> General mailing list
>> General at developer.marklogic.com
>> http://developer.marklogic.com/mailman/listinfo/general
> ------------------------------
> Message: 2
> Date: Mon, 16 Mar 2015 14:46:38 -0600
> From: William Sawyer <wilby.sawyer at gmail.com>
> Subject: Re: [MarkLogic Dev General] Constructing JSON objects
> To: MarkLogic Developer Discussion <general at developer.marklogic.com>
> Message-ID:
> 	<CAKT+1DZaoG93kr1hBwx3iP1hZQquWi4xHQxFkN-tjwbb7mJCGg at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
> I had similar desires for a nicer syntax for working with JSON a few months
> ago and this is what I came up with.  Its similar to what Micheal was
> describing.
> https://github.com/williammsawyer/xquerycoder/blob/master/libs/json-functions.xqy
> -Will
> On Mon, Mar 16, 2015 at 2:03 PM, Will Thompson <wthompson at jonesmcclure.com>
> wrote:
>> In this case, json:object and json:array are fine - I just wanted nicer
>> syntax so that, say, a recursive typeswitch to transform XML to JSON
>> wouldn't turn into a mess with all the temp objects. I guess it's also
>> probably nice for building arbitrary JSON if there is any nesting involved.
>>
>> Mike - Right. And best-case scenario, if there is a conflict, I just
>> remove the utility functions and everything works :)
>>
>> -W
>>
>>
>> > On Mar 12, 2015, at 9:36 PM, David Lee <David.Lee at marklogic.com> wrote:
>> >
>> > 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
>> > dlee at marklogic.com
>> >
>> >
>> >> On Mar 12, 2015, at 9:51 PM, Michael Blakeley <mike at blakeley.com>
>> 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 <wthompson at jonesmcclure.com>
>> 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 <
>> Sudhakar.Reddy at marklogic.com> 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" <Erik.Hennum at marklogic.com>
>> 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: general-bounces at developer.marklogic.com
>> >>>>> [general-bounces at developer.marklogic.com] on behalf of Will Thompson
>> >>>>> [wthompson at jonesmcclure.com]
>> >>>>> 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
>> >>>>> General at developer.marklogic.com
>> >>>>> http://developer.marklogic.com/mailman/listinfo/general
>> >>>>> _______________________________________________
>> >>>>> General mailing list
>> >>>>> General at developer.marklogic.com
>> >>>>> http://developer.marklogic.com/mailman/listinfo/general
>> >>>>
>> >>>> _______________________________________________
>> >>>> General mailing list
>> >>>> General at developer.marklogic.com
>> >>>> http://developer.marklogic.com/mailman/listinfo/general
>> >>>
>> >>> _______________________________________________
>> >>> General mailing list
>> >>> General at developer.marklogic.com
>> >>> http://developer.marklogic.com/mailman/listinfo/general
>> >>
>> >> _______________________________________________
>> >> General mailing list
>> >> General at developer.marklogic.com
>> >> http://developer.marklogic.com/mailman/listinfo/general
>> > _______________________________________________
>> > General mailing list
>> > General at developer.marklogic.com
>> > http://developer.marklogic.com/mailman/listinfo/general
>>
>> _______________________________________________
>> General mailing list
>> General at developer.marklogic.com
>> http://developer.marklogic.com/mailman/listinfo/general
>>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://developer.marklogic.com/pipermail/general/attachments/20150316/402e9695/attachment-0001.html 
> ------------------------------
> Message: 3
> Date: Tue, 17 Mar 2015 11:05:22 -0400
> From: Danny Sinang <d.sinang at gmail.com>
> Subject: [MarkLogic Dev General] Creating Powerpoint files with ML
> 	content
> To: general <General at developer.marklogic.com>
> Message-ID:
> 	<CAPKs-U+TQT7WRCEzrW+b8yd5jwK1oqdEwrz_2LmMb0e9Wabqug at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
> Does ML have any API's or functions that create Powerpoint files using
> content from Marklogic ?
> Regards,
> Danny
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://developer.marklogic.com/pipermail/general/attachments/20150317/d45c82fe/attachment-0001.html 
> ------------------------------
> Message: 4
> Date: Tue, 17 Mar 2015 15:14:46 +0000
> From: Rob Szkutak <rob.szkutak at marklogic.com>
> Subject: Re: [MarkLogic Dev General] Creating Powerpoint files with ML
> 	content
> To: MarkLogic Developer Discussion <general at developer.marklogic.com>
> Message-ID:
> 	<6E8E665D710D394A853B6EEC145FB7DC11042C97 at EXCHG10-BE02.marklogic.com>
> Content-Type: text/plain; charset="iso-8859-1"
> Hi Danny,
> Have a look at our PowerPoint Toolkit: http://developer.marklogic.com/code/marklogic-toolkit-for-powerpoint
> Best,
> Rob
> Rob Szkutak
> Associate Consultant
> MarkLogic Corporation
> rob.szkutak at marklogic.com
> Cell +1.716.562.8464
> www.marklogic.com<http://www.marklogic.com>
> ________________________________
> From: general-bounces at developer.marklogic.com [general-bounces at developer.marklogic.com] on behalf of Danny Sinang [d.sinang at gmail.com]
> Sent: Tuesday, March 17, 2015 10:05 AM
> To: general
> Subject: [MarkLogic Dev General] Creating Powerpoint files with ML content
> Does ML have any API's or functions that create Powerpoint files using content from Marklogic ?
> Regards,
> Danny
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://developer.marklogic.com/pipermail/general/attachments/20150317/c33e60a0/attachment.html 
> ------------------------------
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
> End of General Digest, Vol 129, Issue 26
> ****************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20150317/86612a52/attachment-0001.html 


More information about the General mailing list