APPENDIX A ■ ■ ■ XML Schema Built-in Data Types Reference XML Schemas provide a number of built-in data types. You can use these types directly as types or use them as base types to create new and complex data types. The built-in types presented in this appendix are broken down into primitive and derived types and further grouped by area of functionality for easier reference. Type Definition XML Schema data types are built upon relationships where every type definition is either an extension or a restriction to another type definition. This relationship is called the type defi- nition hierarchy. The topmost definition, serving as the root of the hierarchy, is the ur-type definition, named anyType. It is the only definition that does not have a basis in any other type. Using this data type is similar to using ANY within a DTD. It effectively means that the data has no constraints. Take the following element declaration, for example: <xsd:element name="anything" type="xsd:anyType" /> An element based on this declaration can contain any type of data. It can be any of the built-in types as well as any user-derived type. The simple ur-type definition, named anySimpleType, is a special restriction on the ur-type definition. It constrains the anyType definition by limiting data to only the built-in data types, shown in the following sections. For example, the following element declaration defines an element that can be any built-in type but cannot be a complex type, which is sim- ply an element that can contain subelements or attributes, as explained in Chapter 3: <xsd:element name="simplelement" type="xsd:anySimpleType" /> The built-in types are divided into two varieties: primitive types and derived types. Primitive Types Primitive data types are those that are not defined in terms of another type. For easy reference, the following tables group the primitive types together based on general, non-schema-specific data types. Table A-1 shows the logical types, Table A-2 shows the numeric types, Table A-3 839 R. Richards, Pro PHP XML and Web Services, DOI 10.1007/978-1-4302-0139-7, © 2006 by Robert Richards 840 APPENDIX A ■ XML SCHEMA BUILT-IN DATA TYPES REFERENCE shows the textual types, Table A-4 shows the date/time types, Table A-5 shows the binary types, and Table A-6 shows the XML types. Table A-1. Logical Types Type Description Example boolean Represents the binary-valued logic literals true, false, 1, 0 Table A-2. Numeric Types Type Description Example decimal Arbitrary-precision decimal numbers. 1.0, 1.00, -1, 01.1230, 1.123 The sign is optional, and when omitted, + is assumed. double Real numbers with a double-precision, INF, -INF, NaN (Not a Number), 1.234, 1.2e3, 7E-10 64-bit, floating-point type. float Real numbers with a double-precision, INF, -INF, NaN (Not a Number), 1.234, 1.2e3, 7E-10 32-bit, floating-point type. Table A-3. Textual Types Type Description Example string Any legal XML character string according This is a string, This &amp; that are strings to the XML 1.0 specification. Special characters such as <, >, &, ', and " should be escaped. AnyURI A URI. It can be absolute or relative and http://www.example.com can contain a fragment identifier. Table A-4. Date/Time Types Type Description Example dateTime A date and time in the format CCYY- October 31, 2005, at 2:30 p.m. Coordinated MM-DDTHH:MM:SS. Universal Time (UTC) time is written as 2005-10- 31T14:30:00. The same date and time written in Eastern Standard Time (EST) is 2005-10- 31T14:30:00-5:00. date A calendar date in the format CCYY- October 31, 2005, is written as 2005-10-31. MM-DD with an optional time zone. time An instance of time during a day in the So, 2:30 p.m. UTC time is 14:30:00; the same time format HH:MM:SS. written in EST is 140:30:00-5:00. duration A duration of time in the format A duration of 1 year, 2 months, 3 days, 10 hours, PnYnMnDTnHnMnS. If the number of and 30 minutes is written as P1Y2M3DT10H30M, years, months, days, hours, minutes, or while a duration of 1 year is written as P1Y. seconds in any expression is zero, the number and its corresponding designator can be omitted, but at least one designator and the P designator must always be present. APPENDIX A ■ XML SCHEMA BUILT-IN DATA TYPES REFERENCE 841 Type Description Example gMonth Two-digit Gregorian month in the October is written as —10, and April is written format —MM with an optional time zone. as —04. gDay Two-digit Gregorian day in the format The 22nd day of the month is written as —22. —DD with an optional time zone. gYear Four-digit Gregorian year in the format The year 2005 is written as 2005. CCYY with an optional time zone. gMonthDay Combination of the Gregorian month October 31 is written as —10-31. and day in the format —MM-DD with an optional time zone. gYearMonth Combination of the Gregorian year October 2005 is written as 2005-10. and month in the format CCYY-MM with an optional time zone. Table A-5. Binary Types Type Description Example base64Binary Base64-encoded arbitrary binary data See base64_decode() in the PHP manual. hexBinary Arbitrary hex-encoded binary data See bin2hex() in the PHP manual. Table A-6. XML Types Type Description Example QName Represents an XML qualified name. prefix:name, xsd:attribute NOTATION Represents an XML NOTATION attribute. This type must not be used in an XML Schema. You can use it only to derive types that can be used in an XML Schema. Derived Types Derived types are data types that are defined in terms of other types, called base types. As you will see in the following tables, a base type for a derived type can be a primitive data type or even another derived type. These types also have been grouped into generalized, non-schema- specific data types. Table A-7 shows the numeric types, Table A-8 shows the textual types, and Table A-9 shows the XML types. 842 APPENDIX A ■ XML SCHEMA BUILT-IN DATA TYPES REFERENCE Table A-7. Numeric Types Type Base Type Description Example integer decimal The mathematical concept of integer 1, 0, -1, 12345 numbers nonPositiveInteger integer Any integer less than or equal to 0 0, -1, -12345 negativeInteger nonPositiveInteger Any integer less than 0 -1, -12345, -23456 long integer Any integer less than or equal to -100000, 0, 9,223,372,036,854,775,807 and greater or 10000 equal to -9,223,372,036,854,775,808 int long Any integer less than or equal to -2147483648 2,147,483,647 and greater or equal to -2,147,483,648 short integer Any integer less than or equal to 32,767 12345, -12345 and greater or equal to -32,768 byte short Any integer less than or equal to 127 and -123, 0, 123 greater or equal to -128 nonNegativeInteger integer Any integer greater than or equal to 0 0, 1, 12345 positiveInteger nonNegativeInteger Any integer greater than 0 1, 12345, 123456 unsignedLong nonNegativeInteger Any integer greater than or equal to 0 and 0, 12345, less than or equal to 1234567 18,446,744,073,709,551,615 unsignedInt unsignedLong Any integer greater than or equal to 0 and 0, 12345, less than or equal to 4,294,967,295 1234567 unsignedShort unsignedInt Any integer greater than or equal to 0 and 0, 1234, 65535 less than or equal to 65,535 unsignedByte unsignedShort Any integer greater than or equal to 0 and 0, 100, 126 less than or equal to 255 Table A-8. Textual Types Type Base Type Description Example normalizedString string A whitespace-normalized string. This means it Example does not contain carriage returns, line feeds, or normalized tab characters. string token normalizedString A tokenized string. This means it does not A B C contain carriage returns, line feeds, or tab characters. It also does not have leading or trailing spaces, and any two consecutive characters in the string are spaces. language token Language identifiers as defined by RFC 3066 en-US (http://www.ietf.org/rfc/rfc3066.txt). APPENDIX A ■ XML SCHEMA BUILT-IN DATA TYPES REFERENCE 843 Table A-9. XML Types Type Base Type Description Example Name token Represents an XML name as defined in the XML 1.0 specification NCName Name Represents XML “noncolonized” names, which are simply element QNames without the prefix and colon ID NCName Represents the ID attribute type from the XML 1.0 specification IDREF NCName Represents the IDREF attribute type from the XML 1.0 specification IDREFS IDREF Represents the IDREFS attribute type from the XML 1.0 specification ENTITY NCName Represents the ENTITY attribute type from the XML 1.0 specification ENTITIES ENTITY Represents the ENTITIES attribute type from the XML 1.0 specification NMTOKEN token Represents the NMTOKEN attribute type from the XML 1.0 specification NMTOKENS NMTOKEN Represents the NMTOKENS attribute type from the XML 1.0 specification APPENDIX B ■ ■ ■ Extension APIs This appendix is a quick reference for the XML parser extensions in PHP. You can find usage examples and more detailed information in each parser’s respective chapter. The information provided for the APIs covers functionality found in PHP 5.1.2, as well as a few new methods that will be released with PHP 6.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages78 Page
-
File Size-