OK, thanks. I'll look into it. For some reason the documents read from the collection don't have a document-uri property and therefore can't be written back.
 
You might try using
 
collection(.....)/doc(document-uri(.))//(*|@*) to see if this forces the document URI to be added to the document pool; or if that fails, base-uri() rather than document-uri().
 

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay

 
 


From: Costello, Roger L. [mailto:costello@mitre.org]
Sent: 11 March 2010 17:06
To: Mailing list for the SAXON XSLT and XQuery processor
Subject: Re: [saxon] Rename all the elements/attributes in allthe XMLfiles in a folder -- nothing happens

I set the –t option and on-error=warming. Here’s what I got:

 

Saxon-EE 9.2.0.3J from Saxonica

Java version 1.6.0_16

Analyzing query from FitnessCenter.xu

Analysis time: 968 milliseconds

Using parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser

 

Building tree for file:/C:/new-xml-course/new-xml-course/xquery/update-examples/

example01-b/files/FitnessCenter1.xml using class net.sf.saxon.tree.TreeBuilder

Tree built in 47 milliseconds

Building tree for file:/C:/new-xml-course/new-xml-course/xquery/update-examples/

example01-b/files/FitnessCenter2.xml using class net.sf.saxon.tree.TreeBuilder

Tree built in 0 milliseconds

Updated document discarded because it was not read using doc()

Updated document discarded because it was not read using doc()

Execution time: 516 milliseconds

Memory used: 4464432

 

/Roger

 

From: Michael Kay [mailto:mike@saxonica.com]
Sent: Thursday, March 11, 2010 11:57 AM
To: 'Mailing list for the SAXON XSLT and XQuery processor'
Subject: Re: [saxon] Rename all the elements/attributes in all the XMLfiles in a folder -- nothing happens

 

What messages do you get if you add the option -t?

 

Do you get any warnings if you switch to on-error=warning in the collection URI?

 

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay

 


From: Costello, Roger L. [mailto:costello@mitre.org]
Sent: 11 March 2010 16:08
To: Mailing list for the SAXON XSLT and XQuery processor
Subject: Re: [saxon] Rename all the elements/attributes in all the XMLfiles in a folder -- nothing happens

The question of whether or not updated documents are written back to disk depends on how you invoke the query, which you haven't described. There are various options on the command line, and if you use the Java API it is entirely under your control.

 

I am running it from the command line. Here’s how I invoke SAXON:

 

java -classpath %CLASSPATH% net.sf.saxon.Query -update:on -tree:linked -backup:on  FitnessCenter.xu

 

Where FitnessCenter.xu contains this:

 

for $i in collection('files?select=*.xml;recurse=yes;on-error=ignore')//(*|@*)

    return rename node $i as lower-case(name($i))

 

As I mentioned, I get no output and no changes to the XML files in the folder, “files”

 

 

/Roger

 

From: Michael Kay [mailto:mike@saxonica.com]
Sent: Thursday, March 11, 2010 10:18 AM
To: 'Mailing list for the SAXON XSLT and XQuery processor'
Subject: Re: [saxon] Rename all the elements/attributes in all the XML files in a folder -- nothing happens

 

The question of whether or not updated documents are written back to disk depends on how you invoke the query, which you haven't described. There are various options on the command line, and if you use the Java API it is entirely under your control.

 

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay

 


From: Costello, Roger L. [mailto:costello@mitre.org]
Sent: 11 March 2010 12:46
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Rename all the elements/attributes in all the XML files in a folder -- nothing happens

Hi Michael,

 

I am trying to rename all the elements and attributes in all the XML files in a folder. It seems like this should work:

 

for $i in collection('files?select=*.xml;recurse=yes;on-error=ignore')//(*|@*)

    return rename node $i as lower-case(name($i))

  

But I get no output and no change to the files.

 

I seem to be accessing all the files correctly because I get the expected output when I simply select all the elements in all the files:

 

for $i in collection('files?select=*.xml;recurse=yes;on-error=ignore')//*

    return $i

 

I am using the latest version of SAXON. Am I doing something wrong or is this a bug?

 

/Roger