This content has been marked as final. Show 2 replies
Looking at it, I think this is pretty much a retrograde from the previous related thread.
Passing variable in fn:doc
 If you look at the prolog part, it is obvious that $per is not declared and is bound to nothing... Similarly for $job. If you want to do that, you can add that declaration to bind them and let the xquery itself to load the source document, something like this.
 Now, you can simply load and parse the persistent xml source document using doc() funtion. No need anything more than that.
String xq = "declare variable $per as xs:string := 'file:///c:/personal.xml';\n" + "declare variable $job as xs:string := 'file:///c:/job_info.xml';\n" + "declare variable $per1 as document-node(element(*, xs:untyped)) := " + " etc etc...";
 If you want to use document-node() inside the xquery and have them $per and $job being declared external like the structure you used in the related link above, you sure can do that. Only that, this time you are not using bindNode() but other appropriate binding methods, that's all.
String xq = "etc etc..." + "declare variable $per1 as document-node(element(*, xs:untyped)) := doc($per);\n" + "declare variable $job1 as document-node(element(*, xs:untyped)) := doc($job);\n" + "etc etc...";
Edited by: tsuji on Dec 21, 2011 9:05 AM (Edited a typo on doc1($job) delinquent character "1".)
The part of your code that says "fn:parse-xml($per);" refers to '$per' when it should refer to '$per1'.