Home > Articles > Programming > Java

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

Primitive Datatypes

Primitive datatypes are datatypes defined by the Recommendation, and exist at the most basic level. No one but the W3C can add new primitive datatypes to XML Schemas; however, you can use these primitive datatypes to create your own new datatypes, as we'll see later.

Let's look at some of the more common primitive datatypes defined in the Recommendation:

  • string—The string type is used to represent a string of characters. The characters that can be contained in a string consist of any valid Unicode character in the scope of the character encoding specified by the encoding attribute of the XML declaration.

  • boolean—The boolean type is used to represent binary logic; that is, it can accept values of either true or false and the numeric equivalents of these values (1 and 0).

  • decimal—The decimal type is used to represent decimal numbers of arbitrary precision. This datatype can then be manipulated to create derived types, such as integer, which I'll discuss later.

  • time—The time type is used to represent a specific instance of time, not a duration of time. The time is represented in HH-MM-SS-TIMEZONE format, using a 24-hour clock. TIMEZONE is the difference in time from Universal Coordinated Time; for example, 5 p.m. EST would be represented as 17:00:00-05:00.

  • date—The date type represents a calendar date, expressed as CCYY-MM-DD; October 24, 1979 would be 1979-10-29.

  • hexBinary—The hexBinary type is one of two datatypes specifically provided to represent binary information. The hexBinary type represents hexadecimal-encoded binary data.

  • base64Binary—The base64Binary type is the other datatype for representing binary data, and it represents information that's Base 64 encoded.

  • NOTATION—The NOTATION type is used to represent notations as they're represented in DTDs. This type is provided for the sake of backward compatibility with DTDs, and the ability to easily convert DTDs into XML Schema.

Other primitive datatypes are defined in the Recommendation; however, this is a basic list of the most common datatypes, which should get you started.

  • + Share This
  • 🔖 Save To Your Account