declare option ddtek:xml-streaming 'no';
declare option ddtek:serialize "indent=yes, omit-xml-declaration=no";
(: external reference to XML document :)
declare variable $xPRSXMLInput as document-node() external;
declare variable $logURL := "file:///c:/log/log.xml";
declare function local:addNode($error as element()) as element()*
{
let $newLog :=
{
if(doc-available($logURL)) then
doc($logURL)/Errors/*
else (),
$error
}
return
(ddtek:serialize-to-url($newLog, $logURL,""), $newLog/*[last()])
};
(: Retrieves the size of a white space or red/gold space from a secondary file and inserts it into the node :)
declare function local:replaceElms($n as element(), $acctRecNum as xs:string) as element()*
{
let $whitespacemsg := local:addNode(
{
concat("The white space size (for VISA region 01B) for "",
$acctRecNum,
".xml" could not be found. Please check the xDoc output.")
}
)
return This is a white space message{$whitespacemsg}
};
(: Retrieves the size of the message from a secondary file and inserts it into the message node :)
declare function local:processMessageNode($n as element(), $acctRecNum as xs:string) as element()*
{
let $msgErroNode := local:addNode(
{$n/MESSAGE_TOOL_PK}
{
concat("The message size (for VISA region 01A) for "",
$acctRecNum, "_",
$n/MESSAGE_TOOL_PK/text(),
".xml" could not be found. Please check the xDoc output.")
}
)
return this is another message{$msgErroNode}
};
(: Calls subfunctions to add specific nodes or data values :)
declare function local:updateNodes($n as element(), $recNumber as xs:string) as element()*
{
if ((local-name($n) eq 'WHITE_SPACE_SIZE') or (local-name($n) eq 'RED_GOLD_SIZE')) then
local:replaceElms($n, $recNumber)
else if (local-name($n) eq 'MESSAGE') then
local:processMessageNode($n, $recNumber)
else
element { name($n) }
{
(
$n/@*,
$n/text(),
for $child in $n/*
return local:updateNodes($child, $recNumber)
)
}
};
{
for $acctRec in $xPRSXMLInput/VISA_DATA/ACCOUNT_RECORD
let $acctRecNumber := $acctRec/ACCOUNT_RECORD_KEY_PK/text()
return local:updateNodes($acctRec, $acctRecNumber)
}
(: Stylus Studio meta-information - (c) 2004-2009. Progress Software Corporation. All rights reserved.
:)