Okay, so here are two more features that I would like to implement. I would
appreciate any comments as to their viability and the best approach to
start.


1. Projection Validation

    To support schemas with forward compatibility it is often desirable to
specify that attributes and elements that are undefined in the schema are
ignored rather than causing an error. However, you would generally still
like to validate all options that are known.

I'm getting this idea from:

http://davidbau.com/archives/2003/12/01/theory_of_compatibility_part_1.html
http://davidbau.com/archives/2003/12/08/theory_of_compatibility_part_2.html
http://davidbau.com/archives/2004/01/15/theory_of_compatibility_part_3.html

Here, Bau calls this "projection", in that a elements of a given input are
"projected" onto the understood elements.

It is possible to accomplish this with XmlBeans as it stands today. You:

    A. Validate with an error listener
    B. Obtain a cursor over the document
    C. Enumerate the cursor, deleting any elements mentioned in the
       error listener as "unknown" attributes or elements.
    D. Then, if any outstanding errors are left, you know the document is
not valid.


What I would like to add is a validation option called something like
"VALIDATE_LAX_PROJECTION" or some such that has the validator (a) still pass
the document if it contains unknown elements but all known elements are
valid and (b) removes the unknown elements from the document (although this
could be an additional option, whether the validation would remove the
elements or simply keep them there?)



2. Regex Compatibility Urls

    In line with the above, I'd like to create schemas as follows:

    http://example.com/document/type/1.0

    Where 1.0 would be my supported document type, and any document
    matching:

    http://example.com/document/type/1.(.*)
    
        Pattern.compile("http://example\\.com/document/type/1\\..+";)

    Would be treated as a 1.0 document. This means that any elements added
in the 1.1 schema would be ignored. This works as long as we use an
compatiblity contract that says that (a) elements will not change in meaning
between minor versions and (b) new elements will not affect the semantics of
existing elements.

    It would seem one would need more (e.g., the ability to specify numbers
greater than or equal to some thing), but when combined with a proper use of
projection and the other concepts highlighted in the referenced articles,
generally one would need only to implement a single version (1.0, 1.1, etc.)
and be able to successfully project any document into an understood subset.
Of course, more advanced matching could be provided if one didn't just use
regular expressions, but that might make things overly complicated. Of
course, another approach is allow a compatibility mapping callback to be
provided in the XmlOptions. This would serve the same purpose but probably a
bit more flexibly.


Wesley
    




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@xmlbeans.apache.org
For additional commands, e-mail: dev-h...@xmlbeans.apache.org

Reply via email to