[xsd-users] Re: In-memory validation

david.r.moss at selex-comms.com david.r.moss at selex-comms.com
Wed Sep 26 11:04:54 EDT 2007


Boris,

At the moment, datatype-related validation is the primary thing we're 
looking for. 

In addition to enumerations, I'd like to see validation for:

* uniqueness i.e. can't add data that would break schema uniqueness 
constraints.
* numeric ranges (e.g. min, max facets)
* string length and pattern facets
* list length (both min / max occurrence of an element in a sequence as 
well as min / max items in a xsd list type) 
* boolean 
* date and time ranges - mapping to boost::date_time would help with this 
i guess.

Cheers,
Dave.

Dave Moss 
SELEX Communications 
Grange Road 
Christchurch 
Dorset  BH23 4JE 
United Kingdom 
Tel: + 44 (0) 1202 404841 
Email: david.r.moss at selex-comms.com 




Boris Kolpackov <boris at codesynthesis.com> 
09/26/07 01:33 PM

To
david.r.moss at selex-comms.com
cc
xsd-users at codesynthesis.com
Subject
Re: In-memory validation






Hi David,

david.r.moss at selex-comms.com <david.r.moss at selex-comms.com> writes:

> // Load will fail when content is invalid.
> auto_ptr<memory_test_t> rt( root( "in-memory-validation-test.xml" ) );
>
> // Modify with a valid value (range is 20-80 inclusive).
> rt->bounded_int( 50 );
> cout << *rt << endl;
>
> rt->bounded_int( 100 ); // Ideally, this should fail (throw exception - 
as
> initial file load would)
> cout << *rt << endl;
>
> I believe this kind of capability was on your 'to do' list at one point;
> is this still the case and, if so, do you have an idea of time-scales?!

The plan has evolved a bit over time. The main problem with the in-
memory validation is that the mapping of the XML Schema model to
object model as implemented in C++/Tree will not allow certain kinds
of structure validation that can be found in schema definitions.
Without going into much detail, consider the following schema
fragment:

<complexType name="A">
  <sequence maxOccurs="unbounded">
    <element name="s" type="string"/>
    <choice>
      <element name="x" type="int"/>
      <element name="y" type="int"/>
    </choice>
  </sequence>
</complexType>

The C++/Tree mapping maps the there elements in the above construct
to three independent sequences. It will be next to impossible to make
sure the content in the object model matches the structure in the above
schema. Note that this "loose" mapping is a trade-off between ease of
use and exact content representation that we feel is preferable in most
use-cases (most users don't want an object model that is as hard to use
as DOM).

As a result, the current plan is as follows:

1. Implement a subset of XML Schema validation in C++/Tree. The feature
   that we plan to support are for datatype-related validation (e.g.,
   facets, etc.). The nice thing about this types of checks is that
   they are cheap, fast and allow instant error detection, as you have
   shown in your example above.

2. We are also working on another in-memory (or more precisely, hybrid
   in-memory/even-driven) mapping that will be more "low-level" compared
   to C++/Tree. It will support high-performance XML Schema structure
   and datatype validation during both parsing and serialization.


Note also that for (1), some check are already supported in the generated
code. For example enumeration facets are enforced for string-based types.
The other checks will be implemented as requested by the users. So it 
would
be helpful if you could provide me with a list XML Schema constructs that
you would like validated in the generated code. We probably can support
some of them for the next release of XSD.

There is no definite time-frame for (2). The current plan is to release it
some time in the first quarter of 2008.


Boris



------------------------------------------------------------
This email and any attached files contains company confidential information which may be legally privileged. It is intended only for the person(s) or entity to which it is addressed and solely for the purposes set forth therein.  If you are not the intended recipient or have received this email in error please notify the sender by return, delete it from your system and destroy any local copies.  It is strictly forbidden to use the information in this email including any attachment or part thereof including copying, disclosing, distributing, amending or using for any other purpose.

In addition the sender excludes all liabilities (whether tortious or common law) for damage or breach arising or related to this email including but not limited to viruses and libel.
SELEX Communications Limited is a Private Limited Company registered in England and Wales under Company Number 964533 and whose Registered Office is Marconi House, New Street, CHELMSFORD, Essex. CM1 1PL. England.



More information about the xsd-users mailing list