XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Ethan SteinSubject: 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.

Postnext
Minollo I.Subject: Change Only One Line
Author: Minollo I.
Date: 24 Apr 2009 05:17 PM
You can do that using the XQuery Update Facility; you can find more details in the W3C specifications (http://www.w3.org/TR/xquery-update-10/); for a quick example, take a look at the XQuery fragment in this blog post: http://www.xml-connection.com/2009/03/hipaa-4010-to-5010-and-icd-9-to-icd-10.html

Postnext
Ethan SteinSubject: Change Only One Line
Author: Ethan Stein
Date: 24 Apr 2009 05:24 PM
Cool, that's exactly what I needed. Incidentally, I had just seen another post where that was requested when I got this reply.

Thanks.

P.S. does this method allow for xml streaming?

Postnext
Minollo I.Subject: Change Only One Line
Author: Minollo I.
Date: 24 Apr 2009 05:35 PM
Unfortunately no, that method will not stream in the current version of DataDirect XQuery.

Posttop
Ivan PedruzziSubject: 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>



Hope this helps
Ivan Pedruzzi
Stylus Studio Team

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.