Page 1 of 1
How to associate XML documents with declared external vars?
Posted: Mon Jul 30, 2007 6:22 pm
by Radu3000
I have the following fragment in my xquery file:
declare variable $legalcodes as document-node() external;
What do I do in Oxygen xml editor to configure this external variable to point to an xml file?
Thanks,
Radu Marian
Posted: Thu Aug 02, 2007 10:50 am
by Dan
oXygen does not support the external variables of type "document-node". I filed an enhancement request for this.
An workaround would be to create a new external variable of type xs:string, and then
assign to the $legalcodes variable the evaluation of the doc() function.
Something like this:
declare variable $x as xs:string external;
declare variable $y as document-node() := doc($x);
Thank you for the report,
Dan Caprioara
Posted: Mon Aug 06, 2007 6:17 pm
by Radu3000
Dan,
Thanks for your reply. It makes sense.
I still have a question - how do I configure the oxygen scenario to point the variable $legalcodesString to an xml file? I have tried adding a parameter as:
$legalcodesString = ${cfd}/../xml/legalcodes.xml
and still get the error: No value supplied for required parameter $legalcodesString
Do you have any sample code and scenario?
Thanks,
Radu.
Posted: Mon Aug 06, 2007 6:26 pm
by Radu3000
Never mind good old:
Code: Select all
declare variable $legalcodes as document-node() := doc("../xml/legalcodes.xml");
works just fine.
Thanks again,
Radu.
Posted: Tue Aug 07, 2007 9:44 am
by Dan
Let's consider the XQuery expression:
Code: Select all
declare variable $x as xs:string external;
declare variable $y as document-node() := doc($x);
<test>{
for $a in $y/*
return
<element>
{$a}
</element>
}
</test>
To run it you should select from the Transformation Configuration Dialog the "Execute XQuery" scenario. Press edit, then press the "Parameters" button in the new dialog. Add the parameter "x" with the value corresponding tot the name of the xml file.