You can also try a helper library like this one: https://github.com/ryanjdew/XQuery-XML-Memory-Operations On Aug 1, 2014 6:17 PM, "Pete Aven" <[email protected]> wrote:
And to transform the doc using XQuery, take a look at the typeswitch expression: http://docs.marklogic.com/guide/app-dev/typeswitch#id_65827 -pete *From:* [email protected] [mailto: [email protected]] *On Behalf Of *Joe Bryan *Sent:* Friday, August 01, 2014 8:15 PM *To:* MarkLogic Developer Discussion *Subject:* Re: [MarkLogic Dev General] Urgent request for assistance (please) Hi Paul, The xdmp:node-* functions only work on documents stored in the database. To update a file on disk, you'll need to reconstruct the entire document as you want, and then save it using xdmp:save. Can I ask why you've taken this approach? I think you'll be much better served by querying, transforming, and updating documents that are stored in the database. There's a much larger API surface available to you, and you'll be able to leverage the universal index. Thanks. -jb *From: *Paul Farrell <[email protected]> *Reply-To: *MarkLogic Developer Discussion <[email protected]> *Date: *Friday, August 1, 2014 at 7:55 PM *To: *"[email protected]" <[email protected]> *Subject: *[MarkLogic Dev General] Urgent request for assistance (please) Hi, I am desperately hoping someone out there may be able to help me out with an xquery app that I am building. I have only just started with Marklogic and XQuery. It's going fairly well, however I am having a really tough time in modifying the content of one of my XML documents. I just cannot seem to get a change to an element to pick up. Here's my process (I have had to take things back as basic as I could just to try and get it working): 1. In Query console I have one tab open which queries for the contents of one XML doc xquery version "1.0-ml"; declare namespace html = "http://www.w3.org/1999/xhtml"; xdmp:document-get("C:/Users/Paul/Documents/MarkLogic/xml/ppl/ppl/jdbc_ppl_3790.xml") 2. This brings back the document as below <?xml version="1.0" encoding="UTF-8"?> <document> <meta> <rm_mimetype> </rm_mimetype> <rm_hasattachments> false </rm_hasattachments> <rm_attachmentcount> ... 3790 </ppl_id> <ppl_name> Victoria Wilson </ppl_name> 3. I now want to update the <ppl_name> element using XQuery but it's just not happening. Here's the XQuery: xquery version "1.0-ml"; declare namespace html = "http://www.w3.org/1999/xhtml"; let $docxml := xdmp:document-get("C:/Users/Paul/Documents/MarkLogic/xml/ppl/ppl/jdbc_ppl_3065.xml")/document/meta/ppl_name return for $node in $docxml/* let $target := xdmp:document-get("C:/Users/Paul/Documents/MarkLogic/xml/ppl/ppl/jdbc_ppl_3790.xml")/document/meta/*[fn:name() = fn:name($node)] return xdmp:node-replace($target, $node) --- I am basically looking to replace the <ppl_name> element in the target (3790) with the <ppl_name> element from the source (3065). 4. I run the Xquery - it completes without error (making me thing it has worked) - return value reads "your query returned an empty sequence" 5. I then go back to the same tab as I used in step 1 and re-run the XQuery used in step 1. The doc (3790) comes back but it STILL has Victoria Wilson as the <ppl_name> Can anyone please help? Perhaps the change needs committing? I just don't know. Thanks for reading Paul _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
