[xsd-users] Data validation
Moss, David R (SELEX Comms) (UK Christchurch)
david.r.moss at selex-comm.com
Fri Jan 27 06:06:25 EST 2006
If in a schema I have a restricted data type defined as:
<xsd:simpleType name="myInt">
<xsd:restriction base="xsd:unsignedInt">
<xsd:minInclusive value="100" />
<xsd:maxInclusive value="200" />
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="num" type="myInt"/>
then on parsing an xml file with an element of that type outside of that
range will throw an exception as expected:
<num>999</num>
Datatype error: Type:InvalidDatatypeFacetException, Message:Value '999'
must be less than or equal to MaxInclusive '200' .
However, if I want to modify / create some data programmatically no such
validation occurs. The following compiles, runs and serializes back to
an xml file without any problem:
myInt i(9999999);
Is there any way to use the underlying validation used when an xml file
is parsed to check the validity of objects instantiated in this way?
Cheers,
Dave.
Dave Moss
SELEX Communications
Grange Road
Christchurch
Dorset BH23 4JE
United Kingdom
Tel: + 44 (0) 1202 404841
Email: david.r.moss at seleniacomm.com
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codesynthesis.com/pipermail/xsd-users/attachments/20060127/247dbdde/attachment.htm
More information about the xsd-users
mailing list