Update multiple XML files using XQuery
Issues related to W3C XQuery.
-
- Posts: 18
- Joined: Mon Dec 09, 2013 7:47 pm
Update multiple XML files using XQuery
Hello,
I've got problems to update several documents using a XQuery Update.
The oxygen version is 16. I use Saxon-EE XQuery 9.5.1.5. as a transformer and disabled XQuery 3.0 support.
Here is an example:
I receive the following error message:
Updated document discarded because it was not read using doc(). Warning
If I try
I receive the following message: java.io.FileNotFoundException
It works if I modify the script and update only one file
It would be great if you could give some advice how to modify the xquery script
to update multiple files?
Thanks,
Franziska
I've got problems to update several documents using a XQuery Update.
The oxygen version is 16. I use Saxon-EE XQuery 9.5.1.5. as a transformer and disabled XQuery 3.0 support.
Here is an example:
Code: Select all
xquery version "1.0";
let $docs := collection("file:///C:/My_Collection/?select=*.xml")
for $doc in $docs
return
replace value of node $doc/rootElement/element with 'new value'
Updated document discarded because it was not read using doc(). Warning
If I try
Code: Select all
replace value of node doc($doc)/rootElement/element with 'new value'
It works if I modify the script and update only one file
Code: Select all
let $doc := doc("file:///C:/My_Collection/File.xml")
return
replace value of node $doc/rootElement/element with 'new value'
to update multiple files?
Thanks,
Franziska
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Update multiple XML files using XQuery
Hi Franziska,
Oxygen uses the Saxon processor to run XQuery updated. So ideally you could register and write about this on the Saxon Help Users List:
http://sourceforge.net/p/saxon/mailman/
Looking for this a little bit on the web, it seems that indeed for each document that you want to modify you would need to use the doc function to load it.
Maybe as a possibly silly workaround after you use the collection function, for each of the documents you can use the document-uri function to find out the system ID and load it again using the doc function, then perform the update on it.
Regards,
Radu
Oxygen uses the Saxon processor to run XQuery updated. So ideally you could register and write about this on the Saxon Help Users List:
http://sourceforge.net/p/saxon/mailman/
Looking for this a little bit on the web, it seems that indeed for each document that you want to modify you would need to use the doc function to load it.
Maybe as a possibly silly workaround after you use the collection function, for each of the documents you can use the document-uri function to find out the system ID and load it again using the doc function, then perform the update on it.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 18
- Joined: Mon Dec 09, 2013 7:47 pm
Re: Update multiple XML files using XQuery
Hello,
thank you very much for your response! It works if I use the document-uri function as you suggested it.
Regards,
Franziska
thank you very much for your response! It works if I use the document-uri function as you suggested it.
Code: Select all
replace value of node doc(document-uri($doc))/rootElement/element with 'new value'
Franziska
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service