FYI If this is running on a MarkLogic 4.2 or greater server,
this might be one of those cases where it is a lot easier to use XSLT.


----------------------------------------
David A. Lee
[email protected]<mailto:[email protected]>
http://www.xmlsh.org

From: [email protected] [mailto:[email protected]] On Behalf Of 
Mike Sokolov
Sent: Friday, September 07, 2012 10:05 AM
To: Mailing Lists Mail
Cc: [email protected]; James Fuller
Subject: Re: [xquery-talk] Replacing an attribute

I did notice that your functx:remove-attributes method calls another method 
called functx:remove-attributes-deep - probably just a typo?  Other than that 
it looks reasonable at a glance.  I think there is a Marklogic function 
xdmp:save, but you might get better info over on the MarkLogic mailing list.

-Mike

On 09/07/2012 08:44 AM, Mailing Lists Mail wrote:
Dear All,
I have the following requirement:

There are 40 documents in my Mark Logic DB.

I am trying to create one big XML that contains the dump of all the 40 
documents.. ( small ones each is 32 kb)

so it will look like:

<container >
 <document id = "filename1.xml">
   contents of this file
</document>

<document id = "filename2.xml">
   contents of this file
</document>

<document id = "filename3.xml">
   contents of this file
</document>
</container>

 and so on and so forth...

The thing I also want to do is while making this tree, I must delete all the 
@flag attributes from <request> elements in all the documents.. SO the 
Container element that I am making should not contain @flag for the <request> 
...


My Attempt:

declare namespace functx = "http://www.functx.com";;
declare function functx:remove-attributes
 ($element as element(), $names as xs:string*) as element() {
   element { node-name($element)}
           { $element/@*[not(name() = $names)],
             for $child in $element/node()
             return if ($child instance of element())
                    then functx:remove-attributes-deep($child, $names)
                    else $child }
};


<container>
{
for $doc in doc()

  let $filename:= document-uri($doc)



return (
<document id = "{$NAME}">
{

(: Will the below work?? :)
 functx:remove-attributes($doc//*,'flag') ,

 (:
 i now need to dump the contents ... How do I do this??
:)
 }
</document>
)
}
</container>

Any help will be highly appreciated...
Thanks..
Dak.






_______________________________________________

[email protected]<mailto:[email protected]>

http://x-query.com/mailman/listinfo/talk
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk

Reply via email to