0

I am executing the following XQuery code on BaseX 7.9 and am able to see the insertion on the results window. I even see the new node after closing and reopening the collection. However, when I go to the file directory I see it hasn't been modified. So, how can I make the insertion reflect as well on the file? And how does BaseX handle insertion commands so it is persistent in the context of the database but not in the context of the file?

let $up := <Employee Name="Joe">
    <Personal>
      <SSN>666-66-1234</SSN>
    </Personal>
    <StaffInfo>
      <Position>Doctor</Position>
      <AccountableTo>Jeff</AccountableTo>
    </StaffInfo>
  </Employee>
return insert node $up as last into doc('office')/Staff
popen_2
  • 43
  • 5

2 Answers2

3

BaseX databases correspond to the XML files they were created from, but in a special encoding for high query performance enriched with some indices. When updating a database using XQuery Update, the original file does not automatically get updated (thus, the XML serialized from the database).

Export the database after updating it using either

  • the command prompt and the EXPORT command:

    EXPORT [path]
      Export database to XML.
    
  • the graphical user interface and the export dialog in the menu bar under Database, Export.

Jens Erat
  • 37,523
  • 16
  • 80
  • 96
2

By default, updates will not be reflected on XML documents outside a database. However, updates may be enforced via the command-line flag -U or the option WRITEBACK.

Christian Grün
  • 6,012
  • 18
  • 34