Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: "Michael Kay" <mike@--------.--->
To: "'dave'" <ceek63@-----.--->, <xmlschema-dev@--.--->
Date: 12/20/2007 10:33:00 AM
> 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/


From ovisvana@n... Fri Dec 21 04:35:43 2007
Received: from wiggum.w3.org ([128.30.52.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent