The xdmp:document-get() call pulls a file from the disk, not the database.  
You're not actually manipulating database documents at all in this program, 
you're pulling the same file over and over from disk.  Use fn:doc() to pull 
docs from the database.

-jh-

On Aug 2, 2014, at 7:55 AM, Paul Farrell <[email protected]> wrote:

> 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

Reply via email to