Search code examples
xmlexist-dbxsltforms

Inserting nodeset into a document with Exist-db and XSLTforms


I'm working on setting up an exist-db instance using XSLTforms for non-technical data input. What I want to do sounds simple, but I can't find documentation for it, nor have other asked similar questions, so I'm guessing that I'm missing something obvious here. I want to insert a nodeset from my XSLTforms instance to a pre-existing xml file, but without overwriting the existing data.

<xf:submission id="s03" method="put" nodeset="instance('template')/x/y" resource="../data/XX.xml" replace="none">

works fine in terms of xpath etc, but replaces the entire xx.xml with the new instance. All I want to do is add my instance to the document. I've tried various approaches to create an xpath context for an insert, but this hasn't worked.

What am I doing wrong? Thanks R


Solution

  • @Joe Wicentowski put me on the right path but what I was missing was a simple pre return statement for the update insert:

    let $update := update insert $formdata into $target
    

    This allows me to insert a nodeset ($formdata) into a target nodeset ($target) and the return function is simply communicating success or error.