abk07
abk07

Reputation: 49

What is 'base' attribute in xml?

Hey I was just going through some article on XML, I came across the following snippet of code

<xs:element name="shirtSize">
  <xs:simpleType>
    <xs:restriction base="xs:int">
      <xs:enumeration value="36"/>
      <xs:enumeration value="40"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>

I was wondering what base keyword means in the line

<xs:restriction base="xs:int">

Can anyone please explain me what it means?? Thanks

Upvotes: 2

Views: 913

Answers (3)

Michael Kay
Michael Kay

Reputation: 163575

This element declaration specifies that the type of the element is an anonymous type formed as a restriction of the built-in type xs:int, the restriction being that the only allowed values are 36 and 40. The attribute name "base" is used in xs:restriction to name the type that is being restricted.

Upvotes: 0

Siva Charan
Siva Charan

Reputation: 18064

On base attribute, you can specify

  1. which data type, you want to use such as xs:int, xs:string, xs:long and soon
  2. User Defined type can be set
  3. You can do restriction with the following:

    • length
    • minLength
    • maxLength
    • pattern
    • enumeration
    • whiteSpace and some more too based on type

Upvotes: 0

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726939

base is not, strictly speaking, a keyword. It is part of XML Schema (XSD) "language", letting you create simple types by restricting other simple types, including built-in numeric types.

In your case, the integer value is restricted to two values - 36 and 40.

Upvotes: 3

Related Questions