There must be a better way to do this.  My script works fine when it's loading 
a document that is not very large, but occassionally one of the docs is massive 
(13Mb on one of my error issues), and when that happens, in my application I 
get an error like:
com.marklogic.xcc.exceptions.XQueryException: Time limit exceeded

The script is basically getting a uri, reading it back and comparing the 
'firmname' nodes (there can be many in the same document), and if it differs in 
the shortlist.xml, we change it to what that file says it should be.

The problem with my large file - there's over 72,000 lawfirms it's trying to 
compare

This is my script - anyone have a suggestion of a better way to accomplish what 
I am attempting?



xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";;

declare variable $uri as xs:string external;
let $uri := try { ($uri) } catch ($e) { "" }
(: let $uri:="/olympus/pacer-xml/9739715_3:15-cv-01221" :)

let $xml_doc:=fn:doc("/olympus/data-utils/standard_firmnames_shortlist.xml")

for $this_uri in "$uri"
let $doc := fn:doc($uri)
let $pacer_doc:=$doc

for $firms in $pacer_doc//(counsel|party)
  let $theOrigFirmname:= $firms/originalFirmname
  let $theFirmname:= $firms/firmname
  let $translation:= 
$xml_doc//firmname[.=$theOrigFirmname]/../translation/text()


for $firm in $pacer_doc
return if( fn:exists($translation) and fn:exists($theFirmname) and 
($translation ne $theFirmname ) ) then
(
  fn:concat("CHANGING FIRMNAME: ",$theFirmname, " TO STANDARD FIRMNAME 
TRANSLATION: ",$translation, " IN URI: " ,$uri),
  xdmp:log(fn:concat("Olympotomus Changed Firmname: ",$theFirmname, " in URI: " 
,$uri)),
  xdmp:node-replace($theFirmname,<firmname>{$translation}</firmname>)
 )
else (
  fn:concat("...Evaluated and did not change Firmname: ",$theFirmname, " in 
URI: " ,$uri),
  xdmp:log(fn:concat("Olympotomus Evaluated and did not change a Firmname: 
",$theFirmname, " in URI: " ,$uri))
  )



_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to