Subject:copy/modify with Stylus Studio 2007 R2 Author:Ethan Stein Date:12 May 2009 08:35 PM
Has the copy/modify/replace value of functions changed between Stylus Studio 2007 R2 and Stylus Studio 2008R2/2009?
If so, what was the original implementation? The reason I ask is that apparently in SS2007R2, the following does not work:
<ExtractData>
{
for $CurrentYearPlan in $xPRSXMLInput/ExtractData/CurrentYearPlan
return
copy $CYPlan := $CurrentYearPlan
modify
(
for $planName in $CYPlan/*[contains(upper-case(local-name()),"PLANNAME")]
return
replace value of node $planName with local:transformPlanName($planName/text())
) return $CYPlan
}
</ExtractData>
I'm hoping someone can tell me why it does not work in SS2007R2.
Subject:copy/modify with Stylus Studio 2007 R2 Author:Ivan Pedruzzi Date:13 May 2009 12:40 AM
In XQuery 1.0 you have to use a recursive function that traverses and copies the input document
declare variable $data as document-node(element(*, xs:untyped)) external;
declare function local:transformPlanName($text)
{
concat("PLANNAME_", $text)
};
declare function local:rename($n as element(*, xs:untyped) )
{
element {name($n)}{
$n/@*,
if(starts-with(upper-case(local-name($n)),"PLANNAME")) then
local:transformPlanName($n/text())
else(
$n/text(),
for $child in $n/*
return local:rename($child)
)
}
};