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

This should cover W3C XML Schema, Relax NG and DTD related problems.
daddyjones
Posts: 9
Joined: Wed Apr 11, 2018 4:43 pm

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

Post 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?
tavy
Posts: 364
Joined: Thu Jul 01, 2004 12:29 pm

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

Post 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
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
daddyjones
Posts: 9
Joined: Wed Apr 11, 2018 4:43 pm

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

Post 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*"/>
Post Reply