Subject:Change Only One Line Author:Ethan Stein Date:24 Apr 2009 03:46 PM
I have an XML file that contains a long list of data. I am only interested in changing one line inside the XML. One way to do it would be to do something liek
<ExtractData>
{
for $CurrentYearPlan in $xPRSXMLInput/ExtractData/CurrentYearPlan
return
<CurrentYearPlan>
{$CurrentYearPlan/PlanID}
{$CurrentYearPlan/ContractNumber}
{$CurrentYearPlan/PBPNumber}
{$CurrentYearPlan/BusinessSegment}
{local:transformPlanName($CurrentYearPlan/PlanName/text())}
{$CurrentYearPlan/PlanType}
{$CurrentYearPlan/PlanDescription}
...
</CurrentYearPlan>
}
</ExtractData>
But I am hoping there is a far easier way. That is return all of the XML file, and just go in and change one node value.
Thanks in advance for the help.
By the way, the node value I want to change is what I pass to the local:transformPlanName function.
Subject:Change Only One Line Author:Ivan Pedruzzi Date:28 Apr 2009 03:56 PM
Hi Ethan,
If you are willing to clone the input document you could use the copy/modify expression like in the following example without loosing streaming
<ExtractData>
{
for $CurrentYearPlan in $xPRSXMLInput/ExtractData/CurrentYearPlan
return
copy $p := $CurrentYearPlan
modify replace value of node $p/PlanName with local:transformPlanName($p/PlanName)
return $p
}
</ExtractData>