[MarkLogic Dev General] xpath string construction

Robert Koberg rob at koberg.com
Tue Oct 14 08:24:54 PDT 2008



How about something like this (inline below):

>>> for $person in doc('/people.xml')/people/person
>>> return
>>>   <div>
>>>     $person/@name
>>>     <a href="delete.xqy?path={ xdmp:path($person) }>delete</a>
>>>   </div>

<a href="delete.xqy?name={ $person/@name }>delete</a>

then (below)

>>> This will give me nice delete links like "delete.xqy?path=/people/ 
>>> person[1]", but in the supposed delete.xqy, I'd want to do  
>>> something similar to:
>>> let $file := '/people.xml'
>>> let $person := xdmp:get-request-field('path')
>>> return
>>>   xdmp:node-delete(doc($file)/$person)

let $person-name := xdmp:get-request-field('name')

I realize you have simplified things (nicely) for your post, but I  
would use XQuery to build JavaScript here to put the information you  
need per person into a JSON object (I realize some requirement might  
preclude you from using JS). Then add a click event handler for each  
person link. Then, onclick, use the event handler to find the person's  
json object and construct an ajax POST or DELETE (which can be  
converted to XML on the client if needed) to send to the XQY.


More information about the General mailing list