Page 1 of 1

Is there a way to specify a range as a data type

Posted: Wed Apr 11, 2018 4:47 pm
by daddyjones
I have an attribute that I'd like to have a range of values as it's data type. By which I don't mean: a number between x and y, but more like x-y

For example <myelement myattribute="7-10" /> or <myelement myattribute="14-240" />

I'm guessing I might have to use a regular expression for this, but I was wondering if there was a simpler way that already exists?

Re: Is there a way to specify a range as a data type

Posted: Thu Apr 12, 2018 12:49 pm
by tavy
Hello,

As far as I know the only way to impose this restriction in XSD is to use a "pattern" facet.

Best Regards,
Octavian

Re: Is there a way to specify a range as a data type

Posted: Wed Apr 18, 2018 5:22 pm
by daddyjones
Thanks. In case anyone is googling this in future and finds this thread - I've gone with:

Code: Select all

<xs:pattern value="[123456789]\d*-[123456789]\d*"/>