W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2007

RE: when to validate XML while being created programmatically..

From: dave <ceek63@yahoo.com>
Date: Thu, 20 Dec 2007 23:52:35 -0800 (PST)
To: Michael Kay <mike@saxonica.com>, xmlschema-dev@w3.org
Message-ID: <967648.22781.qm@web38005.mail.mud.yahoo.com>

Let's say, the W3C schema has key/keyref constraints.
LEt's also assume the Key is made up of some 5
elements/attributes. How does on-the-fly validation
work here when you are in the middle of setting the
Key constraint values in your app. How do we tell the
Validator when we completed the Key definition. I may
choose to define partial Key at one place and rest
defined elsewhere.
Am trying to understand the on-the-fly validation
behavior. Am afraid I I may get a Validation exception
if I am middle of constructing the XML instance unless
I command the validator at proper increments??

appreciate inputs.

--- Michael Kay <mike@saxonica.com> wrote:

> > This is related to validating a brand new XML
> instance WHILE 
> > being created programmatically:
> If you use XSLT or XQuery to create the XML
> instance, and you enable
> validation, then Saxon will insert a valldator into
> the serialization
> pipeline and check each element/attribute as it is
> written. You can do the
> same thing if you are generating XML from a Java
> application, though the API
> might be a little low-level for your taste.
> > If Yes, how would you 
> > correct these validation errors programmatically?
> It looks 
> > like a daunting task.
> I've no idea how you would go about correcting
> validation errors
> programmatically whether it's done on the fly or
> otherwise. If you're told
> that an attribute value doesn't match the pattern
> facet for the attribute
> type, what would you expect a program to do about
> it?
> > 
> >  OR
> > 
> > Does it even make sense to perform on-the-fly
> validation 
> > while constructing a new XML instance? 
> Yes, see above, it makes eminent sense.
> > If Yes, how would you 
> > tell the system when the instance is even
> incrementally valid 
> > before turning ON the validation. 
> Sorry, I don't understand the term "incrementally
> valid".
> > I can imagine there must be 
> > an API to enable/disable on-the-fly validation
> during the 
> > creation of XML instance. I might be wrong as it
> may not make sense.
> With Saxon (if you're really prepared to delve deep
> into the API) you can
> enable validation at the level of an element node.
> You can't switch
> validation off: once you're validating an element,
> you keep validating until
> you get to the end of that element.
> > 
> > Does the application design needs to ensure that
> the 
> > generated XML is always valid?
> > 
> Well, if the XML was always valid then you wouldn't
> need to validate it; but
> I think you should treat a validation failure as an
> error either in the
> application or perhaps (arguably) in its source
> data.
> Michael Kay
> http://www.saxonica.com/

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 
Received on Friday, 21 December 2007 08:04:36 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:13 UTC