|
next
|
Subject: Way to replace codes by labels stored in an DB table depending on language and location in an XML file using Data Direct engine Author: (Deleted User) Date: 13 Jun 2008 11:56 AM
|
Hi Sebastian,
I could not try the query against live data, but this should at least give you a starting point.
1) create a new query
2) show the File Explorer window, expand the Relational DB folder, add a server for your database
3) expand the db server until you find the table to be used, then drag it to the right pane of the XQuery
4) paste this content as the query
declare function local:convert($node as element(), $codes as element()*)
{
element { node-name($node) } {
$node/@*,
for $n in $node/node()
return
if($codes[LabelCode=$n/text()]) then
element { node-name($n) } { $codes[LabelCode=$n/text()]/Label }
else
typeswitch ($n)
case element() return local:convert($n, $codes)
default return $n
}
};
<Documents>
{
for $document in doc("file:///c:/testcase/TranslationTableRequirementExample_SampleInput.xml")/Documents/Document
return
<Document>
{
for $customer in $document/CustomerInformation
let $codes := collection("xxxxx")/*[Language=$customer/Language and Location=$customer/Location]
return
local:convert($customer, $codes)
}
</Document>
}
</Documents>
5) drag the table to be used as lookup table on the collection("xxxxx") text, so that the correct URL is generated.
Hope this works,
Alberto
|
|
|