[xsd-users] xs:double with xs:restriction

Boris Kolpackov boris at codesynthesis.com
Mon Sep 24 23:11:04 EDT 2018


Schrader, Glenn - 1002 - MITLL <gschrad at ll.mit.edu> writes:

> I have a schema containing a simple data type that has the restriction
> <xs:pattern value="[0-9]\.[0-9]"/> with xs:double as the base type. The
> problem is that the output doesn't always match the pattern. For instance if
> the field's value is 8.0 then an output file has "<Field>8</Field>" rather
> than "<Field>8.0</Field>". Validating parsers flag this as an error since it
> doesn't match the pattern so is there a way to make this work or are pattern
> restrictions not supported for this case (i.e. non-string base types).

You can't generally serialize a value in a way that matches a regex pattern.
What you can do is customize this type and provide custom serialization that
produces the desired format. See examples/cxx/tree/custom/double/ for how to
do this.



More information about the xsd-users mailing list