schema validation
Friday, 20 February 2015 · 5 messages · last reply 21 Feb 2015
P
pmenso5720 Feb 2015 03:33 #
Hi all.
Is it possible to enforce schema validation on update in BaseX?
Regards,
Paul Mensonides
CG
Christian Grün20 Feb 2015 11:54 #
Hi Paul,
In BaseX, validation is done on XQuery level. If you want to validate a document before updating it in the database, you can e.g. do something like..
let $db := 'database'
let $path := 'collection/doc.xml'
let $schema := 'path/to/schema.xsd'
let $doc := db:open($db, $path) update (
delete node //text()
)
return (
validate:xsd($doc, $schema),
db:replace($db, $path, $doc)
)Hope this helps,
Christian
Quoted text · pmenso57 · 7 lines
On Fri, Feb 20, 2015 at 3:33 AM, <pmenso57 at comcast.net> wrote: > Hi all. > > Is it possible to enforce schema validation on update in BaseX? > > Regards, > Paul Mensonides
DK
Dirk Kirsten20 Feb 2015 12:15 #
After Christians mail I realized I pressed the wrong reply button, so I sent I forward my response to the mailing list.
But good to see Christian says basically the same :)
Cheers,
Dirk
-------- Forwarded Message --------
Subject: Re: [basex-talk] schema validation
Date: Fri, 20 Feb 2015 11:06:53 +0100
Quoted text · Dirk Kirsten · 23 lines
From: Dirk Kirsten <dk at basex.org> To: pmenso57 at comcast.net Hi Paul, no, not directly. You would have to update via your own update functions by using our validation module. You could invoke all updates through such functions, e.g. by using RESTXQ. BaseX itself is not schema-aware. Cheers, Dirk On 02/20/2015 03:33 AM, pmenso57 at comcast.net wrote: > Hi all. > > Is it possible to enforce schema validation on update in BaseX? > > Regards, > Paul Mensonides > -- Dirk Kirsten, BaseX GmbH, http://basexgmbh.de |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
P
pmenso5721 Feb 2015 02:06 #
Thanks for the replies, guys.
I need the schema enforcement up the hierarchy from what is being inserted to enforce uniqueness constraints (customer orders) as well as referential integrity (references to workcenters, suppliers, customers, etc.). Pulling the entire document and then validating would essentially be pulling the entire database--which would be ever-growing and won't scale. Schema-on-read is not sufficient for this application (the data in the database must be valid as it is used in realtime contexts), so I believe I will have to store the data in a relational database instead. :( I can imagine there would be difficulties in implementing such a thing in the database, so I am not complaining. :)
Regards,
Paul Mensonides
Quoted text · Dirk Kirsten · 36 lines
----- Original Message ----- From: "Dirk Kirsten" <dk at basex.org> To: basex-talk at mailman.uni-konstanz.de Sent: Friday, February 20, 2015 3:15:52 AM Subject: [basex-talk] Fwd: Re: schema validation After Christians mail I realized I pressed the wrong reply button, so I sent I forward my response to the mailing list. But good to see Christian says basically the same :) Cheers, Dirk -------- Forwarded Message -------- Subject: Re: [basex-talk] schema validation Date: Fri, 20 Feb 2015 11:06:53 +0100 From: Dirk Kirsten <dk at basex.org> To: pmenso57 at comcast.net Hi Paul, no, not directly. You would have to update via your own update functions by using our validation module. You could invoke all updates through such functions, e.g. by using RESTXQ. BaseX itself is not schema-aware. Cheers, Dirk On 02/20/2015 03:33 AM, pmenso57 at comcast.net wrote: > Hi all. > > Is it possible to enforce schema validation on update in BaseX? > > Regards, > Paul Mensonides > -- Dirk Kirsten, BaseX GmbH, http://basexgmbh.de |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
DK
Dirk Kirsten21 Feb 2015 13:38 #
Hi Paul,
just some thoughts about your database design: It seems like you have one large document. It might by worth thinking about splitting this up in much smaller documents. Many databases have a natural split, e.g. you customer orders. This way, you could do this validation in an acceptable time. You can still query the all documents/databases in a single XQuery.
In fact, almost all document stores benefit from managing many small documents instead of one big document. So this is not necessarily unique to BaseX nor XML native databases.
It might be worth the effort, because mapping XML to relational of course also requires some efforts and has its own advantages and drawbacks.
Cheers,
Dirk
Quoted text · pmenso57 at comcast.net · 50 lines
On 02/21/2015 02:06 AM, pmenso57 at comcast.net wrote: > Thanks for the replies, guys. > > I need the schema enforcement up the hierarchy from what is being inserted to enforce uniqueness constraints (customer orders) as well as referential integrity (references to workcenters, suppliers, customers, etc.). Pulling the entire document and then validating would essentially be pulling the entire database--which would be ever-growing and won't scale. Schema-on-read is not sufficient for this application (the data in the database must be valid as it is used in realtime contexts), so I believe I will have to store the data in a relational database instead. :( I can imagine there would be difficulties in implementing such a thing in the database, so I am not complaining. :) > > Regards, > Paul Mensonides > > ----- Original Message ----- > > From: "Dirk Kirsten" <dk at basex.org> > To: basex-talk at mailman.uni-konstanz.de > Sent: Friday, February 20, 2015 3:15:52 AM > Subject: [basex-talk] Fwd: Re: schema validation > > After Christians mail I realized I pressed the wrong reply button, so I > sent I forward my response to the mailing list. > > But good to see Christian says basically the same :) > > Cheers, > Dirk > > > -------- Forwarded Message -------- > Subject: Re: [basex-talk] schema validation > Date: Fri, 20 Feb 2015 11:06:53 +0100 > From: Dirk Kirsten <dk at basex.org> > To: pmenso57 at comcast.net > > Hi Paul, > > no, not directly. You would have to update via your own update functions > by using our validation module. You could invoke all updates through > such functions, e.g. by using RESTXQ. > > BaseX itself is not schema-aware. > > Cheers, > Dirk > > On 02/20/2015 03:33 AM, pmenso57 at comcast.net wrote: > > Hi all. > > > > Is it possible to enforce schema validation on update in BaseX? > > > > Regards, > > Paul Mensonides > > >
--
Dirk Kirsten, BaseX GmbH, http://basexgmbh.de
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
| Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
Written for BaseX 8.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery