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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
- XQuery Help and Discussion (2017)
-> + Sample XQuery extension using ... (2)
-> + Another EDI problem (7)
-> + Removing xmls:od and xmls:xsi ... (2)
-> + Configuring MarkLogic with Sty... (10)
-> + EDI to XML (7)
-> + Can't write to SQL-Server (4)
-> + XQuery and SQL-Server (2)
-> + Connection to MS SQL Server in... (2)
-> + copy/modify with Stylus Studio... (5)
-> - copy/modify with Stylus Studio... (1)
-> + [SQLServer JDBC Driver]Value c... (5)
-> + wild card chracter usage in XS... (2)
-> + Xquery with SQL NEWID function (4)
-> - Change Only One Line (5)
-> ->Change Only One Line
-> ->Change Only One Line
-> ->Change Only One Line
-> ->Change Only One Line
-> + Format DB xQuery results (3)
-> + Adding MsSQL Database to XQuer... (3)
-> + Need help with using XQuery in... (2)
-> + please help! simple XML transf... (2)
-> + xquery for invoice data (3)
-> + Xquery to cross reference two ... (3)
-- Previous [121-140] [141-160] [161-180] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.