[Xml-compile] unique constraint not validating

Mark Overmeer mark at overmeer.net
Sun Feb 5 22:28:14 GMT 2012


* ml at usermode.de (ml at usermode.de) [120205 09:50]:
> It seems that XML::Compile does not know unique constraints:

True.

> I've found an old conversation from 2008 regarding unique IDs:
> http://grokbase.com/t/sc/xml-compile/085f2pr9yf/xml-compile-schema-validation-on-xs-id-has-problem

Totally unrelated.

> Are there any news?

I know unique/keys/selector exist.  They are mainly used by databases
to create the right indexes.

XML::Compile::Schema is not a validator.  It does report errors when it
finds them "by accident" with not too much effort.  Actually, validation
is quite good in most cases.

I know a few things which are not checked, either because they consume
runtime or because they are hard to implement in the current model.
In this case the latter: I do not use xpath expressions to process
the XML, so when I encounter the expressions I have no idea where I am
relatively to that expression.

Anyway: it's quite rare that see people use unique&co in their
schemas.

> Possible workarounds:
> * Do another validation with XML::LibXML::Schema to catch unique
>   constraints
> * Remove 'unique' from schema and move logic into application/database
> What would you suggest?

I expect that the XML database does understand this from the schema.

XML::Compile translates the XML into a perl datastructure.  Of course,
you must implement you own sanity checks on that data...  schema specs
are never perfect ;-b  In this case, I wouldn't be too difficult for
you to implement the checks that XML::Compile cannot auto-generate.
--
Success

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark at Overmeer.net                          solutions at overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net




More information about the Xml-compile mailing list