How to associate XML documents with declared external vars?

Are you missing a feature? Request its implementation here.
Radu3000
Posts: 11
Joined: Mon Jul 30, 2007 6:19 pm
Location: Charlotte, NC USA

How to associate XML documents with declared external vars?

Post 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
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Post 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
Radu3000
Posts: 11
Joined: Mon Jul 30, 2007 6:19 pm
Location: Charlotte, NC USA

Post 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.
Radu3000
Posts: 11
Joined: Mon Jul 30, 2007 6:19 pm
Location: Charlotte, NC USA

Post 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.
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Post 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.
Post Reply