I’m glad I caught this thread. Replace was working for me in basexgui but not from command line. 
( And I needed to generate replacement list from the shell using ‘find … -newer basex/data/collection’ ) 

I pulled the basex/lib/basex-api-9.2.1-SNAPSHOT.jar file out of the snapshot zip file and copied it to home-brew
/usr/local/Cellar/basex/9.2/libexec/lib/basex-api-9.2.jar  and replacement from the basex shell command appears to work now. 

Previously, I was getting this error, trying several variations of absolute/relative filenames or file: URIs. 

published$ basex -i published -c "replace jmu/vihart00338.xml  /projects/vh-migrate/published/jmu/vihart00338.xml" 
Improper use? Potential bug? Your feedback is welcome:
Contact: basex-talk@mailman.uni-konstanz.de
Version: BaseX 9.2
Java: Oracle Corporation, 1.8.0_201
OS: Mac OS X, x86_64
Stack Trace: 
java.lang.RuntimeException: published: lock file does not exist.
at org.basex.util.Util.notExpected(Util.java:61)
at org.basex.data.DiskData.finishUpdate(DiskData.java:246)
at org.basex.core.cmd.ACreate.update(ACreate.java:97)
at org.basex.core.cmd.Replace.run(Replace.java:55)
at org.basex.core.Command.run(Command.java:257)
at org.basex.core.Command.execute(Command.java:93)
at org.basex.api.client.LocalSession.execute(LocalSession.java:132)
at org.basex.api.client.Session.execute(Session.java:36)
at org.basex.core.CLI.execute(CLI.java:92)
at org.basex.core.CLI.execute(CLI.java:76)
at org.basex.core.CLI.execute(CLI.java:63)
at org.basex.BaseX.<init>(BaseX.java:80)
at org.basex.BaseX.main(BaseX.java:42)



— Steve Majewski



On Apr 29, 2019, at 5:08 AM, Christian Grün <christian.gruen@gmail.com> wrote:

Hi Daniel,

seems hard to reproduce. Could you tell me what you did step by step?
This is what I tried:

1. I created a DB database.
2. I added the document <root id='id'/> to the database path /path/file.xml.
3. I replaced this document with the same document via the DBA.
4. Your query db:open('DB')/root[@id='id']/base-uri() returned a single string.

Thanks in advance,
Christian

PS: The form parameter handling in 9.2 contains a little bug (as a
result, I couldn’t invoke the replace functionality with the current
version). I just uploaded a new snapshot. Both the current and the
snapshot version should behave identically in terms of adding and
replacing documents.



On Fri, Apr 26, 2019 at 4:45 PM Zimmel, Daniel <D.Zimmel@esvmedien.de> wrote:

Hello,

something has gone awry in my database after a db:replace():

query:
       db:open('DB','/path/file.xml')/base-uri()

result:
       /DB/path/file.xml

This is as expected. The result is the replaced file. But when I

query:
       db:open('DB')/root[@id='id']/base-uri()

result is a sequence:
       /DB/path/file.xml
       /DB/path/file.xml

The first result is the file before the db:replace(), the second after.

Can somebody explain why db:open() with path parameter is returning one result, but without parameter two results?
Database statistics say there are indeed two documents. But when I export the database, only one gets exported.

This happens with db:replace() on 9.2 from the DBA browser interface.
When I use the same db:replace() XQuery on 9.2 with my local database, all is well (document gets replaced, no duplicates). Settings should be the default ones.

Thanks, Daniel