XML-schema 'best practice' question

Lorenzo Gatti gatti at dsdata.it
Thu Sep 18 09:53:46 CEST 2008

On 18 Set, 08:28, Frank Millman <fr... at chagford.com> wrote:

> I am thinking of adding a check to see if a document has changed since
> it was last validated, and if not, skip the validation step. However,
> I then do not get the default values filled in.
> I can think of two possible solutions. I just wondered if this is a
> common design issue when it comes to xml and schemas, and if there is
> a 'best practice' to handle it.
> 1. Don't use default values - create the document with all values
> filled in.
> 2. Use python to check for missing values and fill in the defaults
> when processing the document.
> Or maybe the best practice is to *always* validate a document before
> processing it.

The stated problem rings a lot of premature optimization bells;
performing the validation and default-filling step every time,
unconditionally, is certainly the least crooked approach.

In case you really want to avoid unnecessary schema processing, if you
are willing to use persistent data to check for changes (for example,
by comparing a hash or the full text of the current document with the
one from the last time you performed validation) you can also store
the filled-in document that you computed, either as XML or as
serialized Python data structures.

Lorenzo Gatti

More information about the Python-list mailing list