Catch a user event/work with triggers
Hi,
I couldn't find documentation about catching events that occur on a db from an xquery module. What I am trying to achieve:
Context: Writers create content in XML Oxygen and are connected through the data source which uses WebDAV.
1. A writer modifies an .xml file and saves the changes. An event that can be caught by an xquery function is triggered. 2. My xquery function adds an @id to all elements that don't have one and saves the document again. There is a way to differenciate users 'replace' from query 'replace' so that if an event is triggered again here, we will not loop indefinitely.
I know you are working on triggers, but I'm not sure it applies to this use case. Can this currently be done?
Thanks!
Hi France,
With the new trigger mechanism, your trigger will launch your "add-id" function whenever a document is changed in the database. However, there will never be loops, because a trigger function will never trigger any other functions.
Hope this helps, Christian
Quoted text · France Baril · 18 lines
> A writer modifies an .xml file and saves the changes. > An event that can be caught by an xquery function is triggered. > My xquery function adds an @id to all elements that don't have one and saves > the document again. > There is a way to differenciate users 'replace' from query 'replace' so that > if an event is triggered again here, we will not loop indefinitely. > > I know you are working on triggers, but I'm not sure it applies to this use > case. Can this currently be done? > > Thanks! > > > > -- > France Baril > Architecte documentaire / Documentation architect > france.baril at architextus.com
Thanks, can't wait to try it.
Quoted text · Christian Grün · 35 lines
On Mon, Jun 1, 2015 at 5:15 AM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi France, > > With the new trigger mechanism, your trigger will launch your "add-id" > function whenever a document is changed in the database. However, > there will never be loops, because a trigger function will never > trigger any other functions. > > Hope this helps, > Christian > > > > A writer modifies an .xml file and saves the changes. > > An event that can be caught by an xquery function is triggered. > > My xquery function adds an @id to all elements that don't have one and > saves > > the document again. > > There is a way to differenciate users 'replace' from query 'replace' so > that > > if an event is triggered again here, we will not loop indefinitely. > > > > I know you are working on triggers, but I'm not sure it applies to this > use > > case. Can this currently be done? > > > > Thanks! > > > > > > > > -- > > France Baril > > Architecte documentaire / Documentation architect > > france.baril at architextus.com >
Written for BaseX 8.2. BaseX may have changed since: please check the current documentation.