0

I know this is probably a stupid question but I've just received a document that specifies the XML document (format, etc) and I just wanted to verify that this is in fact actually what I think it is....

an integer

<xs:simpleType name="ThreeDigitNumbers">
    <xs:restriction base="xs:int">
        <xs:pattern value="[0-9]{0,1}[0-9]{0,1}[0-9]{1}"/>
    </xs:restriction>

I have a field with the following type....

type="ThreeDigitNumbers"/>

Does this basically mean that it can be but doesn't have to be up to 3 numbers. Since this actually is supposed to be a value in a combobox - I'm assuming anything between 0-999?

Complete noob when it comes to XML

1 Answer 1

2

It's more a regex question.The regex could be simplified to [0-9]{1,3}.
It's not only 0-999, number could also starts with zeros, like 000, 001, 010.
You can test which values you can use here: https://regex101.com/r/ic7kme/1

The regex basically means the following:

[0-9]{0,1} # zero or one digit
[0-9]{0,1} # zero or one digit
[0-9]{1}   # one digit
Sign up to request clarification or add additional context in comments.

3 Comments

i guess my questino is based on the type given - does it have to be 3 digits always? so if it is 1 then it has to be 001. If i type in 1, 12, 123 it shows that it's a FULL MATCH
1 and 01 and 001 will be valid value.
It strikes me as pretty crass and user-unfriendly to allow the number 1 to be input as 01 or 001 but not as 0001, but that's exactly what this schema author has chosen to do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.