Top Banner
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 APPENDIX A ■ ■ ■ R. Richards, Pro PHP XML and Web Services, DOI 10.1007/978-1-4302-0139-7, © 2006 by Robert Richards
78

XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Oct 21, 2019

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

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 typespresented in this appendix are broken down into primitive and derived types and furthergrouped by area of functionality for easier reference.

Type DefinitionXML Schema data types are built upon relationships where every type definition is either anextension 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-typedefinition, named anyType. It is the only definition that does not have a basis in any othertype. Using this data type is similar to using ANY within a DTD. It effectively means that thedata 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 thebuilt-in types as well as any user-derived type.

The simple ur-type definition, named anySimpleType, is a special restriction on theur-type definition. It constrains the anyType definition by limiting data to only the built-indata types, shown in the following sections. For example, the following element declarationdefines 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 TypesPrimitive 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-specificdata types. Table A-1 shows the logical types, Table A-2 shows the numeric types, Table A-3

839

A P P E N D I X A

■ ■ ■

R. Richards, Pro PHP XML and Web Services,DOI 10.1007/978-1-4302-0139-7, © 2006 by Robert Richards

Page 2: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

shows the textual types, Table A-4 shows the date/time types, Table A-5 shows the binarytypes, 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

APPENDIX A ■ XML SCHEMA BUILT- IN DATA TYPES REFERENCE840

Table A-2. Numeric Types

Type Description Example

decimal Arbitrary-precision decimal numbers. 1.0, 1.00, -1, 01.1230, 1.123The 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-1064-bit, floating-point type.

float Real numbers with a double-precision, INF, -INF, NaN (Not a Number), 1.234, 1.2e3, 7E-1032-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 stringsto 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.comcan 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 inEastern 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 designatorand the P designator must always be present.

Page 3: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

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.

APPENDIX A ■ XML SCHEMA BUILT- IN DATA TYPES REFERENCE 841

Derived TypesDerived types are data types that are defined in terms of other types, called base types. As youwill see in the following tables, a base type for a derived type can be a primitive data type oreven 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, andTable A-9 shows the XML types.

Page 4: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table A-7. Numeric Types

Type Base Type Description Example

integer decimal The mathematical concept of integer 1, 0, -1, 12345numbers

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 10000equal to -9,223,372,036,854,775,808

int long Any integer less than or equal to -21474836482,147,483,647 and greater or equal to -2,147,483,648

short integer Any integer less than or equal to 32,767 12345, -12345and greater or equal to -32,768

byte short Any integer less than or equal to 127 and -123, 0, 123greater 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 123456718,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, 65535less than or equal to 65,535

unsignedByte unsignedShort Any integer greater than or equal to 0 and 0, 100, 126less 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 normalizedtab characters. string

token normalizedString A tokenized string. This means it does not A B Ccontain 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 REFERENCE842

Page 5: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

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 elementQNames 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 A ■ XML SCHEMA BUILT- IN DATA TYPES REFERENCE 843

Page 6: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Extension APIs

This appendix is a quick reference for the XML parser extensions in PHP. You can find usageexamples and more detailed information in each parser’s respective chapter. The informationprovided for the APIs covers functionality found in PHP 5.1.2, as well as a few new methodsthat will be released with PHP 6.

libxmlThe libxml extension, described in Chapter 5, is the foundation for all the XML-based exten-sions in PHP. As of PHP 5.1, the extension defines common constants and functionality usedby a majority of the other related extensions. Table B-1 lists the general constants. Note thatsome constants are defined only when using certain versions of the libxml2 library.

Table B-1. libxml General Constants

Name Description

LIBXML_VERSION The numeric value of the libxml2 version being used by PHP. You canuse this value to test the version number for functionality that dependsupon certain versions of libxml2.

LIBXML_DOTTED_VERSION The string value using dotted notation of the libxml2 version beingused. This value is primarily used for display purposes.

The extensions, such as DOM and SimpleXML, allow parser options to be passed to func-tions and methods that are loading XML documents (see Table B-2).

Table B-2. libxml Constants for Loading Documents

Name Description

LIBXML_NOENT Substitutes entities found within the document with their replacementcontent.

LIBXML_DTDLOAD Loads any external subsets but does not perform validation. This flag alsoensures that IDs set in a DTD are created within the document.

LIBXML_DTDATTR Creates attributes within the document for any attributes defaulted througha DTD.

LIBXML_DTDVALID Loads subsets and validates a document while parsing.

Continued845

A P P E N D I X B

■ ■ ■

R. Richards, Pro PHP XML and Web Services,DOI 10.1007/978-1-4302-0139-7, © 2006 by Robert Richards

Page 7: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table B-2. Continued

Name Description

LIBXML_NOERROR Suppresses errors from libxml2 that may occur while parsing.

LIBXML_NOWARNING Suppresses warnings from libxml2 that may occur while parsing.

LIBXML_NOBLANKS Removes all insignificant whitespace within the document.

LIBXML_XINCLUDE Performs all XIncludes found within the document.

LIBXML_NSCLEAN Removes redundant namespace declarations found while parsing thedocument.

LIBXML_NOCDATA Merges CDATA nodes into text nodes. A document using CDATA sections willbe created with no CDATA nodes, as these will now be converted into plain-text nodes. This flag is useful when loading a document to be used for an XSLtransformation.

LIBXML_NONET Disables network access when loading documents. You can use this flag toincrease security from untrusted documents so resources cannot be fetchedfrom the network.

LIBXML_COMPACT Enables some memory optimizations that may help speed up an applicationusing XML. This constant is available only when using libxml2 2.6.21 or higher.

Several constants are also defined that can be used in the context of serializing an XMLdocument (see Table B-3). These are available only when using libxml2 2.6.21 and higher.

Table B-3. libxml Constants for Saving Documents

Name Description

LIBXML_NOXMLDECL Does not produce an XML declaration when saving the document

LIBXML_NOEMPTYTAG Does not output empty tags; rather, always outputs an opening and closingelement tag with no content between

Table B-4 lists libxml’s functions.

Table B-4. libxml Functions

Function Description

libxml_clear_errors(void) Clears libxml error buffer.

libxml_get_errors(void) Retrieves an array of errors.

libxml_get_last_error(void) Retrieves the last error from libxml.

libxml_set_streams_context Sets the stream’s context for the next libxml document load or (resource streams_context) write.

libxml_use_internal_errors Disables libxml errors and allows the user to fetch error infor-([bool use_errors]) mation as needed. This returns a Boolean of the previous state.

The LibXMLError class was introduced in PHP 5.1. Objects of this type are returned fromthe libxml error-handling functions. A few constants are defined explicitly for use with thisobject (see Table B-5). Table B-6 lists the LibXMLError class properties.

APPENDIX B ■ EXTENSION APIS846

Page 8: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table B-5. libxml Error-Level Constants

Name Description

LIBXML_ERR_NONE No error has been detected.

LIBXML_ERR_WARNING This is a simple warning that the XML document may have problems.

LIBXML_ERR_ERROR This is a recoverable error. The XML document contains errors, but theparser was able to continue processing.

LIBXML_ERR_FATAL This means a fatal error was detected, and the parser is unable to continueprocessing the document.

Table B-6. LibXMLError Class Properties

Property Type Description

level integer Indicates the severity of the error using one of the error-level constants asits value

code integer Indicates the error code from libxml2

column integer Indicates the column number, if available, from within the documentwhere the error occurred

line integer Indicates the line number, if available, from within the document wherethe error occurred

message string Indicates the textual representation of the error

file string Indicates the filename of the XML document containing the error

xmlThe xml extension, covered in Chapter 8, provides a SAX parser to process XML based onevents using handlers. Because this extension maintains compatibility and also can be builtusing expat rather than libxml2, it defines its own set of parser option constants. Table B-7 liststhe xml parser’s options constants, Table B-8 lists the xml parser’s error code constants, andTable B-9 lists the xml parser’s XML functions.

Table B-7. XML Parser Options Constants

Option Description

XML_OPTION_TARGET_ENCODING Sets the encoding to use when the parser passes the XML informa-tion to the function handlers. The available encodings are US-ASCII,ISO-8859-1, and UTF-8. The default is either the course encoding setwhen the parser was created or UTF-8 when not specified.

XML_OPTION_SKIP_WHITE Skips values that are entirely ignorable whitespaces. These valueswill not be passed to your function handlers. The default value is 0,meaning to pass whitespaces to the functions.

XML_OPTION_SKIP_TAGSTART Skips a certain number of characters from the beginning of a starttag. The default value is 0 to not skip any characters.

XML_OPTION_CASE_FOLDING Determines whether element tag names are passed all uppercaseor left as is. The default value is 1 to uppercase all tag names. Thedefault setting tends to be a bit controversial. XML is case-sensitive,and the default setting is to case fold characters. For example, anelement named FOO is not the same as an element named Foo.

APPENDIX B ■ EXTENSION APIS 847

Page 9: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table B-8. XML Error Code Constants

Name

XML_ERROR_NONE

XML_ERROR_NO_MEMORY

XML_ERROR_SYNTAX

XML_ERROR_NO_ELEMENTS

XML_ERROR_INVALID_TOKEN

XML_ERROR_UNCLOSED_TOKEN

XML_ERROR_PARTIAL_CHAR

XML_ERROR_TAG_MISMATCH

XML_ERROR_DUPLICATE_ATTRIBUTE

XML_ERROR_JUNK_AFTER_DOC_ELEMENT

XML_ERROR_PARAM_ENTITY_REF

XML_ERROR_UNDEFINED_ENTITY

XML_ERROR_RECURSIVE_ENTITY_REF

XML_ERROR_ASYNC_ENTITY

XML_ERROR_BAD_CHAR_REF

XML_ERROR_BINARY_ENTITY_REF

XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF

XML_ERROR_MISPLACED_XML_PI

XML_ERROR_UNKNOWN_ENCODING

XML_ERROR_INCORRECT_ENCODING

XML_ERROR_UNCLOSED_CDATA_SECTION

XML_ERROR_EXTERNAL_ENTITY_HANDLING

APPENDIX B ■ EXTENSION APIS848

Table B-9. XML Functions

Function Description

xml_parser_create([string encoding]) Creates and returns an XML parser. You can specify anoptional encoding for output.

xml_parser_create_ns([string encoding Creates and returns an XML parser. You can specify an [, string sep]]) optional encoding for output, and you can use an optional

separator to separate the namespace with the local name. Ifnot specified, a colon is used as the default separator.

xml_set_object(resource parser, object Associates a parser with an object so callback functions will obj) use the object’s methods as handlers. This returns a Boolean

indicating success or failure.

xml_set_element_handler(resource parser, Sets start and end element handlers for the parser. This string shdl, string ehdl) returns a Boolean indicating success or failure.

xml_set_character_data_handler(resource Sets a character data handler for the parser. This returns parser, string hdl) a Boolean indicating success or failure.

Page 10: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Function Description

xml_set_processing_instruction_handler Sets a PI handler for the parser. This returns a Boolean (resource parser, string hdl) indicating success or failure.

xml_set_default_handler(resource parser, Sets the default handler for a parser. This functionality is string hdl) now working as of PHP 5.1. This returns a Boolean indicating

success or failure.

xml_set_unparsed_entity_decl_handler Sets unparsed entity declaration handler for the parser. This (resource parser, string hdl) returns a Boolean indicating success or failure.

xml_set_notation_decl_handler(resource Sets the notation declaration handler for the parser. This parser, string hdl) returns a Boolean indicating success or failure.

xml_set_external_entity_ref_handler Sets the external entity reference handler for the parser. This (resource parser, string hdl) returns a Boolean indicating success or failure.

xml_set_start_namespace_decl_handler Sets the start namespace declaration handler for the parser. (resource parser, string hdl) This returns a Boolean indicating success or failure.

xml_set_end_namespace_decl_handler Sets the end namespace declaration handler for the parser. (resource parser, string hdl) This returns a Boolean indicating success or failure.

xml_parse(resource parser, string data Parses the XML sent in the data parameter. Parsing can be [, integer isFinal]) performed in chunks, and the isFinal parameter identifies

whether the chunk being passed is the end of the XMLdocument.

xml_parse_into_struct(resource parser, Parses the XML into an array, values, and optionally an string data, array &values[, array array, index, containing pointers to values in the values&index]) array.

xml_get_error_code(resource parser) Returns the XML parser error code. This code is a constantdefined by the XML extension.

xml_error_string(integer code) Returns the error string for the code.

xml_get_current_line_number(resource Returns the line number the parser is currently processing.parser)

xml_get_current_column_number(resource Returns the column number the parser is currently parser) processing.

xml_get_current_byte_index(resource Returns the byte index the parser is currently processing.parser)

xml_parser_free(resource parser) Frees the reference to the XML parser.

xml_parser_set_option(resource parser, Sets the value for one of the XML parser options. This integer option, mixed value) returns a Boolean indicating success or failure.

xml_parser_get_option(resource parser, Retrieves current value for an option.integer option)

utf8_encode(string data) Encodes an ISO-8859-1 string to UTF-8.

utf8_decode(string data) Converts a UTF-8 encoded string to ISO-8859-1.

APPENDIX B ■ EXTENSION APIS 849

XMLReaderXMLReader, covered in Chapter 9, is a stream-based, lightweight, and simple-to-use parser.This extension is written specifically for PHP 5 and newer. It originated as a PECL extensionbut was not added to the main distribution until PHP 5.1. For PHP 5.1, all constants have been

Page 11: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

moved to the XMLReader class rather than to global constants. Table B-10 lists the XMLReadernode type constants, Table B-11 lists the options class constants, and Table B-12 lists theXMLReader properties, which are read-only.

Table B-10. XMLReader Node Type Constants

Name Description

NONE No current node

ELEMENT Element node

ATTRIBUTE Attribute node

TEXT Text node

CDATA CDATA node

ENTITY_REF Entity reference node

ENTITY Entity node

PI PI node

COMMENT Comment node

DOC Document node

DOC_TYPE Doctype node

DOC_FRAGMENT Document fragment node

NOTATION Notation node

WHITESPACE Whitespace

SIGNIFICANT_WHITESPACE Significant whitespace

END_ELEMENT End element

END_ENTITY End entity

XML_DECLARATION XML declaration

Table B-11. XMLReader Parser Options Class Constants

Name Description

LOADDTD Loads DTD while parsing

DEFAULTATTRS Indicates the default attributes defined in the DTD while parsing

VALIDATE Validates the document while parsing

SUBST_ENTITIES Substitutes entities while parsing

APPENDIX B ■ EXTENSION APIS850

Page 12: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table B-12. XMLReader Properties (Read-Only)

Property Type Description

attributeCount integer Returns the number of attributes on the current element

baseURI string Returns the base URI for the current node

depth integer Returns the depth of the node within the tree using a zero-basedstarting point

hasAttributes Boolean Indicates whether the element has any attributes

hasValue Boolean Indicates whether the node has a child text node

isDefault Boolean Indicates whether the attribute is defaulted from the DTD

isEmptyElement Boolean Indicates whether the element is an empty element tag

localName string Returns the local name of the node

name string Returns the full qualified name of the node

namespaceURI string Returns the namespace URI for the node

nodeType integer Returns an XMLReader node type constant for the current node

prefix string Returns the prefix of the current node

value string Returns the text value of the node

xmlLang string Returns the xml:lang scope for which the node resides

The majority of methods from the XMLReader class return a Boolean that indicates thesuccess or failure of the operation. Unless otherwise indicated in the method description, youshould assume a Boolean as the return type. Table B-13 lists the XMLReader class methods.

Table B-13. XMLReader Class Methods

Method Description

close() Closes the XMLReader parser and returns a Boolean indicatingsuccess or failure.

getAttribute(string name) Returns the value of the attribute specified by name.

getAttributeNo(integer index) Returns the value of the attribute specified by index.

getAttributeNs(string name, Returns the value of the attribute specified by name and string namespaceURI) namespace.

getParserProperty(integer Returns a Boolean for the value of the specified property. property) The property is identified by one of the XMLReader parser

option class constants.

isValid Boolean isValid() When in validating mode, returnsBoolean indicating whether parsed document is valid.

lookupNamespace(string prefix) Returns the namespace URI in scope for the given prefix.

moveToAttribute(string name) Positions the reader on the attribute specified by name.

moveToAttributeNo(integer index) Positions the reader on the attribute specified by index.

moveToAttributeNs(string name, Positions the reader on the attribute identified by the name string namespaceURI) and namespace.

Continued

APPENDIX B ■ EXTENSION APIS 851

Page 13: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table B-13. Continued

Method Description

moveToElement() When positioned on an attribute, this method positions thereader back on the containing element.

moveToFirstAttribute() Positions the reader on the first attribute.

moveToNextAttribute() Positions the reader on the next attribute.

open(string URI [, string Sets the URI to be opened by the reader. The optional encoding [, integer options]]) parameters are currently available only in CVS for the

upcoming PHP 6. You can specify the encoding of thedocument within the file and parser options.

read() Positions the reader to the next node in the stream.

next([string localname]) Moves the reader to the next node in the stream, skippingover any subtrees. Optionally, you can specify a local name,causing the reader to continually call the next method untilit either has found a node with the specified name or hasreached the end of the stream.

setParserProperty(integer Sets the value for a specified property, which is one of the property, Boolean value) parser options.

setRelaxNGSchemaSource(string Sets the URI of a RELAX NG schema to be used for validation.filename)

setRelaxNGSchemaSource(string Provides a string containing a RELAX NG schema to be used source) for validation.

XML(string source [, string Sets data, contained in the string parameter, to be processed encoding [, integer options]]) by the reader. The optional parameters are currently avail-

able only in CVS for the upcoming PHP 6. You can specify theencoding of the document within the file and parser options.

expand() Creates a copy of the node the reader is currently positionedon and returns it as the appropriate DOM class. This functionis available in PHP 5.1 and newer.

readInnerXml() Returns a string containing the contents of the current node,including child nodes and markup. This method is currentlyavailable only in CVS for the upcoming PHP 6. libxml2 ver-sion 2.6.20 or newer is also required for this functionality.

readOuterXml() Returns a string containing current node, including its con-tents, child nodes, and markup. This method is currentlyavailable only in CVS for the upcoming PHP 6. libxml2 ver-sion 2.6.20 or newer is also required for this functionality.

readString() Reads the contents of an element or a text node as a string.This method is currently available only in CVS for theupcoming PHP 6. libxml2 version 2.6.20 or newer is alsorequired for this functionality.

SimpleXMLThe SimpleXML extension, covered in Chapter 7, provides a tree-based parser that allows an XML document to be manipulated as an object. Other than a few functions used to loadXML data and create a SimpleXMLElement object, you perform all functionality using the

APPENDIX B ■ EXTENSION APIS852

Page 14: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

SimpleXMLElement class. Table B-14 lists the SimpleXML functions, and Table B-15 lists the SimpleXMLElement methods.

Table B-14. SimpleXML Functions

Function Description

simplexml_import_dom(DOMNode node Performs a zero-copy import from a DOMNode. This function [, string class_name]) either returns a SimpleXMLElement object or returns an

object from the class specified by the class_name parame-ter. When this parameter is used, the class must inheritfrom the SimpleXMLElement class.

simplexml_load_file(string uri [, Loads the data from the location specified by the uristring class_name [, integer parameter. The class_name parameter allows the returned options]]) object to be instantiated as the specified class rather than

a SimpleXMLElement, as long as the class inherits fromSimpleXMLElement. The options parameter, added in PHP5.1, allows the use of LIBXML constants appropriate whenloading a document.

simplexml_load_string(string data Loads the data contained in the data parameter. The [, string class_name [, integer class_name parameter allows the returned object to options]]) be instantiated as the specified class rather than a

SimpleXMLElement, as long as the class inherits fromSimpleXMLElement. The options parameter, added in PHP 5.1, allows the use of LIBXML constants appropriatewhen loading a document.

Table B-15. SimpleXMLElement Methods

Name Description

__construct(string data) Constructor for SimpleXMLElement. The data parameter is a string containing an XML document and is used tocreate the XML tree within the returned object.

asXML([string uri]) Returns a well-formed XML string based on theSimpleXMLElement.

attributes([string ns]) Returns a SimpleXMLElement for the attributes of an ele-ment. The ns parameter specifies a namespace for theattributes to be retrieved.

children([string ns]) Returns a SimpleXMLElement for the children of an element.The ns parameter specifies a namespace for the children tobe retrieved.

xpath(string path) Runs XPath query on XML data returning the results in anarray.

registerXPathNamespace(string Registers a namespace and associated prefix that can be prefix, string namespace) used when performing XPath queries. This method was

added in PHP 5.1.

Continued

APPENDIX B ■ EXTENSION APIS 853

Page 15: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table B-15. Continued

Name Description

getDocNamespaces([bool recursive]) Returns an array containing all namespace declarationsdefined on the document element. When recursive ispassed as TRUE, all namespace declarations in the entiredocument are returned. The array is an associative arrayusing the namespace prefix as the key. Any redefined pre-fixes further in the tree when using this method recursivelyare not returned in the array, because their first definitiontakes precedence. Default namespace declarations do nothave a prefix, so an empty string is used as the key in thearray. This method was added in PHP 5.1.2.

getNamespaces([bool recursive]) Returns an array containing all namespaces in use for thecurrent element or attribute. When the recursive parame-ter is set to TRUE, all namespaces for child nodes arereturned as well. The array is an associative array using thenamespace prefix as the key. Any redefined prefixes furtherin the tree when using this method recursively are notreturned in the array, because their first definition takesprecedence. Default namespaces do not have a prefix, soan empty string is used as the key in the array. This methodwas added in PHP 5.1.2.

DOMThe DOM extension, covered in Chapter 6, is a tree-based parser that offers the most flexibilityand functionality to manipulate an XML document. As you can see from its API, it is also themost complex extension to use. Table B-16 lists the DOM node type constants, Table B-17 liststhe DOM exception code constants, and Table B-18 lists the DOM functions.

Table B-16. DOM Node Type Constants

Name Description

XML_ELEMENT_NODE The node is a DOMElement.

XML_ATTRIBUTE_NODE The node is a DOMAttr.

XML_TEXT_NODE The node is a DOMText.

XML_CDATA_SECTION_NODE The node is a DOMCharacterData.

XML_ENTITY_REF_NODE The node is a DOMEntityReference.

XML_ENTITY_NODE The node is a DOMEntity.

XML_PI_NODE The node is a DOMProcessingInstruction.

XML_COMMENT_NODE The node is a DOMComment.

XML_DOCUMENT_NODE The node is a DOMDocument.

XML_DOCUMENT_TYPE_NODE The node is a DOMDocumentType.

XML_DOCUMENT_FRAG_NODE The node is a DOMDocumentFragment.

XML_NOTATION_NODE The node is a DOMNotation.

XML_HTML_DOCUMENT_NODE The node is a DOMDocument containing an HTML document.

APPENDIX B ■ EXTENSION APIS854

Page 16: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table B-17. DOM Exception Code Constants

Name Description

DOM_INDEX_SIZE_ERR Indicates whether the index or size is negative or greaterthan the allowed value.

DOMSTRING_SIZE_ERR Indicates whether the specified range of text does not fit intoa DOMString.

DOM_HIERARCHY_REQUEST_ERR Indicates whether any node is inserted where it doesn’tbelong.

DOM_WRONG_DOCUMENT_ERR Indicates whether a node is used in a different documentthan the one that created it.

DOM_INVALID_CHARACTER_ERR Indicates whether an invalid or illegal character is specified,such as in a name.

DOM_NO_DATA_ALLOWED_ERR Indicates whether data is specified for a node that does notsupport data.

DOM_NO_MODIFICATION_ALLOWED_ERR Indicates whether an attempt is made to modify an objectwhere modifications are not allowed.

DOM_NOT_FOUND_ERR Indicates whether an attempt is made to reference a node ina context where it does not exist.

DOM_NOT_SUPPORTED_ERR Indicates whether the implementation does not support therequested type of object or operation.

DOM_INUSE_ATTRIBUTE_ERR Indicates whether an attempt is made to add an attributethat is already in use elsewhere.

DOM_INVALID_STATE_ERR Indicates whether an attempt is made to use an object thatis not, or is no longer, usable.

DOM_SYNTAX_ERR Indicates whether an invalid or illegal string is specified.

DOM_INVALID_MODIFICATION_ERR Indicates whether an attempt is made to modify the type of the underlying object.

DOM_NAMESPACE_ERR Indicates whether an attempt is made to create or change anobject in a way that is incorrect with regard to namespaces.

DOM_INVALID_ACCESS_ERR Indicates whether a parameter or an operation is notsupported by the underlying object.

DOM_VALIDATION_ERR Indicates whether a call to a method such as insertBeforeor removeChild would make the node invalid with respect to“partial validity.” This exception would be raised, and theoperation would not be done.

Table B-18. DOM Functions

Function Description

dom_import_simplexml(SimpleXMLElement node) Imports a SimpleXMLElement and returns thecorresponding DOMNode. This function per-forms a zero-copy import.

APPENDIX B ■ EXTENSION APIS 855

Page 17: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

DOMExceptionThe DOMException class inherits from the built-in Exception class. When an exception erroroccurs, according to the DOM specifications, DOM throws a DOMException, unless error han-dling has been changed using the DOMDocument strictErrorChecking property. This allows adeveloper to explicitly catch and handle a DOMException. The value of the code property corre-sponds to one of the DOMException code constants.

DOMImplementationTable B-19 lists the DOMImplementation methods.

Table B-19. DOMImplementation Methods

Method Description

createDocument([string namespaceURI[, Creates a new DOMDocument object. This method is string qualifiedName[, DOMDocumentType typically used to create a document containing doctype]]]) a doctype.

createDocumentType(string qualifiedName, Creates an empty DOMDocumentType object that string publicId, string systemId) can be used with the createDocument() method.

hasFeature(string feature, string version) Tests whether the DOM implementation imple-ments a specific feature for a specified version.

DOMXPathTable B-20 lists the DOMXPath methods.

Table B-20. DOMXPath Methods

Method Description

__construct(DOMDocument doc) Constructs a new DOMXPath object for the givenDOMDocument.

registerNamespace(string prefix, string Registers a prefix and namespace that can be used uri) in the XPath expressions.

query(string expr [,DOMNode context]) Evaluates the given XPath expression and returns a DOMNodeList containing the resulting nodes. A DOMNode can be passed to set the initial context.

evaluate(string expr [,DOMNode context]) Evaluates the given XPath expression and returns atyped result if possible. A DOMNode can be passed toset the initial context. This method was added inPHP 5.1.

DOMNodeListThe DOMNodeList class has a single read-only property called length. It returns the number ofnodes contained within the list. Nodes are accessed using the item(integer index) method.The index parameter specifies the zero-based index of the node to retrieve from the list.

APPENDIX B ■ EXTENSION APIS856

Page 18: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

DOMNamedNodeMapThe DOMNamedNodeMap class has a single read-only property called length. It returns the numberof nodes contained within the map. This class defines three methods to retrieve nodes (seeTable B-21).

Table B-21. DOMNamedNodeMap Methods

Method Description

getNamedItem(string name) Retrieves a node specified by name.

getNamedItemNS(string namespaceURI, Retrieves a node specified by local name and string localName) namespace URI.

item(integer index) The index parameter specifies the zero-based index of the node to retrieve from the list.

DOMNodeThe DOMNode class is the base class for the majority of the rest of the DOM classes. Table B-22lists its properties, and Table B-23 lists its methods.

Table B-22. DOMNode Properties

Name Type Read-Only? Description

nodeName string Yes Returns the more accurate name for thecurrent node type.

nodeValue string No The value of this node, depending on itstype.

nodeType integer Yes Gets the type of the node. This is one of thepredefined XML_xxx_NODE constants.

parentNode DOMNode Yes The parent of this node.

childNodes DOMNodeList Yes A DOMNodeList that contains all children ofthis node. If there are no children, this is anempty DOMNodeList.

firstChild DOMNode Yes The first child of this node. If there is nosuch node, this returns NULL.

lastChild DOMNode Yes The last child of this node. If there is nosuch node, this returns NULL.

previousSibling DOMNode Yes The node immediately preceding thisnode. If there is no such node, this returnsNULL.

nextSibling DOMNode Yes The node immediately following this node.If there is no such node, this returns NULL.

attributes DOMNamedNodeMap Yes A DOMNamedNodeMap containing theattributes of this node (if it is a DOMElement)or NULL otherwise.

ownerDocument DOMDocument Yes The DOMDocument object associated withthis node.

Continued

APPENDIX B ■ EXTENSION APIS 857

Page 19: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table B-22. Continued

Name Type Read-Only? Description

namespaceURI string Yes The namespace URI of this node or NULL ifit is unspecified.

prefix string No The namespace prefix of this node or NULLif it is unspecified.

localName string Yes Returns the local part of the qualified nameof this node.

baseURI string Yes The absolute base URI of this node or NULLif the implementation wasn’t able to obtainan absolute URI.

textContent string No This attribute returns the text content ofthis node and its descendants.

Table B-23. DOMNode Methods

Method Description

appendChild(DomNode newChild) Adds the newChild node to the end of the children.

cloneNode(Boolean deep) Clones a node. If deep is specified, then all child nodes arealso cloned.

hasAttributes() Returns a Boolean indicating whether the node hasattributes.

hasChildNodes() Returns a Boolean indicating whether the node haschildren.

isDefaultNamespace(string Returns a Boolean indicating whether the supplied namespaceURI) namespaceURI is the default namespace in scope for the

node.

insertBefore(DomNode newChild, Adds a new child node before a reference node.DomNode refChild)

isSameNode(DomNode other) Indicates whether the current node is the same node beingpassed to method.

isSupported(string feature, string Checks whether the feature is supported for specified version) version.

lookupNamespaceURI(string prefix) Returns the namespace URI currently associated with thesupplied prefix.

lookupPrefix(string namespaceURI) Gets the namespace prefix of the node based on thenamespace URI.

normalize() Normalizes the node.

removeChild(DomNode oldChild) Removes the child node from list of children.

replaceChild(DomNode newChild, Replaces a child node with a different node. This method DomNode oldChild) returns the node that was replaced.

APPENDIX B ■ EXTENSION APIS858

Page 20: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

DOMDocumentFragmentDOMDocumentFragment extends DOMNode (see Table B-24).

Table B-24. DOMDocumentFragment Methods

Method Description

__construct() Constructs a new DOMDocumentFragment element that is not associatedwith a document.

appendXML(string data) Builds an XML tree based on the input data within a DOMDocument➥Fragment. This function was added in PHP 5.1.

DOMDocumentDOMDocument extends DOMNode. Table B-25 lists the DOMDocument properties, and Table B-26 liststhe DOMDocument methods.

APPENDIX B ■ EXTENSION APIS 859

Table B-25. DOMDocument Properties

Name Type Read-Only? Description

actualEncoding string Yes Indicates the encoding of the document.

doctype DOMDocumentType Yes Indicates the document type declaration asso-ciated with this document.

documentElement DOMElement Yes This is a convenience attribute that allowsdirect access to the child node that is the doc-ument element of the document.

documentURI string No Indicates the location of the document or NULLif undefined.

encoding string No Indicates the current encoding of the document.

formatOutput bool No During serialization, this property specifieswhether line feeds and indentation should beadded. The default value is FALSE.

implementation DOMImplementation Yes Indicates that the DOMImplementation objecthandles this document.

preserveWhiteSpace bool No Does not remove redundant whitespace. Thedefault is TRUE.

recover bool No Indicates the parser recover on a fatal errorwhile loading the document. The default isFALSE.

resolveExternals bool No Loads external entities from a doctype decla-ration. This is useful for including characterentities in your XML document.

standalone bool No Indicates the value of the standalone attributefrom the XML declaration.

strictErrorChecking bool No Throws DOMException on errors. The default isTRUE.

Continued

Page 21: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table B-25. Continued

Name Type Read-Only? Description

substituteEntities bool No Determines whether the parser shouldsubstitute entities with their content whenloading a document.

validateOnParse bool No Loads and validates against the DTD. Thedefault is FALSE.

version string No Indicates the XML version being used in thedocument.

xmlEncoding string Yes Specifies, as part of the XML declaration, theencoding of this document. This is NULL whenunspecified or when it is not known, such aswhen the document was created in memory.

xmlStandalone bool No Specifies, as part of the XML declaration,whether this document is stand-alone. This isFALSE when unspecified.

xmlVersion string No Specifies, as part of the XML declaration, theversion number of this document. If there isno declaration and if this document supportsthe XML feature, the value is 1.0.

APPENDIX B ■ EXTENSION APIS860

Table B-26. DOMDocument Methods

Method Description

__construct([string version[, string Creates a new DOMDocument object.encoding]])

createAttribute(string name) Creates a new attribute associated with theDOMDocument.

createAttributeNS(string namespaceURI, Creates a new attribute node with an associated string qualifiedName) namespace associated with the DOMDocument.

createCDATASection(string data) Creates a new CDATA node associated with theDOMDocument.

createComment(string data) Creates a new comment node associated with theDOMDocument.

createDocumentFragment() Creates a new document fragment associated with theDOMDocument.

createElement(string tagName [, string Creates a new element node associated with the value]) DOMDocument.

createElementNS(string namespaceURI, Creates a new element node with an associated string qualifiedName [,string value]) namespace associated with the DOMDocument.

createEntityReference(string name) Creates a new entity reference node associated withthe DOMDocument.

createProcessingInstruction(string Creates a new PI node associated with the target[, string data]) DOMDocument.

createTextNode(string data) Creates a new text node associated with theDOMDocument.

getElementById(string elementId) Searches for an element with a certain ID.

Page 22: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Method Description

getElementsByTagName(string tagname) Searches for all elements with the given tag name.

getElementsByTagNameNS(string Searches for all elements with given tag name in namespaceURI, string localName) specified namespace.

importNode(DOMNode importedNode, Imports a node into current document.Boolean deep)

load(string URI [, integer options]) Loads XML from a file.

loadHTML(string source) Loads HTML from a string.

loadHTMLFile(string URI) Loads HTML from a file.

loadXML(string data [, integer Loads XML from a string.options])

normalizeDocument() Normalizes the document.

relaxNGValidate(string filename) Performs RELAX NG validation on the documentloading the schema from a URI.

relaxNGValidateSource(string data) Performs RELAX NG validation on the documentloading the schema from a string.

save(string URI[, integer options]) Dumps the internal XML tree back into a file.

saveHTML(string source) Dumps the internal document into a string usingHTML formatting.

saveHTMLFile(string URI) Dumps the internal document into a file using HTMLformatting.

saveXML([node n [, integer options]]) Dumps the internal XML tree back into a string.

schemaValidate(string filename) Validates a document based on a schema loaded froma URI.

schemaValidateSource(string data) Validates a document based on a schema.

validate() Validates the document based on its DTD.

xinclude([integer options]) Substitutes XIncludes in a DOMDocument object.

registerNodeClass(string baseclass, Registers classes that will be used to create DOM string extendedclass) objects rather than the internal ones. This method is in

CVS for the upcoming PHP 6.

DOMAttrDOMAttr extends DOMNode. Table B-27 lists the DOMAttr properties, and Table B-28 lists theDOMAttr methods.

Table B-27. DOMAttr Properties

Name Type Read-Only? Description

name string Yes The name of the attribute

ownerElement DOMElement Yes The element that contains the attribute

value string No The value of the attribute

APPENDIX B ■ EXTENSION APIS 861

Page 23: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table B-28. DOMAttr Methods

Method Description

__construct(string name, [string value]) Creates a DOMAttr with a specified name andoptional value

isId() Returns a Boolean indicating whether the attributeis an ID

DOMElementDOMElement extends DOMNode. Table B-29 lists the DOMElement methods, and Table B-30 lists theDOMElement methods.

Table B-29. DOMElement Properties

Name Type Read-Only? Description

tagName string Yes The element name

Table B-30. DOMElement Methods

Method Description

__construct(string name, [string value Creates a DOMElement object with a specified name [, string uri]]) and optionally a value and namespace URI.

getAttribute(string name) Returns the value of the attribute based on thename.

getAttributeNode(string name) Returns the attribute node with the specified name.

getAttributeNodeNS(string namespaceURI, Returns the attribute node with given namespace string localName) and name.

getAttributeNS(string namespaceURI, Returns the value of the attribute based on string localName) namespace URI and name.

getElementsByTagName(string name) Gets elements by tag name.

getElementsByTagNameNS(string Gets elements by namespaceURI and localName.namespaceURI, string localName)

hasAttribute(string name) Indicates whether the specified attribute exists.

hasAttributeNS(string namespaceURI, Indicates whether the specified attribute exists string localName) within a namespace.

removeAttribute(string name) Removes the attribute by name.

removeAttributeNode(DOMAttr oldAttr) Removes the attribute from the element.

removeAttributeNS(string namespaceURI, Removes the attribute by name and namespace.string localName)

setAttribute(string name, string value) Adds a new attribute with the specified name andvalue.

setAttributeNode(DOMAttr newAttr) Adds a new attribute node to the element.

setAttributeNodeNS(DOMAttr newAttr) Adds a new attribute node to the element.

APPENDIX B ■ EXTENSION APIS862

Page 24: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Method Description

setAttributeNS(string namespaceURI, Adds a new attribute in the specified namespace string qualifiedName, string value) with fully qualified name and value.

setIdAttribute(string name, Boolean isId) Sets IDness of an attribute by name. This method isimplemented only in CVS for upcoming PHP 6.

setIdAttributeNS(string namespaceURI, Sets IDness of an attribute by name and namespace. string localName, Boolean isId) This method is implemented only in CVS for

upcoming PHP 6.

setIdAttributeNode(attr idAttr, Boolean Set IDness of an attribute node. This method is isId) implemented only in CVS for upcoming PHP 6.

DOMCharacterDataDOMCharacterData extends DOMNode. Table B-31 lists DOMCharacterData properties, and Table B-32 lists DOMCharacterData methods.

Table B-31. DOMCharacterData Properties

Name Type Read-Only? Description

data string No The contents of the node

length integer Yes The length of the contents

Table B-32. DOMCharacterData Methods

Method Description

appendData(string arg) Appends a string to the end of the character dataof the node

deleteData(integer offset, integer count) Removes a range of characters from the nodestarting at the offset

insertData(integer offset, string arg) Inserts a string at the specified 16-bit unit offset

replaceData(integer offset, integer count, Replaces a substring within the DOMCharacterDatastring arg) node

substringData(integer offset, integer count) Extracts a range of data from the node

DOMCommentDOMComment extends DOMCharacterData. Table B-33 lists the DOMComment method.

Table B-33. DOMComment Methods

Method Description

__construct([string value]) Creates a DOMComment object with the specified value

APPENDIX B ■ EXTENSION APIS 863

Page 25: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

DOMTextDOMText extends DOMCharacterData. Table B-34 lists the DOMText properties, and Table B-35 liststhe DOMText methods.

Table B-34. DOMText Properties

Name Type Read-Only? Description

wholeText string Yes Returns all text of text nodes logically adjacent to this node,concatenated in document order

Table B-35. DOMText Methods

Method Description

__construct([string value]) Creates a DOMText object with specified value.

splitText(integer offset) Splits the text of a DOMText node at offset, creating an adjacentDOMText node.

isWhitespaceInElementContent() Returns a Boolean indicating whether the node contains onlywhitespace.

isElementContentWhitespace() This method is depreciated by isWhitespaceInElement➥Content().

DOMCdataSectionDOMCdataSection extends DOMText. Table B-36 lists the DOMCdataSection method.

Table B-36. DOMCdataSection Methods

Method Description

__construct([string value]) Creates a DOMCdataSection object with the specified value

DOMDocumentTypeDOMDocumentType extends DOMNode. Table B-37 lists the DOMDocumentType properties.

Table B-37. DOMDocumentType Properties

Name Type Read-Only? Description

publicId string Yes The public identifier of the external subset.

systemId string Yes The system identifier of the external subset.This can be an absolute or relative URI.

name string Yes The name of DTD, that is, the name imme-diately following the DOCTYPE keyword.

entities DOMNamedNodeMap Yes A DOMNamedNodeMap containing the generalentities, both external and internal,declared in the DTD.

APPENDIX B ■ EXTENSION APIS864

Page 26: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Name Type Read-Only? Description

notations DOMNamedNodeMap Yes A DOMNamedNodeMap containing the notationsdeclared in the DTD.

internalSubset string Yes The internal subset as a string, or NULL ifthere is none. This does not contain thedelimiting square brackets.

DOMNotationDOMNotation extends DOMNode. Table B-38 lists the DOMNotation properties.

Table B-38. DOMNotation Properties

Name Type Read-Only? Description

publicId string Yes The public identifier of the DOMNotation

systemId string Yes The system identifier of the DOMNotation

DOMEntityDOMEntity extends DOMNode. Table B-39 lists the DOMEntity properties.

Table B-39. DOMEntity Properties

Name Type Read-Only? Description

publicId string Yes The public identifier associated with the entity ifspecified and NULL otherwise.

systemId string Yes The system identifier associated with the entity ifspecified and NULL otherwise. This can be anabsolute URI or relative.

notationName string Yes For unparsed entities, the name of the notation forthe entity. For parsed entities, this is NULL.

DOMEntityReferenceDOMEntityReference extends DOMNode. Table B-40 lists the DOMEntityReference method.

Table B-40. DOMEntityReference Methods

Method Description

__construct([string name]) Creates a DOMEntityReference object with specified name

DOMProcessingInstructionDOMProcessingInstruction extends DOMNode. Table B-41 lists the DOMProcessingInstructionproperties, and Table B-42 lists the DOMProcessingInstruction method.

APPENDIX B ■ EXTENSION APIS 865

Page 27: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table B-41. DOMProcessingInstruction Properties

Name Type Read-Only? Description

target string Yes The target name of the PI

data string No The content of the PI

Table B-42. DOMProcessingInstruction Methods

Method Description

__construct(string name [, string value]) Creates a DOMProcessingInstruction object withthe specified target name and optionally speci-fies the value

XSLThe XSL extension, detailed in Chapter 10, implements the XSL standard and performs XSLtransformations. The functionality of this extension is provided through the XSLTProcessorclass. Table B-43 lists the XSL constants, Table B-44 lists the XSLTProcessor properties, andTable B-45 lists the XSLTProcessor methods.

Table B-43. XSL Constants

Name Value Description

XSL_CLONE_AUTO 0 Allows XSL to determine whether document passed toimportStylesheet() needs to be cloned

XSL_CLONE_NEVER -1 Never clones document passed to importStylesheet()

XSL_CLONE_ALWAYS 1 Always clones document passed to importStylesheet()

Table B-44. XSLTProcessor Properties

Name Default Value Description

cloneDocument XSL_CLONE_AUTO This property determines how the cloning of a documentis handled when passed to the importStylesheet. It maytake any of the values from Table B-43.

Table B-45. XSLTProcessor Methods

Name Description

getParameter(string namespace, Returns the value of the parameter specified by name. The string name) namespace parameter is currently unused.

hasExsltSupport() Returns a Boolean indicating whether PHP has EXSLTsupport.

importStylesheet(DOMDocument doc) Imports a style sheet from a DOMDocument object.

APPENDIX B ■ EXTENSION APIS866

Page 28: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Name Description

registerPHPFunctions([mixed Enables the ability to use PHP functions as XSLT functions. function]) The function parameter was added in PHP 5.1 and allows

the available functions to be called to be limited to thosespecified in the function parameter. It can be a string to seta single function at a time or an array to set multiple func-tions at once.

removeParameter(string namespace, Removes a parameter. Returns a Boolean indicating success string name) or failure.

setParameter(string namespace, Sets value for a parameter. In PHP 5.0 parameters must be mixed name [, string value]) passed one at a time passing the namespace: a string con-

taining the name of the parameter and a string containingthe value. In PHP 5.1 it is possible to set multiple parame-ters at once by passing the namespace and an associativearray containing the parameter names, where the namesare the keys and their corresponding values. Returns aBoolean indicating success or failure.

transformToDoc(DOMDocument doc) Transforms the input DOMDocument containing the XML datato a resulting DOMDocument.

transformToURI(DOMDocument doc, Transforms the input DOMDocument containing the XML data string uri) to URI and returning the number of bytes written to the URI.

transformToXML(DOMDocument doc) Transforms the input DOMDocument containing the XML datato a resulting string.

SOAPThe SOAP extension, covered in Chapter 18, provides functionality allowing for the consump-tion and creation of SOAP-based Web services. Table B-46 lists the SOAP options constants,Table B-47 lists the SOAP encoding constants, and Table B-48 lists the SOAP functions.

Table B-46. SOAP Options Constants

Name Name

SOAP_1_1 SOAP_ACTOR_NEXT

SOAP_1_2 SOAP_ACTOR_NONE

SOAP_PERSISTENCE_SESSION SOAP_ACTOR_UNLIMATERECEIVER

SOAP_PERSISTENCE_REQUEST SOAP_COMPRESSION_ACCEPT

SOAP_FUNCTIONS_ALL SOAP_COMPRESSION_GZIP

SOAP_ENCODED SOAP_COMPRESSION_DEFLATE

SOAP_LITERAL SOAP_AUTHENTICATION_BASIC

SOAP_RPC SOAP_AUTHENTICATION_DIGEST

SOAP_DOCUMENT

APPENDIX B ■ EXTENSION APIS 867

Page 29: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table B-47. SOAP Encoding Constants

Name Name Name

UNKNOWN_TYPE XSD_GMONTHDAY XSD_NONPOSITIVEINTEGER

XSD_ANYTYPE XSD_GYEAR XSD_NORMALIZEDSTRING

XSD_ANYURI XSD_GYEARMONTH XSD_NOTATION

XSD_ANYXML XSD_HEXBINARY XSD_POSITIVEINTEGER

XSD_BASE64BINARY XSD_ID XSD_QNAME

XSD_BOOLEAN XSD_IDREF XSD_SHORT

XSD_BYTE XSD_IDREFS XSD_STRING

XSD_DATE XSD_INT XSD_TIME XSD_TOKEN

XSD_DATETIME XSD_INTEGER XSD_UNSIGNEDBYTE

XSD_DECIMAL XSD_LANGUAGE XSD_UNSIGNEDINT

XSD_DOUBLE XSD_LONG XSD_UNSIGNEDLONG

XSD_DURATION XSD_NAME XSD_UNSIGNEDSHORT

XSD_ENTITY XSD_NCNAME SOAP_ENC_OBJECT

XSD_ENTITIES XSD_NEGATIVEINTEGER SOAP_ENC_ARRAY

XSD_FLOAT XSD_NMTOKEN XSD_1999_TIMEINSTANT

XSD_GDAY XSD_NMTOKENS XSD_NAMESPACE

XSD_GMONTH XSD_NONNEGATIVEINTEGER XSD_1999_NAMESPACE

Table B-48. SOAP Functions

Function Description

use_soap_error_handler([bool handler]) This function disables SOAP error handling anduses the current PHP error handler. The SOAP errorhandler is enabled by default when working with aSoapClient or SoapServer.

is_soap_fault(zval data) Returns a Boolean indicating whether data is aSoapFault.

SoapVarThe SoapVar class defines only a constructor and is used to type and encode data:

__construct(mixed data, int encoding [, string type_name [,string type_namespace [, string node_name [, string node_namespace]]]])

Table B-49 lists the SoapVar constructor parameters.

APPENDIX B ■ EXTENSION APIS868

Page 30: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table B-49. SoapVar Constructor Parameters

Parameter Description

data The data to pass or return

encoding The encoding ID, one of the SOAP encoding constants

type_name The type name

type_namespace The type namespace

node_name The XML node name

node_namespace The XML node namespace

SoapParamThe SoapParam class creates a name-based parameter. This class implements only aconstructor:

__construct(mixed data, string name)

Table B-50 lists the SoapParam constructor parameters.

Table B-50. SoapParam Constructor Parameters

Parameter Description

data The data to pass or return. Typically this is a SoapVar object.

name The name of the parameter.

SoapHeaderThe SoapHeader class creates SOAP header entities to be added to the SOAP message withinthe SOAP header:

__construct(string namespace, string name [, mixed data [, bool mustUnderstand [,mixed actor]]])

Table B-51 lists the SoapHeader constructor parameters.

Table B-51. SoapHeader Constructor Parameters

Parameter Description

namespace The namespace of the SOAP header element.

name The name of the SOAP header element.

data A SOAP header’s content. It can be a PHP value or a SoapVar object.

mustUnderstand Value of the mustUnderstand attribute of the SOAP header element.

actor Value of the actor attribute of the SOAP header element. This is the URI of therecipient or one of the SOAP_ACTOR_... constants.

APPENDIX B ■ EXTENSION APIS 869

Page 31: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

SoapFaultThe SoapFault class creates SOAP faults from a server that are returned to the calling client tobe handled:

__construct(string faultcode, string faultstring [, string faultactor [,mixed detail [, string faultname [, SoapHeader headerfault]]]])

Table B-52 lists the SoapFault constructor parameters.

Table B-52. SoapFault Constructor Parameters

Parameter Description

faultcode The error code of the SoapFault

faultstring The error message of the SoapFault

faultactor A string identifying the actor that caused the error

detail A PHP variable or SoapVar object to pass in the SOAP fault detail

faultname Can be used to select the proper fault encoding from WSDL

headerfault Can be used during SOAP header handling to report an error in the response header

SoapClientThe SoapClient class creates SOAP messages and makes SOAP requests. Table B-53 lists theSoapClient methods.

Table B-53. SoapClient Methods

Method Description

__construct( mixed wsdl [, array options]) Constructor for SoapClient.

__getLastRequest() Returns a string containing the last SOAP mes-sage request when the trace option is enabled.

__getLastResponse() Returns a string containing the last SOAP mes-sage response when the trace option is enabled.

__getLastRequestHeaders() Returns a string containing the last requestheaders when the trace option is enabled.

__getLastResponseHeaders() Returns a string containing the last responseheaders when the trace option is enabled.

__getFunctions() Returns an array of functions extracted from theWSDL.

__getTypes() Returns an array of types extracted from theWSDL.

__doRequest(string request, string This method is called by the SoapClient class location, string action, int version) when a request is made. Implementing this

method in a subclassed SoapClient object allowsaccess and modification to the SOAP messageprior to the request being sent to a SOAP server.When implemented, it is required that theparent’s __doRequest method be called for therequest to be made.

APPENDIX B ■ EXTENSION APIS870

Page 32: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Method Description

__soapCall (string function_name [, array Calls a function by name and returns appro-arguments [, array options [, mixed priate typed data. This method depreciated input_headers [, array &output_headers]]]]) __call() in PHP 5.0.2.

__setCookie(string name [, string value]) Sets a cookie that is sent with the request. Thismethod was added in PHP 5.0.4.

__setLocation([string new_location]) Sets a new URL (endpoint) for the SoapClient.This method was added in PHP 5.0.4.

__setSoapHeaders(array SoapHeaders) Sets SOAP headers by passing an array ofSoapHeader objects, replacing any previously setheaders. This method was added in PHP 5.0.5.

SoapServerTable B-54 calls the SoapClient methods.

Table B-54. SoapClient Methods

Method Description

__construct( mixed wsdl [, array Constructor for SoapServer.options])

setClass(string class_name [, Sets the class and its constructor arguments that will mixed args]) handle SOAP requests.

addFunction(mixed functions) Registers function handlers either one at a time, by array,or all at once using SOAP_FUNCTIONS_ALL constant.

getFunctions() Returns an array of functions registered with the server.

handle([string soap_request]) Handles a SOAP request. A SOAP message can be passeddirectly rather than retrieved automatically.

setPersistence(int mode) Sets the persistence mode of SoapServer using one of thepersistence constants.

fault(string code, string string Issues a SOAP fault.[, string actor [, mixed details [, string name]]])

XMLWriterThe XMLWriter extension, mentioned in Chapter 21, is an API to create XML-serialized XMLdocuments using a simple interface. It was added to the default PHP distribution in PHP 5.1.2.It originally was a PECL extension developed for PHP 4.3 using procedural calls, but an object-oriented interface was added for PHP 5. The API documented here is for the object-orientedinterface using the XMLWriter class. Table B-55 lists the XMLWriter class methods.

APPENDIX B ■ EXTENSION APIS 871

Page 33: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Table B-55. XMLWriter Class Methods

Method Description

openUri(string source) Initializes the writer and sets the URI to which the data will bewritten.

openMemory() Initializes the writer using memory to provide string output.

outputMemory([bool flush]) Returns the current data in the memory buffer as a string. Thememory buffer can be cleared when flush is passed as TRUE.

flush([bool empty]) Sends the writer buffer to the output. The return type dependsupon the output method being used (memory or URI). Theempty parameter, default FALSE, determines whether the writerbuffer is cleared when data is sent to output.

setIndent(bool indent) Turns indenting on/off. The default setting is off.

setIndentString(string Sets string to use for indenting.indentString)

startComment() Starts a comment.

endComment() Closes an open comment.

writeComment(string content) Creates a complete comment tag.

StartAttribute(string name) Starts an attribute.

endAttribute() Closes an open attribute.

writeAttribute(string name, Creates a complete attribute with a name and content.string content)

startAttributeNs(string prefix, Starts a namespaced attribute. libxml 2.6.17 and newer is string name, string uri) required for this method.

startElement(string name) Starts an element.

endElement() Closes an open element.

startElementNs(string prefix, Starts a namespaced element tag.string name, string uri)

writeElement(string name, Creates a complete element tag.string content)

writeElementNs(string prefix, Creates a complete namespace element tag.string name, string uri, string content)

startPi(string target) Starts a PI tag.

endPi() Closes an open PI.

writePi(string target, string Creates a complete PI tag.content)

startCdata() Starts a CDATA section.

endCdata() Closes an open CDATA section.

writeCdata(string content) Creates a complete CDATA section.

text(string content) Writes some text within current context.

startDocument([string version[, Starts a document setting as version, encoding, and standalone.string encoding[, string standalone]]])

APPENDIX B ■ EXTENSION APIS872

Page 34: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Method Description

endDocument() Closes an open document.

startDtd(string name[, string Starts a DTD tag.pubid[, string sysid]])

endDtd() Closes an open DTD tag.

writeDtd(string name[, string Creates a complete DTD tag.pubid[, string sysid[, string subset]]])

startDtdElement(string name) Starts a DTD element.

endDtdElement() Closes an open DTD element.

APPENDIX B ■ EXTENSION APIS 873

Page 35: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Features and Changes in PHP 6

Technology is in a continual state of perpetual motion. It is nearly impossible to keep up with all the changes and new features. This also holds true within PHP. During the time it tookto write the chapters in this book, PHP has added new functionality and has fixed or changedsome behavior. This appendix addresses some of these changes and introduces some newfunctionality that will be released with PHP 6.

■Note Although most of the new features mentioned in this chapter are currently planned to be released inPHP 6, it is possible they may be introduced in an earlier version depending upon the PHP release schedule.

xml ExtensionChapter 8 pointed out the problems of using default handlers. When using the xml extensionunder PHP 4 and implementing a default handler, any data not handled by any other handlerwill use the default handler. Under PHP 5, when defined, the default handler will process onlycomments and entities. With the release of PHP 5.1, this has changed. Although XML declara-tions and DTDs are still not handled, other types of data, otherwise unhandled in PHP 5.0, arenow processed by the default handler. Listing C-1 demonstrates how to parse a documentcontaining various node types using only a default handler. The results shown in Listings C-2and C-3 demonstrate the difference in output when the code is executed in PHP 5.0 and inPHP 5.1.

Listing C-1. Parsing XML Using Default Handler

<?phpfunction defaultData($parser, $data) {

print "$data";}

875

A P P E N D I X C

■ ■ ■

R. Richards, Pro PHP XML and Web Services,DOI 10.1007/978-1-4302-0139-7, © 2006 by Robert Richards

Page 36: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

$xmldata = '<?xml version="1.0"?><root att1="attval">

<e1>some content</e1><!-- A comment --><?php echo "Processing Instruction"; ?><e2/>

</root>';$xml_parser = xml_parser_create();xml_parser_set_option ($xml_parser, XML_OPTION_CASE_FOLDING, 0);xml_set_default_handler($xml_parser, "defaultData");xml_parse($xml_parser, $xmldata, true);?>

Listing C-2. Results Under PHP 5.0

<!-- A comment -->

Listing C-3. Results Under PHP 5.1

<root att1="attval"><e1>some content</e1><!-- A comment --><?php echo "Processing Instruction"; ?><e2></e2>

</root>

XMLReader ExtensionOnce PHP 6 is released, XMLReader will provide some new functionality. Probably the mostnotable feature is the ability to specify the encoding of the XML and parser options from thelibxml extension. For example:

boolean open(string URI [, string encoding [, int options]])boolean XML(string source [, string encoding [, int options]])

The ability to specify an encoding might not seem all that exciting, but being able tospecify parser options now means that XMLReader can perform an XInclude as it processes a document. For example, Listing C-5 shows how to process a document that contains anxinclude call to retrieve only a specific course element from the document in Listing C-4.When the first XML document contained in Listing C-5 is loaded into the XMLReader object,the LIBXML_XINCLUDE parser option is specified, resulting in the XMLReader object also pro-cessing the specified course element, shown by the results in Listing C-5.

APPENDIX C ■ FEATURES AND CHANGES IN PHP 6876

Page 37: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Listing C-4. External Document courses.xml

<courses><course cid="c1">

<title>Basic Languages</title><description>Introduction to Languages</description><credits>1.5</credits><lastmodified>2004-09-01T11:13:01</lastmodified>

</course><course cid="c2">

<title>French I</title><description>Introduction to French</description><credits>3.0</credits><lastmodified>2005-06-01T14:21:37</lastmodified>

</course></courses>

Listing C-5. XMLReader Using XInclude and Resulting Output

<?php$xincdata = '<?xml version="1.0" ?><academic xmlns:xi="http://www.w3.org/2001/XInclude">

<xi:include href="courses.xml" parse="xml"xpointer="xpointer(/courses/course[@cid='."'c1'".'])">

<xi:fallback>Element not found</xi:fallback></xi:include>

</academic>';

$reader = new XMLReader();

/* Load the XML document, and pass the LIBXML_XINCLUDE parser option */$reader->XML($xincdata, NULL, LIBXML_XINCLUDE);while ($reader->read()) {

if ($reader->nodeType == XMLReader::ELEMENT) {print $reader->localName;/* If element is named title, move to text node and output contents */if ($reader->localName == 'title') {

$reader->read();print ": ".$reader->value;

}print "\n";}

}?>

APPENDIX C ■ FEATURES AND CHANGES IN PHP 6 877

Page 38: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

academiccoursetitle: Basic Languagesdescriptioncreditslastmodified

Three other new methods allow for text content to be accessed in a simpler manner. Thesenew methods, shown in Table C-1, are available only when PHP is built with libxml2-2.6.20 andhigher. None of the methods take any parameters, and all return a string.

Table C-1. New XMLReader Methods for PHP 6

Method Description

readInnerXml() Returns a string containing the contents of the current node, which includeschild nodes and markup.

readOuterXml() Returns a string containing the current node and all of its contents, whichincludes child nodes and markup.

readString() Returns a string containing the contents an element or text node. When posi-tioned on an element, the content of all text and CDATA nodes within thesubtree of the element are concatenated together in the resulting string.

The example in Listing C-6 uses XMLReader to process a document containing variousnode types. I have not modified the results in order to demonstrate that all text nodes, includ-ing the whitespaces, are returned in the resulting string from each of the method calls.

Listing C-6. Example Calling readString(), readInnerXml(), and readOuterXml()

<?php$xmldata = '<?xml version="1.0"?><root att1="attval">

<e1>some content</e1><!-- A comment --><?php echo "Processing Instruction"; ?><e2/><![CDATA[ more content ]]>

</root>';

$reader = new XMLReader();$reader->XML($xmldata);while ($reader->read()) {

if ($reader->nodeType == XMLReader::ELEMENT) {switch ($reader->localName) {

case 'root':print "readInnerXML():\n";print $reader->readInnerXml()."\n";print "readString():\n";

APPENDIX C ■ FEATURES AND CHANGES IN PHP 6878

Page 39: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

print $reader->readString()."\n";break;

case 'e1':print "readOuterXML():\n";print $reader->readOuterXML()."\n";

}}

}?>

readInnerXML():

<e1>some content</e1><!-- A comment --><?php echo "Processing Instruction"; ?><e2/><![CDATA[ more content ]]>

readString():

some content

more content

readOuterXML():<e1>some content</e1>

SimpleXML ExtensionNo time has been wasted with the SimpleXML extension. As of PHP 5.1.2, two new methodshave been introduced, getNamespaces() and getDocNamespaces(), and the resulting structurefrom calling var_dump() with a SimpleXMLElement has changed for the better.

Working with namespaced documents is probably the area that causes the most problemsfor developers working with SimpleXML. To access an element or attribute within a name-space, and not the default namespace, you must specify the namespace URI. The issue facedis that it is up to the developer to remember all the namespaces used throughout the docu-ment. The only way to introspect the document for namespaces is to import it into DOM anduse XPath to locate namespaces. That is, that was the only way until now.

The getNamespaces() and getDocNamespaces() methods return an associative array ofnamespaces where the prefix is the key and the namespace URI is the value. The differencebetween the two methods is the scope of the document that is searched and the type of name-space returned in the array. The getNamespaces() method operates on the current element.The namespace URI for which the element resides in, if any, is added in the returned array.The getDocNamespaces() method uses the document element as the starting point rather than

APPENDIX C ■ FEATURES AND CHANGES IN PHP 6 879

Page 40: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

the element from which it is called. This method not only adds the namespace of the docu-ment element but also any namespaces that have been declared on the document element.

■Note Prefixes are not used with default namespaces. If a default namespace is added to the return arrayby either of these functions, the key for the item is an empty string.

These methods also take an optional Boolean parameter, recursive. When passed as TRUE,both methods will also add namespaces found within the starting element’s subtree to thearray as well. The use of the recursive parameter might give you pause. It is perfectly legal forprefixes to change their namespace associations within a document. Even default namespacescan be changed for different scopes. Then how do you deal with the issue of using prefixes forthe array keys?

When working with SimpleXML, it naturally would be more important to know aboutnamespaces within an element that are closer to the element rather than ones that have beenredefined and reside further down in the subtree. The returned array, when called recursively,returns the first namespace URIs encountered that have their prefixes redefined further withinthe tree. This may be a bit hard to visualize, so the example in Listing C-7 should clarify this.

Listing C-7. Retrieving Namespace URIs with SimpleXML

<?php$xmldata = '<?xml version="1.0" ?><root xmlns:a="urn:namespace:A" xmlns:b="urn:namespace:B">

<a:node_1 xmlns="urn:newns:C" xmlns:b="urn:newns:B"><a:node xmlns:a="urn:newns:A" />

</a:node_1></root>';

$sxe = simplexml_load_string($xmldata);

/* getDocNamespaces() call */$arnames = $sxe->getDocNamespaces();print "Doc Namespaces: \n";foreach ($arnames AS $prefix=>$namespace) {

print " Prefix: $prefix URI: $namespace \n";}

/* Recursive getDocNamespaces() call */$arnames = $sxe->getDocNamespaces(TRUE);print "\nDoc Namespaces Recursive: \n";foreach ($arnames AS $prefix=>$namespace) {

print " Prefix: $prefix URI: $namespace \n";}

APPENDIX C ■ FEATURES AND CHANGES IN PHP 6880

Page 41: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

/* getNamespace() call */$a_ns = $sxe->children('urn:namespace:A');$node_1 = $a_ns->node_1;$arnames = $node_1->getNamespaces();print "\nElement a:node_1 Namespaces: \n";foreach ($arnames AS $prefix=>$namespace) {

print " Prefix: $prefix URI: $namespace \n";}

/* Recursive getNamespace() call */$arnames = $node_1->getNamespaces(TRUE);print "\nElement a:node_1 Recursive: \n";foreach ($arnames AS $prefix=>$namespace) {

print " Prefix: $prefix URI: $namespace \n";}?>

Doc Namespaces:Prefix: a URI: urn:namespace:APrefix: b URI: urn:namespace:B

Doc Namespaces Recursive:Prefix: a URI: urn:namespace:APrefix: b URI: urn:namespace:BPrefix: URI: urn:newns:C

Element a:node_1 Namespaces:Prefix: a URI: urn:namespace:A

Element a:node_1 Recursive:Prefix: a URI: urn:namespace:A

As you can see by the results, the first call to getDocNamespaces() returns the two name-spaces, urn:namespace:A and urn:namespace:B, that are declared on the document element,root. The next call to the method is performed recursively by passing TRUE as the parameter. In this case, not only the two namespaces from the previous method call are returned but alsothe urn:newns:C namespace is returned. The namespace urn:newns:A, from the a:node element,is not returned in this case because the prefix a has already been mapped from the declarationof the urn:namespace:A namespace on the document element. The last two getNamespaces()method calls return namespaces that are actually used and not only declared within the scopeof the element from which the method is called. From the code in Listing C-7, the method iscalled using the a:node_1 element as the starting point. The first call to getNamespaces() simplyreturns the namespace urn:namespace:A, which is the namespace in which the element resides.The second call to the method is performed recursively. Because the prefix a has already beenadded to the array being returned, the urn:newns:A namespace is not added to the returned array.

APPENDIX C ■ FEATURES AND CHANGES IN PHP 6 881

Page 42: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Besides the addition of these two methods, the data returned by calling var_dump()on a SimpleXMLElement has also changed. First, attributes are now included in the output.SimpleXMLElement objects containing attributes will be output, with this function containingan additional property named @attributes. The value of this property is an array containingits attributes. Second, how objects deal with namespaces has changed. The var_dump() func-tion now also respects the namespace of the object, meaning that any child elements includedin the output are within the same namespace of the object with which the function was called.Prior to this change, namespaces were not respected, and all elements within the objects sub-tree were output.

Listing C-8 uses a document where one of the child course elements resides in a prefixednamespace. Each of the course elements also contains a cid attribute. You will notice the dif-ference between the output when the script is executed using PHP 5.0, shown in Listing C-9,and the output when executed using PHP 5.1.2, shown in Listing C-10. Not only do you see theattributes in Listing C-10, but only the first course element is contained in the output. Theobject being passed to var_dump() has not had any namespace specified, such as creating anobject using the children(namespaceURI) method, so only children not within a namespace or within the default namespace will be included.

Listing C-8. Using var_dump() with SimpleXMLElement

<?php$xmldata = '<?xml version="1.0" ?><courses>

<course cid="c1"><title>Basic Languages</title>

</course><a:course cid="c2" xmlns:a="urn:namespace:A">

<!-- this course element is within prefixed namespace --><title>French I</title>

</a:course></courses>';$sxe = simplexml_load_string($xmldata);var_dump($sxe);?>

Listing C-9. PHP 5.0 Results from Listing C-8

object(SimpleXMLElement)#1 (1) {["course"]=>array(2) {[0]=>object(SimpleXMLElement)#2 (1) {["title"]=>string(15) "Basic Languages"

}

APPENDIX C ■ FEATURES AND CHANGES IN PHP 6882

Page 43: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

[1]=>object(SimpleXMLElement)#3 (2) {["comment"]=>object(SimpleXMLElement)#4 (0) {}["title"]=>string(8) "French I"

}}

}

Listing C-10. PHP 5.1.2 Results from Listing C-8

object(SimpleXMLElement)#1 (1) {["course"]=>object(SimpleXMLElement)#2 (2) {["@attributes"]=>array(1) {["cid"]=>string(2) "c1"

}["title"]=>string(15) "Basic Languages"

}}

DOM ExtensionNot to be left out, the DOM extension contains new functionality for PHP 6. Developers whoregularly use this extension will be excited to know that one of the most requested features hasfinally been implemented—the ability to have DOM return nodes using extended classes ratherthan the built-in ones. Before going into more details on this, I will mention the other newfunctionality that has been implemented, because it is now possible to add and remove IDsusing any attribute.

The DOM specification defines the setIdAttribute(), setIdAttributeNS(), andsetIdAttributeNode() methods on a DOMElement object. Until now, these have not been imple-mented in the DOM extension. The methods do not create new attributes in a document. Theparameters passed are used to locate a specific attribute and indicate whether it should be anID. For example:

setIdAttribute(string name, boolean isId)setIdAttributeNS(string namespaceURI, string localName, boolean isId)setIdAttributeNode(DOMAttr idAttr, boolean isId)

Prior to these methods, the only way to create the attribute ID in a document was to use a DTD to specify an attribute is of the ID type or use the xml:id attribute. This was limitingbecause the DTD cannot be changed after the document has been loaded, so attributes not

APPENDIX C ■ FEATURES AND CHANGES IN PHP 6 883

Page 44: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

specified in the DTD could not be made into an ID. Also, once an attribute was made into anID, you had no way to remove the ID other than to physically remove the entire attribute fromthe document. Listing C-11 demonstrates how to set and remove an ID on a document notcontaining a DTD and use only these new methods.

Listing C-11. Setting Attribute IDs Using DOMElement Methods

<?php$xmldata = '<?xml version="1.0" ?><courses>

<course cid="c1"><title>Basic Languages</title>

</course></courses>';

$dom = new DOMDocument();$dom->loadXML($xmldata);$root = $dom->documentElement;$node = $root->firstChild;$course = $node->nextSibling;

$course->setIDAttribute('cid', TRUE);print "setIDAttribute - TRUE\n ";if ($element = $dom->getElementByID('c1')) {

print $element->nodeName;} else {

print "ID Does not exist";}

$attr = $course->getAttributeNode('cid');$course->setIDAttributeNode($attr, FALSE);print "\n\nsetIDAttributeNode - FALSE\n ";if ($element = $dom->getElementByID('c1')) {

print $element->nodeName;} else {

print "ID Does not exist";}?>

setIDAttribute - TRUEcourse

setIDAttributeNode - FALSEID Does not exist

APPENDIX C ■ FEATURES AND CHANGES IN PHP 6884

Page 45: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Finally, I will now cover probably one of the most requested features for DOM. The normalmethod for creating objects based on a class that extends one of the DOM classes and inserting itinto the tree was to create the node using the new keyword to instantiate an object of the extendedclass type. This node was then inserted into the tree using any of the various DOM methodsapplicable for this action. This method had a few drawbacks. Probably the most important onewas that you should use the createXXXX() methods from DOMDocument when creating a new nodeto properly create it with a document association. The other big drawback, which mostly affecteddevelopers, was that once the newly created object fell out of scope and no longer had any refer-ences, the next time the node was accessed, the object returned would be based on one of theinternal DOM classes and no longer the extended class type.

The good news is that you can finally do this—or at least once PHP 6 rolls around, you willbe able to do this. The registerNodeClass() method has been added to the DOMDocument class.This method allows a user class that extends any of the DOM classes based on DOMNode to be reg-istered with a document and cause the extended class to be instantiated when needed ratherthan the internal DOM class. Every method within DOM will respect the class registration:

registerNodeClass(string baseclass, string extendedclass)

This method takes two parameters and returns a Boolean indicating whether registrationwas successful. The first parameter, baseclass, is the name of the DOM class that the userclass is replacing. The extendedclass parameter is either the name of the user class to register,which must inherit from baseclass, or NULL. When NULL is passed, any class that may have pre-viously been registered for the baseclass will unregister itself, causing the baseclass to onceagain be used as the class type when objects are created.

■Note Classes are registered per document and not per request. This also means that reusing aDOMDocument object for multiple XML documents will reset the registered classes to the original empty state each time a new document is loaded.

As mentioned in the previous note, classes are registered per document. This means everytime a new document is created, you must register your classes. For example, each of the fol-lowing calls creates a new document:

/* Create a new empty document */$dom = new DOMdocument();

/* Load a string creating a new document */$dom->loadXML(...);

/* Load a URI creating a new document */$dom->load(...);

Based on this, unless you are creating a new document from scratch, you would not regis-ter any classes until after having called one of the load methods. A benefit of this being basedon a document, however, is that if you are working on two or more documents simultaneously,

APPENDIX C ■ FEATURES AND CHANGES IN PHP 6 885

Page 46: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

each document can use a different class for a node type, rather than only a single class pernode type for every document. This may sound more complex than it really is. Listing C-12should make things much clearer.

Listing C-12. Registering Extended Classes in DOM

<?phpclass userElement extends DOMElement {

function customFunction() {print "Node Name: ".$this->nodeName."\n";print "Node Contents: ".$this->nodeValue."\n";

}}

$xmldata = '<?xml version="1.0" ?><courses>

<course cid="c1"><title>Basic Languages</title>

</course></courses>';

$dom = new DOMDocument();/* Load the XML, and remove blanks for simplicity */$dom->loadXML($xmldata, LIBXML_NOBLANKS);

/* Register the userElement class */print "Register userElement class\n\n";$dom->registerNodeClass('DOMElement', 'userElement');$root = $dom->documentElement;$course = $root->firstChild;$title = $course->firstChild;$title->customFunction();

/* Unregister our custom class */print "Unregister Custom Class\n\n";$dom->registerNodeClass('DOMElement', NULL);print "Remove reference to title node using unset()\n\n";/* Call unset() to remove reference to title node */unset($title);?>

Register userElement class

Node Name: titleNode Contents: Basic LanguagesUnregister Custom Class

APPENDIX C ■ FEATURES AND CHANGES IN PHP 6886

Page 47: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

Remove reference to title node using unset()

course element is of the userElement class

title element is of the DOMElement class

No longer do you need to use the new keyword. The ability to register classes with a docu-ment solves many of the issues developers have had when a subclassed object loses scope.Even when a class was unregistered, objects in scope that were created based on the extendedclass remain the extended class type until they also lose scope. Listing C-12 demonstrated thiswith the course element. This still does not provide persistence; when an object goes out ofscope, it is re-created when the node is accessed again. Therefore, property values will bereset, but all the functions of the class are available.

APPENDIX C ■ FEATURES AND CHANGES IN PHP 6 887

Page 48: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

■Symbols{ } (curly braces), 349–350/ (forward slash), 21( ) (parentheses), 49, 51[ ] (square brackets), 26, 48< (angle bracket)

attribute values, 25comments, 27–28entity references, 17PCDATA content, 53processing instructions, 28start and end tags, 21

> (angle bracket)comments, 27–28entity references, 17processing instructions, 28start and end tags, 21

= (equal sign), 132>= (greater than or equal to sign), 132> (greater than sign), 132<= (less than or equal to sign), 132< (less than sign), 132+ (plus sign), 49, 132? (question mark), 28, 49' (single quote), 17, 24, 25! (exclamation point), 26, 27–28!= (not equal sign), 132

■Aabout attribute

channel element, RSS 1.0, 524image element, RSS 1.0, 526item element, RSS 1.0, 527

absolute paths, XPath, 127accept attribute, 153accept-language attribute, 153accessPoint element, 759, 760acronyms, 14actor attribute, 700, 708Actor parameter, 664actor parameter, 724, 731, 869actualEncoding property, 859addChild() method, 500addFunction() method, 727, 871add_publisherAssertions() function, 768address element, 756address structure, 756–757addressLine attribute, 757adult_ok parameter, 648AdWords API, 13, 744Ajax (Asynchronous JavaScript Technology and

XML), 826–830Al-Ghosein, Mohsen, 10Alexa Web Information Service, 660

all element, 78, 86allow_url_fopen option, 175–176Amazon E-Commerce Service (ECS), 13, 660, 781–785Amazon Historical Pricing Service, 660Amazon Simple Queue Service, 660Amazon Web services, 660–661

error format, 661–663item searches, 663–666registering, 661remote shopping cart, 666–672, 784–785Services_Amazon PEAR package, 781–785

ancestor axis, 128ancestor-or-self axis, 128and operator, 132andAllKeys option, 767annotation elements, 88ANSI (American National Standards Institute), 14any element, 84ANY value, 50, 84anyAttribute element, 84anyName pattern, 105anySimpleType type, 839anyType type, 84, 839anyURI type, 840API versioning, URIs and, 638–639appendChild() method, 206–207, 209–210, 858appendData() method, 863appendXML() method, 859appid parameter, 648, 652appinfo element, 88application-specific instructions. See PIs

(processing instructions)applying templates, 345–347array element, 572, 599–600array type, 569array type definitions, 678–679arrays

parsing data into, 288–291serializing, 506–510unserializing, 510–512

Artist parameter, 664AssociateTag parameter, 667Association of Shareware Professionals (ASP), 230asXML() method, 241, 853Asynchronous JavaScript Technology and XML

(Ajax), 826–830Atkinson, Bob, 10Atom, 522. See also RSS technologies

Atom entry documents, 543, 549–550Atom feed documents, 542–543, 547–549constructs, 543–547document structure, 543sample document, 542selecting feed technologies, 550–551

Index

889

R. Richards, Pro PHP XML and Web Services,DOI 10.1007/978-1-4302-0139-7, © 2006 by Robert Richards

Page 49: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

using DOM (example), 551–555, 557–560using XMLReader (example), 561–563

Atom class, 557–560Atom entry documents, 543, 549–550Atom feed documents, 542–543, 547–549atomCommonAttributes definition, 543ATTLIST declarations, 36–38, 59–66Attr interface, DOM, 187ATTRIBUTE constant, 318, 850attribute declarations

attribute IDs, 36–41, 64attribute-list declarations, 59–66namespaces in XML schemas, 94–97RELAX NG schemas, 101–102, 113–114

attribute default values, 60–62attribute groups, 79attribute IDs, 36–41, 64attribute-list declarations, 59–66attribute nodes

canonical XML, 455DOM extension, 207–208XPath, 124, 125–126

attribute pattern, 112, 113–114attribute sets, XSLT, 352–353attribute types, 62–66attribute values, 25, 326, 450attribute XPath axis, 128attributeCount property, 321, 851attributeFormDefault attribute, 95–97attributeGroup element, 79attributes, 24

case sensitivity, 17–18child elements vs., 25–26creating using XSLT, 351–352IDs, 36–41, 64in canonical XML, 450, 451–453, 457in DOM, 201–203in DTDs, 36–38, 40–41, 59–66, 64in RELAX NG schemas, 113–114in SimpleXML, 255–257in XML documents, 24–26in XML schemas. See attributes (XML schemas)namespaces and, 31, 32, 35–36naming, 24–25types, 62–66usage guidelines, 25–26values, 25XMLReader access, 325–327

attributes key, 289attributes() method, 256, 259, 853attributes property, 857attributes (XML schemas). See also attributes;

schemas, XMLattribute groups, 79declaring, 73, 74–75, 79default values, 79global declarations, 95local declarations, 95namespaces and, 76, 94–100qualified local declarations, 95–97simple types, 72–73, 83–84

unqualified local declarations, 94–95usage options, 79user-defined types, 80–83

authentication. See also digital signatureseBay Web services, 743SOAP messages, 719UDDI registries, 773–774XML signatures, 460

authentication option, 711author element

entry element, Atom, 549, 558feed element, Atom, 548, 558item element, RSS 2.0, 540

Author parameter, 664authorizedName attribute, 755, 761AverageRating element, 653axes, XPath, 127–128, 131–132

■Bbase attribute, 42–43, 543base64 element, 599, 610–611Base64 encoding, 27, 67base types, 73base URIs, 42–43base64Binary type, 841baseURI property, 321, 851, 858Berners-Lee, Tim, 3binary data in CDATA sections, 27binary element, 576binary large object (BLOB) fields, 8binary type, 569binding attribute, 695–696binding definitions, WSDL, 681

SOAP binding, 691SOAP headers, 694SOAP operation, 692–693WSDL operation, 691–692, 693–694

binding element, 690–691bindingKey attribute, 759bindingTemplate structure, 758–760bindingTemplates attribute, 758blogInfo() method, 790, 791–792blogPostTags() method, 790, 792–793body, XML documents, 20Body element, 701BOM (byte order mark), 19, 169bookmarks, online, 785–786boolean element, 571, 597boolean() function, 138boolean type, 569, 840Box, Don, 10buffering documents, XMLWriter, 817–818bug fixes, libxml2, and libxslt libraries, 164built-in types, 73built-in XSL templates, 347–348businessEntity structure, 754–757, 774businessKey attribute, 755, 758businessService structure, 757–758businessServices element, 755byte index, 291–292, 304byte type, 842

■INDEX890

Page 50: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

■CCache element, 650cached pages, retrieving, 787calculations, XPath expressions, 146, 160_call() method, 743–744callbacks, 826call_using_curl() function, 601call_using_sockets() function, 601canonical XML

attribute nodes, 455canonical form requirements, 449–451comment nodes, 456element nodes, 454empty namespace declarations, 454encrypting data, 482exclusive XML canonicalization, 456–460namespace nodes, 454–455node ordering, 450, 451–453processing instruction nodes, 455–456root node, 453text nodes, 455whitespace, 455

CanonicalizationMethod element, 464, 470, 473cards, WML, 831carriage return character

formatting XML documents, 23–24in canonical XML, 455in SAX parser, 277, 278in user-derived types, 81–82in XML documents, 16

CartAdd operation, 670–671CartClear operation, 670CartId element, 669CartItemId element, 671CartModify operation, 671Cascading Style Sheets, WAP (WCSS), 835case folding, SAX parser, 273case-order attribute, 362case sensitivity, 17–18, 64caseFolding option, 502caseFoldingTo option, 502caseSensitiveMatch, 766Catalog element, 652, 656category element

Atom, 546entry element, Atom, 549feed element, Atom, 548item element, RSS 2.0, 540

categoryBag attribute, 758categoryBag element, 755, 762CDATA constantcdata() method, 518cdata-section-elements attribute, 382, 384CDATA sections, 173–174, 277–278, 450CDATA type, 62–63. See also NMTOKEN,

NMTOKENS typescdataHandler() method, 494CDATASection interface, 187ceiling() function, 138certificates, XML signatures, 465channel element, 524–526, 530–532, 536–537, 552,

555, 556

channels, RSS, 524–526, 531, 532, 536–537character data

CDATA attribute type, 62–63character data event handlers, 275–279, 284, 308in canonical XML, 450in DOM parser example, 308in XML documents, 16–17markup vs., 16–17

character data encryption, 476character data handlers, 301character encodings, 19character escaping, 146character references, 15–16, 17, 62, 450CharacterData interface, 184, 186characters

allowed in names, 16case sensitivity, 17–18, 64character references, 15–16, 17, 62, 450decimal, hexadecimal equivalents, 15–16restricted characters, 17, 25Unicode character set, 15whitespace characters, 16

child axis, XPath, 128child content model, 50–52child elements

attributes vs., 25–26child content model, 50–52complex types, 73–76, 84–85in RELAX NG schemas, 101–103, 105in SimpleXML, 244, 245, 246–250, 252mixing with text content, 85–86nested elements, 23–24

child nodes, DOM extension, 196–197childNodes property, 196–197, 857children() method, 246–247, 259, 853children property, 500choice element, 78choice pattern, 105, 106, 114chunking data, SAX parser, 286–287, 304CipherData element, 479–480, 483, 485, 487CipherReference element, 480, 487CipherValue element, 480, 483, 487circular entity references, 55class definitions, WSDL, 679–680classaddFunction() method, 727, 871classes, DOM extension

constructors, 220extending, 219–220, 226, 228methods, 221migrating from domxml extension, 228–230objects, classes, and interfaces, 183, 184,

186–187, 885–887properties, 220–221registering, 885–887scope and object lifetime, 221–223, 226,

885–887classes, SimpleXML extension, 257–258classmap option, 711classmap parameter, 724ClickUrl element, 650Client fault code, SOAP, 702

■INDEX 891

Find it faster at http://superindex.apress.com/

Page 51: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

clientsREST Web service (example), 643–645SOAP. See SOAP clientsvalidating server-based data, 826–830WDDX Web service (example), 587–589XML-RPC, 612–617, 625, 628

cloneDocument property, 389, 866cloneNode() method, 858close() method, 851code property, 178, 847collections

iterating, 196–197, 201–202, 225, 245–246NameNodeMap interface, 184, 186, 225NodeList interface, 184, 186of attributes, 201–202of elements, 245–246of node sets, 358–360, 360–362, 406–407of nodes, 196–197, 225removing nodes, 225

collisions, namespace, 31column number, SAX, 291–292, 303–304column property, 178, 847combineCategoryBags option, 767combining schemas

local vs. global declarations, 93namespaces and, 94–100using import elements, 97–100using include elements, 91–93

COMMENT constant, 317, 318, 850Comment interface, 187comment() method, 518comment nodes

canonical XML, 456CharacterData interface, 184, 186creating using XSLT, 354XPath, 124, 127

comments, XML documents, 27–28comments element, 540Common EXSLT module, 378Common Object Response Broker Architecture

(CORBA), 10comparing parsers. See parser comparisonscomplex element content, 86–87complex type definitions, WSDL, 680–681complex types, 73–76, 84–85complexContent element, 86–87complexType element, 74compression option, 711concat() function, 137conditional processing, XSLT, 358conditional sections, DTDs, 68–70connection_timeout option, 711constrained implementation, 459–460constraining facets, 80–83_construct() method, 853

DOMAttr class, 862DOMCdata class, 864DOMComment class, 863DOMDocument class, 860DOMDocumentFragment class, 859DOMElement class, 862DOMEntityReference class, 865DOMProcessingInstruction class, 866

DOMText class, 864DOMXPath class, 856SoapClient class, 710–712, 870SoapFault class, 870SoapHeader class, 708, 869SoapParam class, 869SoapServer class, 724–725, 871SoapVar class, 707, 868–869

constructors, DOM classes, 220contact structure, 756contacts element, 755contains() function, 137content

complex element content, 86–87default element content, 76–77element content, 21empty element content, 112–113fixed element content, 76–77mixed element content, 85–86, 107–108, 111–112PCDATA content, 52–54reusing. See XInclude

content blocks, RSS, 527–528, 532–534, 539–541content element, 546, 549content management systems (CMS), 6–7Content module, 532–534content syndication. See syndicationcontext nodes, XPath, 127, 134contexts (stream contexts), 176–177contributor element, 548, 550convenience of parsers. See parser comparisonsconverting document encoding, 171–172copying

nodes, 354–355subtrees, 436–438

CORBA (Common Object Response BrokerArchitecture), 10

cosmos() method, 790count attribute, 363, 364, 365count() function, 136country parameter, 648createAttribute() method, 860createAttributeNS() method, 860createCDATASection() method, 860createComment() method, 860createDataObject() method, 824createDocument() method, 204, 856createDocumentFragment() method, 860createDocumentType() method, 204, 856createElement() method, 204–205, 860createElementNS() method, 204–205, 860createEntityReference() method, 860createProcessingInstruction() method, 860CreateRatingUrl element, 653createTextNode() method, 209–210, 860creating resources, 636, 637. See also REST

(Representational State Transfer)CRUD operations, 636current() function, 374

■DData Access Service, SDO, 820–826data element, 102, 570data encryption. See encryption

■INDEX892

Page 52: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

data exchange extensions, 166data parameter

SoapHeader class constructor, 708, 869SoapParam class constructor, 709, 869SoapVar class constructor, 707, 869

data pattern, 114data property, 863, 866data storage and retrieval applications, 7–9data structures, UDDI. See UDDI (Universal

Description, Discovery, and Integration)data-type attribute, 362data type definitions, WSDL, 678–681data types

any types, allowing, 84attribute types, 62–66base types, 73built-in types, 73complex types, 73–76, 84–85constraining facets, 80–83derived types, 73, 80–83, 841–843empty elements, 85length, restricting, 81matching regular expressions, 81multiple types, allowing, 83–84PHP and XML-RPC data types, converting,

610–611, 623primitive types, 73, 839–841RELAX NG schemas, 102, 114simple types, 72–73, 83–84, 839–841user-derived types, 73, 80–83WDDX, 568–569XML schemas, 839–843

databases, 7–9datatypeLibrary attribute, 102Date construct, 545date type, 840dateTime element, 571dateTime type, 103, 569, 840dateTime.iso8601 element, 598–599, 610–611debugging. See also errors and error handling

SOAP client calls, 722–723XSLT, 376

decimal notation for characters, 15–16decimal-separator attribute, 372decimal type, 840decks, WML, 831declaration handlers, 281–283declaration separators, 59declarations

attribute lists. See attribute-list declarationsattributes. See attribute declarationsdocument type declarations, 19–20, 46–49element type declarations, 50–54entity declarations, 29, 54–59external subset declarations, 47–48markup. See markup declarationsnamespace. See namespace declarationsnotation declarations, 66–67scope of. See scopeXML declaration, 18–19, 450

decrypting data, 447–448, 484–489deep copies of nodes, 355default attribute, 79

default attributes, canonical XML, 450default element content, 76–77default event handlers, 283–284, 302–303, 875default mode, XMLSerializer class, 506default namespaces

canonical XML, 454, 458–459SimpleXML, 259XML, 32, 34–35XML schemas, 96XPath, 227

DEFAULTATTRS constant, 850defaultHandler() method, 494define element, 119defines, RELAX NG, 117–119DELETE (HTTP), 636, 637delete_binding() function, 768delete_business() function, 768deleteData() method, 863delete_publisherAssertions() function, 768delete_service() function, 768delete_tModel() function, 768deleting resources, 636, 637. See also REST

(Representational State Transfer)del.icio.us Web service, 785–786department parameter, 652depth property, 321, 851derived types, 73, 80–83, 841–843descendant axis, XPath, 128descendant nodes, XPath, 125descendant-or-self axis, XPath, 128description attribute, 758Description element, 652description element

bindingTemplate structure, 759businessEntity structure, 755channel element, RSS 1.0, 525channel element, RSS 2.0, 536contact structure, 756image element, RSS 2.0, 538item element, RSS 1.0, 528item element, RSS 2.0, 538textinput element, RSS 1.0, 528textInput element, RSS 2.0, 538tModel structure, 761

deserialize() method, 590detached encryption, 477detached signatures, 462detail element, 703–704detail parameter, 709, 710, 870DigestMethod element, 465DigestValue element, 465, 472digit attribute, 373digital signatures, 460–461. See also encryption

algorithms, 448–449creating, 466–471detached signatures, 462enveloped signatures, 461enveloping signatures, 461–462generating references, 467–469generating signatures, 470–471hashing serialized XML, 443–445message integrity, 442–443verifying signatures, 471–474

■INDEX 893

Find it faster at http://superindex.apress.com/

Page 53: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

W3C specifications, 447XML signature structure, 462–465

digits in user-defined types, 82Director parameter, 664disable-output-escaping attribute, 353discard_authToken() function, 768, 774discoverURLs element, 755–756Distributed Component Object Model (DCOM), 10distributed computing, 9distributed information systems. See Web servicesdiv operator, 132DOC constant, 317, 318, 850DOC_FRAGMENT constant, 317, 318, 850docstring key, 626DOC_TYPE constant, 317, 318, 850DOCTYPE declarations, 19–20, 46–49doctype property, 859doctype-public attribute, 382, 383, 384doctype-system attribute, 382, 383, 384document editing, parser comparisons, 410,

415–416document element, 18, 20

in document type declarations, 46retrieving using DOM extension, 193–194XPath element nodes, 125

document encryption, 476document() function, 370Document interface, 186Document/literal message format, WSDL, 683–685document navigation, parser comparisons, 410,

413–415document nodes, 159, 203–204Document Object Model. See DOM (Document

Object Model)document tree, 20document type declarations (DOCTYPE), 19–20,

46–49. See also markup declarationsdocumentElement property, 859documents

HTML. See HTML documentsRSS, 391–392well-formed documents, 45XHTML, 516–519XML. See XML documents

DocumentType interface, 187documentURI property, 859doGetCachedPage() function, 746–747doGoogleSearch() function, 746, 747–748DOM (Document Object Model), 9, 14, 181.

See also DOM extension; DOM objectscreating feeds, 551–560node types, 181–182, 194Services_Webservice package, 797–802tree representation of documents, 182XML_Tree package, 498–501

DOM extension, 165, 185–188, 854–855, 883–887.See also DOM (Document Object Model)

attribute nodes, 207–209attributes, 201–203, 883–884CDATA section nodes, 211child nodes, 196–197choosing parsers, 424–425, 426

classesconstructors, 220extending core classes, 219–220, 226, 228methods, 221objects, classes, and interfaces, 183, 184,

186–187properties, 220–221registering, 885–887scope and object lifetime, 221–223, 226,

885–887comments, 211creating and instantiating documents, 188–189document editing, 410, 415, 416document element, 193–194document fragments, creating, 211document navigation, 410, 414, 415document node, 199, 203–204domxml extension migration, 228–230ease of use, 410, 416element nodes, 204–206, 206–207elements, 199–201, 217–218entity reference nodes, 211exporting nodes from XMLReader, 328external subsets and, 215handling encoded data, 188, 226importing nodes from SimpleXML, 434, 435–436internal subsets and, 214–215large document processing, 411, 412, 413loading HTML data, 190–191loading XML data, 189–190, 193locating elements, 431–432, 433namespace declarations, 203namespace support, 410, 418–419namespaces, registering, 218–219, 227navigating between nodes, 196–201node information, 194–196, 217node types, 181–182, 194objects, creating and instantiating, 187–188,

885–887optimizing, 426–427, 431–432, 433PAD template (example), 230–234parent nodes, 198–199processing instruction nodes, 211removing nodes, 212–213, 225replacing nodes, 213saving HTML data, 192saving XML data, 191sibling nodes, 198SimpleXML interoperability, 250, 253, 255,

434–436subtrees, 197system resource usage, 410, 411, 412, 413text nodes, 209–210troubleshooting, 223–228validation

using DTDs, 214–215using RELAX NG schemas, 216using XML schemas, 215–216

XMLReader interoperability, 436–438XML_Tree package, 498–501XPath support, 216–219XSL template (example), 235–237

■INDEX894

Page 54: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

DOM objects. See also DOM (Document ObjectModel)

constructors, 220creating and instantiating, 187–188extending core classes, 219–220, 226, 228,

885–887in PHP sessions, 224–225methods, 221nodes vs. objects, 221–223objects, classes, and interfaces, 183, 184,

186–187, 885–887properties, 220–221scope and object lifetime, 221–223, 226serialization, 224–225

DOM parser, SAX example code, 306–310DOMAttr class, 187, 228, 861–862DOMCdata class, 864DOMCDATASection class, 187, 228DOMCharacterData class, 186, 210–211, 863DOMComment class, 187, 863DOMDocument class, 186, 188–192, 203–204,

859–861. See also tree, DOMDOMDocument object, 392–393DOMDocumentFragment class, 186, 211, 212, 859DOMDocumentType class, 187, 864–865domdtd class, 228DOMElement class, 187, 862DOMEntity class, 187, 865DOMEntityReference class, 187, 228, 865DOMException class, 186, 856DOMException interface, 184DOM_HIERARCHY_REQUEST_ERR constant, 855DOMImplementation class, 185, 186, 203–204, 856dom_import_simplexml() functionDOM_INDEX_SIZE_ERR constant, 855DOM_INUSE_ATTRIBUTE_ERR constant, 855DOM_INVALID_ACCESS_ERR constant, 855DOM_INVALID_CHARACTER_ERR constant, 855DOM_INVALID_MODIFICATION_ERR constant,

855DOM_INVALID_STATE_ERR constant, 855DOMNamedNodeMap class, 186, 201–202, 857DOM_NAMESPACE_ERR constant, 855DOMNameSpaceNode class, 186domnamespacenode class, 228DOM_NO_DATA_ALLOWED_ERR constant, 855DOMNode class, 186, 194–196, 857DOMNodeList class, 186, 196–197, 856DOM_NO_MODIFICATION_ALLOWED_ERR

constant, 855DOMNotation class, 187, 865DOM_NOT_FOUND_ERR constant, 855DOM_NOT_SUPPORTED_ERR constant, 855DOMProcessingInstruction class, 187, 228, 865–866DOMSTRING_SIZE_ERR constant, 855DOM_SYNTAX_ERR constant, 855DOMText class, 187, 864DOM_VALIDATION_ERR constant, 855DOM_WRONG_DOCUMENT_ERR constant, 855domxml extension, 165, 228–230DOMXPath class, 187, 216–217, 856_doRequest() method, 720–722, 870doSpellingSuggestion() function, 746–747

double element, 597double type, 840DTDs (Document Type Definitions), 3, 14.

See also validationadding manually, 227attribute ID definitions, 36–38, 64attribute-list declarations, 59–66conditional sections, 68–70document type declarations, 19–20, 46–49element type declarations, 50–54entity declarations, 29, 54–59entity references, 28–29external subsets, 46–48in canonical XML, 450internal subsets, 48–49markup declarations. See markup declarationsnamespaces and, 35notation declarations, 66–67parsing, 512–516schemas vs., 71, 90standalone declaration and, 19validation

within DOM extension, 214–215XML_DTD package, 512, 515within XMLReader, 333

Dublin Core module, 530–531duration type, 840

■EE-Commerce Service, Amazon (ECS), 13, 660,

781–785ease of use, parsers. See parser comparisonseBay Web services, 13, 736

authentication, 743registration and setup, 736–737remote procedure calls, 743–744requests, 741responses, 741–742Services_Ebay package, 786SOAP client implementation, 737–740

eBayAuth class, 743ebay.ini file, 738–739ebaySession object, 739–740eBaySOAP class, 741efficiency of parsers. See parser comparisonsEJSE, 793ELEMENT constant, 317, 318, 850element content, 21<!ELEMENT declaration, 50–54element encryption, 475element event handlers, 274–275element groups, 78–79element hierarchy, 22–24Element interface, 187element nodes, 124, 125, 204–207, 454element type declarations, 50–54elementFormDefault attribute, 95–97elementIsDeclared() method, 514elements

attribute IDs, 36–41attributes vs., 25–26case sensitivity, 17–18components of, 21

■INDEX 895

Find it faster at http://superindex.apress.com/

Page 55: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

default namespaces and, 32, 34–35, 227element handlers, 274–275element hierarchy, 22–24element type declarations, 50–54empty-element tags, 21–22identifying uniquely, 36–38in DOM, 199–201, 226–227in RELAX NG. See elements (RELAX NG)in SimpleXML. See elements (SimpleXML)in XML schemas. See elements (XML schemas)in XSL and XSLT. See elements (XSL, XSLT)namespaces and, 31, 32nesting of, 23–24referencing from other elements, 38–40

elements (RELAX NG)declaring, 101–103, 111–113defining allowable content, 112–113disallowing, 105empty content, 112mixed content, 107–108, 111–112naming elements, 104–105patterns. See patterns

elements (SimpleXML)accessing by index, 245–246accessing by name, 242–243accessing child elements, 244, 245–246accessing element content, 243–244accessing namespaced elements, 258–260accessing unknown elements, 246–247, 250collections, iterating, 245–246, 246–247modifying child elements, 252–253modifying subtrees, 252modifying text content, 251–252names of, determining, 247–250namespaces and, 258–260, 879–883removing from trees, 253–255replacing subtrees, 253

elements (XML schemas). See also schemas, XMLannotation elements, 88complex element content, 86–87complex types, 73–76, 84–85declaring, 73, 74–76default content, 76–77element groups, 78–79element name substitutions, 77–78empty elements, 85fixed content, 76–77global declarations, 95local declarations, 95mixed content, 85–86namespaces and, 94–100notation elements, 87–88NULL-valued elements, 77qualified local declarations, 95–97schema element, 72simple types, 72–73, 83–84unqualified local declarations, 94–95user-defined types, 80–83

elements (XSL, XSLT)creating, 350–351EXSLT extension elements, 377–378matching, 343selecting for processing, 346–347

email element, 545, 756empty attribute values, 25empty element content, 112–113empty-element tags, 21–22empty elements, 85, 450empty namespace declarations, 454empty pattern, 106EMPTY value, 50, 84enabled attribute, 87enclosure element, 540–541encoding and encoded data, 19

Base64 encoding, 27, 67binary data, WDDX, 576byte order mark (BOM), 169detecting document encoding, 168–170encoding conversions, 171–172, 293–294encoding declaration, 19, 169–170encryption, 293–294handling encoded data, 67, 188, 226images, XML documents, 65–66in canonical XML, 450in libxml2, 168, 170–172in XMLWriter, 816SAX parser options, 273target encoding, xml extension, 300

encoding attributebinary element, WDDX, 576xi:include element, 153xsl:output element, 382, 383, 387

encoding declaration, 19, 169–170encoding element, 534encoding option, 613, 711encoding parameter, 707, 724, 869encoding property, 859encodingStyle attribute, 698EncryptedData element, 478, 481, 483EncryptedKey element, 481encryption

algorithms, 448–449canonical XML, 482character data encryption, 476decrypting data, 447–448, 484–489detached encryption, 477document encryption, 476element encryption, 475encrypting data, 446–447, 480–484enveloping encryption, 477mixed content encryption, 475–476super encryption, 476–477W3C specifications, 447XML encryption structure, 477–480

EncryptionMethod element, 479, 483end-point() function, 151end tags, 21, 23–24endAttribute() method, 872endCdata() method, 872endComment() method, 872endDocument() method, 814, 873endDtd() method, 873endDtdElement() method, 873END_ELEMENT constant, 318, 850endElement() method, 814, 872END_ENTITY constant, 318, 850

■INDEX896

Page 56: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

endHandler() method, 494endPi() method, 872entities, 54–55. See also entity declarations; entity

referencesgeneral entities, 29, 55–57in SAX parser, 278–279in SGML, 3parameter entities, 57–59parsed entities, 55–56unparsed entities, 57, 374–375

entities property, 864ENTITY, ENTITIES types, 65–66, 843ENTITY constant, 317, 318, 850entity declarations, 29, 54–59Entity interface, 187entity references, 55

ENTITY, ENTITIES attribute types, 65–66entity errors, 227external entity reference handlers, 280–281,

305–306in attribute-list declarations, 62–63in canonical XML, 450, 455in SAX parser, 278–279, 280–281in XML documents, 28–29optimizing memory usage, 426–427for restricted characters, 17

ENTITY_REF constant, 317, 318, 850EntityReference interface, 187entityrefHandler() method, 494entry documents, Atom, 543, 549–550entry element, 543, 549–550, 557enumerated attribute types, 63–64enumeration element, 80Envelope element, 698enveloped signatures, 461enveloping encryption, 477enveloping signatures, 461–462epilog, XML documents, 20Error structure, Amazon Web services, 661–663errors and error handling. See also debugging;

faultsAmazon Web services, 661–663DOMException interface, 184, 186entity errors, 227failed XIncludes, 155–156failed XPointer expressions, 156–157fallback capabilities, XSLT, 380in XML-RPC, 607, 614, 618libxml2-derived errors, 177–179SOAP header entries, 700–701using SAX, 292–293validation errors, 177WSDL, 687, 689Yahoo Web services, 660

Errors structure, Amazon Web services, 661–663escaping characters, 146escaping option, 613evaluate() method, 216, 217–218, 856evaluating node sets. See expressions, XPathevent-based parsing, 165, 269–270. See also SAX

(Simple API for XML)event handlers, SAX

character data handlers, 275–279, 301

declaration handlers, 281–283default handler, 283–284, 302–303element handlers, 274–275external entity reference handlers, 280–281,

305–306namespace declaration handlers, 297object methods as handlers, 297–300processing instruction handlers, 279

event mode, XML_Parser, 495–496every quantifier, 161exactNameMatch option, 766except pattern, 104–105exceptions option, 711exceptNameClass pattern, 104–105exclusive XML canonicalization, 456–457, 459–460expand() method, 328, 436–438, 852expanded names, XPath nodes, 124expressions

attribute value templates, 349–350in markup declarations, 49–50XPath. See expressions (XPath)XPath 2.0, 159–161XPointer, 147–148

expressions (XPath)abbreviated syntax, 131–132axes, 127–128calculations in, 146complex expressions, 141–146equivalent XPointer expressions, 147filtering node sets, 133–134name tests, 128–130namespaces and, 141–143, 148node type tests, 130optimizing, 138–139value comparisons, 135–136, 144–145XPath functions, 136–138, 144–145, 146XPath operators, 130

exsl:document element, 378EXSLT modules, 377–380, 395extending classes

in DOM extension, 219–220, 226, 228in SimpleXML extension, 257–258

extends keyword, 219–220Extensible Business Reporting Language (XBRL), 6extension element, 87extension-element-prefixes attribute, 377–378extensions, PHP 5. See XML extensions, PHPexternal content, including. See XIncludeexternal entities, 47, 57, 65–66external entity reference handlers, 280–281,

305–306external patterns, 119–121external subsets, 46–48, 58, 68–70externalRef element, 119–121

■Ffacets, constraining, 80–83factory() function, 803fallback capabilities, XSLT, 380false() function, 138Fault element, 701–704fault element, 607, 618, 686, 687, 693, 694fault() method, 871

■INDEX 897

Find it faster at http://superindex.apress.com/

Page 57: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

fault structures, XML-RPC, 607, 614, 618faultactor element, 703, 709faultactor parameter, 870faultcode element, 702faultCode() method, 626faultcode parameter, 709, 870faultname parameter, 710, 870faults. See also errors and error handling

SOAP, 701–704, 709–710, 729–730, 870WSDL, 687, 693XML-RPC, 607, 618

faultstring element, 702–703faultString() method, 626faultstring parameter, 709, 870feed documents, Atom, 542–543, 547–549feed element, 543, 546, 547–549, 552, 557Feed Validator, 521feeds and feed technologies, 521–522, 550–551

Atom. See Atomcreating feeds using DOM, 551–560parser using SimpleXML (example), 560–561RSS 1.0. See RSS 1.0 (RDF Site Summary)RSS 2.0. See RSS 2.0 (Really Simple Syndication)

Field element, 655field element, 574–576Fielding, Roy, 633fieldNames attribute, 574–575file data, parsing, 287file property, 178, 847file security support, PHP 5, 175–176filter option, 788filter parameter, 748filtering, XPath expressions

abbreviated syntax, 131–132axes, 127–128calculations, 146filtering node sets, 133–134node tests, 128–130numeric comparisons, 136optimizing expressions, 138–139predicates, 130string comparisons, 135value comparisons, 135–136, 144–145XPath functions, 136–138XPath operators, 132

find_binding() function, 765find_business() function, 765find_relatedBusiness() function, 765find_service() function, 766find_tModel() function, 766firstChild property, 197, 857firstResultPosition attribute, 647fixed attribute, 79#FIXED attribute default, 61fixed element content, 76–77flags, PHP parser options, 173–174Flickr, 646float type, 840floor() function, 138flush() method, 814, 817–818, 872following axis, XPath, 128following-sibling axis, XPath, 128form attribute, 96–97

format attribute, 365format element, 533format-number() function, 372–373format parameter, 648formatFile() method, 503formatOutput property, 859formatString() method, 503–504formatted numbers, XSLT results tree, 362–366formatting XML documents, 23–24, 502–504,

816–817forms, RSS, 528–529, 538–539fractionDigits element, 82from attribute, 363, 364, 365fromKey element, 764func mode, XML_Parser, 495–496func:function element, 378func:result element, 378function() function, 397–399function key, 626functions. See also methods; names of specific

functionsuser-defined, 378–380XPath, 136–138, 144–145, 146XPointer, 149–151

Functions EXSLT module, 378–380functionString() function, 397–399

■GgDay type, 841general entities, 29, 55–59. See also parameter

entitiesgenerate-id() function, 375generator element, 548GET (HTTP), 636–637get_assertionStatusReport() function, 768getAttribute() method, 202, 329, 331, 851, 862getAttributeNo() method, 851getAttributeNode() method, 202, 862getAttributeNodeNS() method, 202, 862getAttributeNS() method, 202, 331, 862getAttributeNs() method, 851getAttributes() method, 514get_authToken() function, 768, 773get_bindingDetail() function, 766get_businessDetail() function, 766get_businessDetailExt() function, 766getCachedPage() method, 787getChannelInfo() method, 564getChildren() method, 514getContent() method, 515getDocNamespaces() method, 854, 879–891getDTDRegex() method, 515getElement() method, 500getElementByID() method, 226–227, 860getElementsByTagName() method, 199–200, 861,

862getElementsByTagNameNS() method, 199, 201,

861, 862getForecast() method, 796getFunctions() method, 871_getFunctions() method, 712, 870getImages() method, 564getInfo() method, 790

■INDEX898

Page 58: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

getItems() method, 564_getLastRequest() method, 722, 870_getLastRequestHeaders() method, 722, 870_getLastResponse() method, 722, 870_getLastResponseHeaders() method, 722, 870getLocation() method, 794getMessage() method, 515getNamedItem() method, 857getNamedItemNS() method, 857getNamespaces() method, 854, 879–881get_object_vars() method, PHP, 247–248getParameter() method, 390, 393, 394–395, 866getParserProperty() method, 316–317, 851getPcreRegex() method, 515get_publisherAssertions() function, 768get_registeredInfo() function, 768getSerializedData() method, 509get_serviceDetail() function, 766getStructure() method, 565getTextinputs() method, 564get_tModelDetail() function, 766_getTypes() method, 712, 870getUnserializedData() method, 511getUser() function, 741getUserRequestType parameter, 741getWeather() method, 795global scope of declarations, 89–91, 93GlobalWeather, 793GML (Generalized Markup Language), 2gMonth type, 841gMonthDay type, 841Goldfarb, Charles F., 2Google Web services, 12–13

AdWords API service, 744cached pages, retrieving, 787checking spelling, 787doGetCachedPage() function, 746–747doGoogleSearch() function, 746, 747–748doSpellingSuggestion() function, 746–747GoogleSearchResult structure, 745, 748–750registration and setup, 744search services, 744–750, 788–789Services_Google package, 786–789

GoogleSearchResult structure, 745, 748–750grammar element, 117–119, 120grammars, 46, 49–50, 57–59group element, 78–79group pattern, 106grouping-separator attribute, 363, 372grouping-size attribute, 363groups and grouping, 78–79guid element, 541gYear type, 841gYearMonth type, 841

■Hhandle() method, 729, 871handleElement() method, 497handlers, event-based parsing, 165handlers, registering, 494, 505hasAttribute() method, 862hasAttributeNS() method, 862hasAttributes() method, 201, 858

hasAttributes property, 321, 851hasChildNodes() method, 196–197, 858hasExsltSupport() method, 390, 395, 866hasFeature() method, 856hashing serialized XML, 443–445hasValue property, 321, 851HEAD (HTTP), 636header element, 570, 699header entries, SOAP

Header element, 699–701in SOAP clients, 718–719in SOAP servers, 730–732SoapHeader class, 708

headerfault parameter, 710, 870headers, 601–602, 605height element, 538here() function, 151hexadecimal notation for characters, 15–16hexBinary type, 841highestprice parameter, 652history of XML, 2–4HMAC hash, 444hostingRedirector element, 760href attribute

link element, Atom, 546xi:include element, 152XLink, 158

hreflang attribute, 546HTML documents

parsing, 504–506transforming XML data, 356–357using XSLT processor, 391–392

HTML (Hypertext Markup Language), 3, 22–24loading in DOM trees, 190–191outputting to XSLT trees, 385–387

html value, Text construct, 544HTTP DELETE, 636, 637HTTP GET, 636–637HTTP HEAD, 636HTTP POST

in REST architecture, 636, 637using SOAP, 704XML-RPC request headers, 601–602

HTTP PUT, 636, 637HTTP requests, using SOAP, 704HTTP responses, using SOAP, 705

■Ii4 element, 597IANA (Internet Assigned Numbers Authority), 19icon element, 548iconv extension, 171–172ID attributes, 36–38, 40–41, 64, 226–227id element, 547, 549id() function, 136, 155id specification, 36, 40–41ID type, 73, 843identifierBag element, 755, 762IDREF attribute, 38–39, 64IDREF type, 73, 843IDREFS attribute, 39–40, 64IDREFS type, 843IDs, 370–372, 375, 389

■INDEX 899

Find it faster at http://superindex.apress.com/

Page 59: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

ie parameter, 748if/then/else expressions, 160–161IGNORE blocks, 68–70image element

channel element, RSS 2.0, 537, 538items element, RSS 1.0, 526RDF element, RSS 1.0, 526–527, 530

imagesadding to XML documents, 65–66in RSS feeds, 526–527, 538notation elements, 87–88

imageType attribute, 87implementation property, 859#IMPLIED attribute default, 60–61import element, 91, 97–100importNode() method, 861importStylesheet() method, 390–391, 866INCLUDE blocks, 68–70include element, 91–93including conditional DTD sections, 68–70inclusive canonical XML, 457. See also canonical

XMLInclusiveNamespaces PrefixList parameter,

457–459indent attribute, 381, 383indent option, 502indentation, 23–24indentXML() method, 518infinity attribute, 373inline style sheets, 343input element, 686, 689, 693input settings, XML_Parser, 495Inquiry API, UDDI, 765–767, 769–772insertBefore() method, 206, 207, 209–210, 858insertData() method, 863instructions in schemas, 88int element, 597int type, 842integer type, 842integrity, 460. See also digital signaturesinterleave pattern, 108–109intermediaries, 700internal parsed entities, 55–56internal subsets, 48–49, 58internalSubset property, 865IRIs (internationalized resource identifiers), 543isDefault property, 321, 851isDefaultNamespace() method, 858isElementContentWhitespace() method, 864isEmptyElement property, 321is_final parameter, 285–287isId() method, 862ISO-8859-1, ISO-2022-JP encodings, 19ISO 10646 character set, 15ISO (International Organization for

Standardization), 14isSameNode() method, 199, 858is_soap_fault() function, 868isSupported() method, 858isValid() method

xml extension, 333, 334XML_DTD, 515, 519XMLReader, 851

isWhitespaceInElementContent() method, 864item element

channel element, RSS 2.0, 539–541Content module, 533RDF element, RSS 1.0, 527–528, 530, 556

item() method, 856, 857ItemPage parameter, 664items element, 524, 532–533, 555itemType attribute, 83iterating collections

of attributes, 201–202of nodes, 196–197, 225of XSLT node sets, 358–360, 360–362, 406–407

■JJavaScript (Ajax), 826–830

■Kkey() function, 370–372key parameter, 748keyedReference element, 764KeyInfo element, 465, 479, 481, 485, 487keyInfo() method, 790keys

HMAC hash, 444XML encryption, 479, 481, 485XML signatures, 465XSLT, 370–372, 389

Keywords parameter, 664, 665

■Llabel attribute, 546lang attribute

Atom elements, 543XML, 42xsl:sort element, 362

lang() function, 138language option, 788language parameter, 648language type, 842languages, specifying, 42large document processing

breaking into smaller documents, 426–427,436–438

DOM extension, 411, 412, 413optimizing memory usage, 426–427optimizing performance, 429–433parser comparisons, 411–413SimpleXML, 411, 412, 413streaming parsers, 411, 413tree-based parsers, 411, 413xml extension, 412, 413XMLReader, 413

last() function, 136lastChild property, 197, 857length attribute, 546, 572length element, 81length property, 863level attribute, 363, 364, 365level key, array structures, 289level property, 178, 847li element, 525, 555, 556

■INDEX900

Page 60: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

librariesdetermining library version, 172–173libxml2. See libxml2 librarylibxslt. See libxslt libraryPEAR. See PEARsupported versions, 163–164

libxml extension, 167–168, 845libxml2 library

enabling and disabling, 167encoding conversions, 171–172errors, retrieving, 293internal document encoding, 170–172library location, 167–168library version, 172–173libxml2-derived errors, 177–179supported versions, 163–164

libxml_clear_errors() function, 178–179, 846LIBXML_COMPACT constant, 846LIBXML_DOTTED_VERSION constant, 845LIBXML_DTDATTR option, 173, 450, 845LIBXML_DTDLOAD constant, 845LIBXML_DTDLOAD option, 173, 450LIBXML_DTDVALID constant, 845LIBXML_DTDVALID option, 173LIBXML_ERR_ERROR constant, 847LIBXML_ERR_FATAL constant, 847LIBXML_ERR_NONE constant, 847LibXMLError object, 178–179LIBXML_ERR_WARNING constant, 847libxml_get_errors() function, 178–179, 846libxml_get_last_error() function, 178–179, 293, 846LIBXML_NOBLANKS constant, 846LIBXML_NOBLANKS option, 173LIBXML_NOCDATA constant, 846LIBXML_NOCDATA option, 173, 450LIBXML_NOEMPTYTAG constant, 846LIBXML_NOENT constant, 845LIBXML_NOENT option, 173, 450LIBXML_NOERROR constant, 846LIBXML_NOERROR option, 173LIBXML_NONET constant, 846LIBXML_NONET option, 173LIBXML_NOWARNING constant, 846LIBXML_NOWARNING option, 173LIBXML_NOXMLDECL constant, 846LIBXML_NSCLEAN constant, 846LIBXML_NSCLEAN option, 173libxml_set_streams_context() function, 176, 846libxml_use_internal_errors() function, 178–179,

376, 846LIBXML_VERSION constant, 845LIBXML_XINCLUDE constant, 846LIBXML_XINCLUDE option, 173libxslt library, 163–164, 389license parameter, 648lifetime of objects, 221–223, 226limit option, 788line feed character

formatting XML documents, 23–24in canonical XML, 450, 455in SAX parser, 277, 278in user-derived types, 81–82

in XML documents, 16migrating to PHP 5, 301

line number, retrieving using SAX, 291–292line property, 178, 847linebreak option, 502link element

Atom, 545, 557channel element, RSS 1.0, 525channel element, RSS 2.0, 536entry element, Atom, 549feed element, Atom, 548image element, RSS 1.0, 527image element, RSS 2.0, 538item element, RSS 1.0, 528item element, RSS 2.0, 539textinput element, RSS 1.0, 528textInput element, RSS 2.0, 538

links between resources (XLink), 157–159list pattern, 110–111list type, 83literal values, 349–350load() method, 189–190, 428, 861load time of large documents, 429–430LOADDTD constant, 850loadHTML() method, 191, 861loadHTMLFile() method, 191, 861loading documents

HTML data, 190–191XML data, 189–190

loadXML() method, 189–190, 861local-name() function, 137local scope of declarations, 89–91, 93local_cert option, 711localName property, 321, 851, 858location, XPointer, 149location option, 711, 714–715location paths. See paths, XPathlocation set, XPointer, 149location type, 149login option, 711logo element, 548long type, 842lookupNamespace() method, 851lookupNamespaceURI() method, 858lookupPrefix() method, 858Lorie, Ray, 2lowercase characters, 17–18lowestprice parameter, 652lr parameter, 748

■MManufacturer parameter, 664markup, 16–17, 26–27markup declarations

attribute-list declarations, 59–66attribute types, 62–66element type declarations, 50–54entity declarations, 54–59notation declarations, 66–67wildcards, 49–50

markup language, 2markup tags, 3

■INDEX 901

Find it faster at http://superindex.apress.com/

Page 61: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

marshaling, 595. See also WDDX (Web DistributedData Exchange); XML-RPC

match attribute, 343, 371Math EXSLT module, 377Mathematical Markup Language (MathML), 5maxCommentLine option, 503maxExclusive element, 82MaximumPrice parameter, 664maxInclusive element, 82maxLength element, 81maxOccurs attribute, 74, 75, 78, 89–90MaxRating element, 653maxResults option, 788maxResults parameter, 748mbstring extension, 171–172mcrypt library, 446–448MD5 hash, 443media-type attribute, 382, 383, 386, 387member element, 600memberTypes attribute, 84memory usage

DOM extension, 410, 411, 412, 413large document processing, 426–427multiple document processing, 427–429parser comparisons, 410, 411SimpleXML, 410, 411, 412, 413streaming parsers, 411, 413tree-based parsers, 411, 413xml extension, 410, 412, 413XMLReader, 410, 413

Merchant element, 655, 656merchantid parameter, 652, 656MergeCart parameter, 668message attribute, 694message authentication, 460. See also digital

signaturesmessage definitions, WSDL, 681–685message element, 681message integrity

canonical XML. See canonical XMLencryption. See encryptionhashing serialized XML, 443–445signatures. See digital signatures

message property, 178, 847messages, debugging XSLT, 376metalanguages, 2method attribute, 381methodCall element, 603–604methodName element, 603methodResponse element, 606, 618methods. See also functions; names of specific

methodsdomxml/DOM extension migration, 228–230as event handlers, 297–300extending DOM classes, 221

mhash extension, 444migrating to PHP 5, 300–306MIME types, 66–67MimeType element, 650minExclusive element, 82MinimumPrice parameter, 664minInclusive element, 82minLength element, 81

minOccurs attribute, 74, 75, 78, 89–90minus-sign attribute, 373Misc* section, 20mixed attribute, 86, 87mixed content model, 52–54mixed element content

RELAX NG schemas, 107–108, 111–112XML schemas, 85–86

mixed pattern, 106mod operator, 132mode attribute, 344, 347ModificationDate element, 650modifying resources, 636, 637. See also REST

(Representational State Transfer)modules, RSS

Content module, 532–534Dublin Core module, 530–531Syndication module, 531–532

Mosher, Ed, 2moveToAttribute() method, 326, 327, 331, 851moveToAttributeNo() method, 326, 327, 851moveToAttributeNs() method, 326, 331, 851moveToElement() method, 327, 852moveToFirstAttribute() method, 327moveToFirstElement() method, 852moveToNextAttribute() method, 327moveToNextElement() method, 852multilineTags option, 503, 504multiple documents, processing, 427–429multiple formats, publishing to, 6mustUnderstand attribute, 700–701, 708MustUnderstand fault code, SOAP, 702mustUnderstand parameter, 869

■Nname attribute

businessService structure, 758RELAX NG schemas, 105, 113template element, 343XML schemas, 73xsl:decimal-format element, 372xsl:element element, 350xsl:key element, 371xsl:variable, xsl:param elements, 366

name elementbusinessEntity structure, 755Person construct, 545textinput element, RSS 1.0, 528textInput element, RSS 2.0, 538tModel structure, 761XML-RPC, 600

name() function, 137name parameter, 708, 709, 869name property, 321, 851, 861, 864name tests, XPath expressions, 128–130Name type, 843name/value pairs, 24–25nameClass pattern, 104–105named attribute groups, 79named attribute sets, 352–353named element groups, 78–79named elements, 3named patterns, 117–119

■INDEX902

Page 62: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

NameNodeMap interface, 184, 186names. See also namespaces

attribute ID names, 37attribute names, 24–25, 104–105attribute uniqueness, 35–36characters allowed in, 16DOM extension node names, 194–195element name substitutions, 77–78element names, 21, 104–105, 351namespaces and, 35–36QNames, 31, 32, 35reserved names, 16scope of declarations and, 90, 93XPath node names, 124

namespace attribute, 99, 351namespace-aware parsers, 209, 296, 309namespace declaration handlers, 297namespace declarations

canonical XML, 450, 454DOM extension, 203SAX parser, 295, 297XML schemas, 76

namespace nodescanonical XML, 454–455XPath, 124, 126–127

namespace parameter, 708, 869namespace-uri() function, 137namespace URIs, 330–331namespace XPath axis, 128namespaced schemas, 94–100namespaces, 29–30

attribute uniqueness, 35–36combining multiple schemas, 91–93, 94–97,

98–100declarations. See namespace declarationsdefault. See default namespacesdefining, 31element nodes, within namespaces, 205, 206elements in specific namespaces, 201elements in transformed trees, 351in DOM extension, 218–219, 227, 418–419in DOM parser example, 308in exclusive XML canonicalization, 457–459in RELAX NG schemas, 101, 115–117in SimpleXML extension, 258–260, 261, 419,

879–883in xml extension, 417–418in XMLReader, 312–313, 328–333, 418in XMLWriter, 818–819in XPath expressions, 129, 130, 141–143in XPath node names, 124in XPointer expressions, 148in XSL templates, 237named patterns and, 118–119namespace collisions, 31namespace declaration handlers, 297namespace support, parser comparisons, 410,

417–419namespaced schemas, 94–100naming, 33PHP function calls and, 397qualified local declarations, 95–97qualified names, 116–117

registering, 218–219, 227, 261reserved prefixes, 33SAX parser and, 294–297scope of, 33–35sorting for canonical XML, 451–453specifying in schemas, 72tips for using, 35unqualified local declarations, 94–95unqualified names, 115–116user-defined functions, EXSLT, 378–380W3C XML Schemas namespace, 72xsd prefix, 72

namespaceURI property, 321, 330–331, 851, 858NaN attribute, 373National Weather Service, 793native XML databases (NXDs), 8–9NCName type, 843NCName:* XPath name test, 130NDATA keyword, 57negativeInteger type, 842nesting

conditional sections in DTDs, 70elements, 23–24

next() method, 320, 323–325, 329, 431, 852nextSibling property, 198, 857nillable attribute, 77NMTOKEN, NMTOKENS types, 64–65, 843.

See also CDATA typeNode interface, 182, 186node objects and interfaces

CharacterData interface, 184, 186DOMException interface, 184, 186DOMImplementation interface, 185, 186,

203–204NameNodeMap interface, 184, 186, 225Node interface, 182, 186Node objects in DOM tree, 183NodeList interface, 184, 186

node ordercanonical XML, 450, 451–453XSLT, 360–362, 406–407

node sets (XPath)axes, 127–128filtering, 133–134location paths, 127name tests, 128–130node set functions, 136–137node type tests, 130predicates, 130

node sets (XSLT)conditional processing, 358–360containing current node only, 374external documents, accessing, 370repetitive processing, 358sorting, 360–362, 406–407

node tests, XPath expressions, 128–130, 131–132node type constants, 317–319, 850node type tests, 130node types, DOM, 181–182, 194. See also DOM

(Document Object Model)NodeList interface, 184, 186node_name parameter, 707, 869nodeName property, 194–195, 857

■INDEX 903

Find it faster at http://superindex.apress.com/

Page 63: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

node_namespace parameter, 707, 869nodes, UDDI registries, 752nodes (DOM)

attribute nodes, 207–209attributes, 201–203CDATA section nodes, 211child nodes, 196–197comments, 211document fragments, 211document node, 199, 203–204DOM node types, 181–182, 194element nodes, 204–207elements

accessing by ID, 226–227accessing by name, 199–201accessing using XPath, 217–218

entity reference nodes, 211in DOM tree, 182–183iterating collections, 196–197, 225Node interface, 182node name, 194–195node objects, 183node type, 194node value, 195objects, DOM, vs. nodes, 221–223parent nodes, 198–199processing instruction nodes, 211properties, 194–196removing from tree, 212–213, 225replacing, 213retrieving using XPath, 217sibling nodes, 198text nodes, 209–210

nodes (in transformed trees)attribute value templates, 349–350attributes, 351–352comment nodes, 354copying nodes, 354–355current node, retrieving, 374elements, 350–351named attribute sets, 352–353node sets

conditional processing, 358–360repetitive processing, 358sorting, 360–362

processing instruction nodes, 353–354text nodes, 353, 356

nodes (XPath)axes, 127–128calculations in expressions, 146complex XPath expressions, 141–146context nodes, 127, 134equivalent XPointer expressions, 147filtering node sets, 133–134location paths, 127–132node tests, 128–130node type tests, 130node types, 125–127optimizing XPath expressions, 138–139predicates, 130value comparisons, 135–136, 144–145XPath data model, 124–125

XPath functions, 136–138, 144–145, 146XPath operators, 130

nodes (XSL, XSLT)matching in templates, 343selecting for processing, 346–347

nodeType property, 194, 321, 851, 857nodeValue property, 195, 857non-normative exclusive XML canonicalization

implementation, 459–460NONE constant, 317, 318, 850nonNegativeInteger type, 842nonPositiveInteger type, 842normalize() method, DOMNode class, 858normalize-space() function, 137normalizeComments option, 503, 504normalizeDocument() method, 861normalizedString type, 842not() function, 138NOTATION constant, 317, 318, 850Notation interface, 187NOTATION type, 64, 67, 841notationHandler() method, 494notationName property, 865notations, 57, 64, 66–67, 281–283notations property, 865notes (annotation elements), 88. See also

commentsnotification operation, WSDL, 698–699ns attribute, 115–116null element, 571null type, 569NULL value, 77number element, 571number() function, 137, 138number type, 569numeric values

formatted numbers, XSLT, 362–366, 372numeric comparisons, XPath, 136in user-defined types, 82

NumRatings element, 653NXDs (native XML databases), 8–9

■OOASIS (Organization for the Advancement of

Structured Information Standards), 14Object element, 465object handlers, XML_Parser, 496–497object lifetime, 221–223, 226object methods as event handlers, 297–300object-oriented interface, xml extension, 493–498object type definitions, WSDL, 679–680objects, DOM

constructors, 220creating and instantiating, 187–188extending core classes, 219–220, 226, 228,

885–887in PHP sessions, 224–225methods, 221nodes vs. objects, 221–223objects, classes, and interfaces, 183, 184,

186–187, 885–887properties, 220–221

■INDEX904

Page 64: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

scope and object lifetime, 221–223, 226serialization, 224–225

objects, serializing, 224–225. See alsoXML_Serializer package

oe parameter, 748Offer element, 655, 656omit-xml-declaration attribute, 382one-way operation, WSDL, 685–686oneOrMore pattern, 109–110online bookmarks, 785–786open() method, 315, 852open source libraries. See PEARopen_basedir option, 175–176openMemory() method, 813–814, 872openUri() method, 813–814, 872operation element, 686, 689, 691, 693Operation parameter, 664, 665, 670operator attribute, 755, 761operators, XPath, 130optimization

memory usage, 426–429parser comparisons. See parser comparisonsperformance, 429–433

optional elements, 53–54optional pattern, 106–107or operator, XPath, 132orAllKeys option, 766order

elements in element type declarations, 51–52entity declarations, 55–56entity references, 58–59node order

canonical XML, 450, 451–453XSLT, 360–362, 406–407

schema elements, 74, 75order attribute, 362origin() function, 151orLikeKeys option, 766outbound() method, 790output element, 686, 689, 693outputBusiness() function, 770outputMemory() method, 872outputTemplate() function, 771outputting XSLT result trees, 381–387overviewDoc element, 762ownerDocument property, 199, 857ownerElement property, 861

■Ppackages, PEAR. See PEARpackets, WDDX

serializing data, 577–579, 579–581, 583–584,590–591

unserializing data, 581–583, 584–585, 591–592WDDX document structure, 570Web service client (example), 587–589Web service server (example), 586–587XML_WDDX package, 589–592

PAD (Portable Application Description), 230–234,262–268

param element, 112, 603, 604parameter entities, 57–59, 69. See also general

entities

parameterOrder attribute, 686parameters, XSLT

defining, 366–367in style sheets, 393–395passing to templates, 368–369referencing, 367scope of, in templates, 367–368for user-defined functions, 379

params element, 603parent axis, XPath, 128parent nodes, 125, 198–199parentNode property, 198–199, 857parse() method, 513, 564parsed character data. See PCDATA contentparsed entities, 55–57parsed entity references, 450parser attribute, 153parser comparisons

choosing parsers, 423–426document editing, 415–416document navigation, 413–415ease of use, 416–417namespace support, 417–419processing speed, 420–423streaming parsers, 410, 423–424system resource usage, 410, 411–413tree-based parsers, 409–410, 423–424

parser modes, XML_Parser, 495parser options, 173–174, 450–451parsers and parsing, 14

Atom parser using XMLReader (example),561–563

bypassing using CDATA sections, 26–27DOM extension, 165DOM parser using SAX (example), 306–310epilogs and, 20memory usage, 426–429parsing DTDs, 512, 515parsing HTML documents, 504–506performance, 429–433pull parsers, 165, 312push parsers, 165, 270, 312RSS 2.0 parser using SimpleXML (example),

560–561SimpleXML extension, 164using SAX. See parsing using SAXusing XMLReader. See parsing using

XMLReaderxml extension, 165, 270–272XML_DTD package, 512, 515XMLReader extension, 165

parsing speedloading, unloading time, 429–430locating specific elements, 430–433optimizing, 429–433parser comparisons, 410, 420–423

parsing using SAXbyte index, 291–292, 304chunking data, 286–287, 304column number, 291–292, 303–304data from files, 287encoding conversions, 293–294error handling, 292–293

■INDEX 905

Find it faster at http://superindex.apress.com/

Page 65: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

line number, 291–292parser information, 291–292parsing into array structures, 288–291releasing parser, 294xml_parse() function, 285

parsing using XMLReaderaccessing attributes, 325–327, 331–332, 339accessing node information, 320–323accessing nodes, 319–320, 330–331, 338–339accessing sibling nodes, 323–325namespaces and, 328–333retrieving attribute values, 326validation using DTDs, 333validation using RELAX NG, 334–335

parts attribute, 693passphrase option, 711password option, 711paths, XPath

abbreviated syntax, 131–132calculations in expressions, 146complex XPath expressions, 141–146equivalent XPointer expressions, 147filtering node sets, 133–134location paths, 127–132namespaces and, 141–143node tests, 128–130optimizing XPath expressions, 138–139predicates, 130value comparisons, 135–136, 144–145XPath functions, 136–138, 144–145, 146XPath operators, 130

pattern element, 81pattern-separator attribute, 373patterns, RELAX NG, 100–102. See also schemas,

RELAX NGattribute declarations, 101–102attribute pattern, 112, 113–114choice pattern, 106, 114data pattern, 114element declarations, 101–103empty pattern, 106external patterns, 119–121group pattern, 106interleave pattern, 108–109list pattern, 110–111mixed pattern, 106named patterns, 117–119oneOrMore pattern, 109–110optional pattern, 106–107value pattern, 112–113, 113, 114zeroOrMore pattern, 109–110

PCDATA content, 52–54PEAR

installing, 492–493purposes and guidelines, 491–492Services_Amazon package, 781–785Services_Delicious package, 785–786Services_Ebay package, 786Services_Google package, 786–789Services_Technorati package, 789–793Services_Weather package, 793–797Services_Webservice package, 797–802Services_Yahoo package, 802–806

SOAP package, 734–735, 806UDDI package, 806–808Web services packages, 781XML_Beautifier package, 502–504XML_DTD package, 512–516XML_FastCreate package, 516–519XML_HTMLSax package, 504–506XML_Parser package, 493–498XML_RPC package, 622–628, 808XML_RSS package, 512, 563–566XML_Serializer package, 506–512XML_Tree package, 498–501XML_Util package, 501–502XML_WDDX package, 589–592

PEAR Package Manager, 492–493PECL, 812–813per-mille attribute, 373percent attribute, 373performance. See also parser comparisons

large documents, processing, 426–427, 429–430loading, unloading time, 429–430locating specific elements, 430–433multiple documents, processing, 427–429

persistence of SOAP classes, 728Person construct, 545personName element, 756phone element, 756PHP 4, 163, 167, 300–306PHP 5

digital signature support, 448DOM extension. See DOM extensiondomxml/DOM extension migration, 228–230encryption support, 448file security, 175–176I/O handling, 175libxml2-derived errors, 177–179PHP 4 migration, 300–306protocols supported, 174–175Safe Mode support, 175–176SOA and, 9–10stream contexts, 176–177streams, 174–177WAP detection, 837–838XML extensions, 163, 164–167

PHP functionsin SOAP servers, 725–728in style sheets, 396–399, 401, 402

php.ini options, 175–176PI constant, 317, 318, 850PI nodes

canonical XML, 455–456creating using XSLT, 353–354XPath, 124, 127

piHandler() method, 494PIs (processing instructions), 28, 88, 279point node type, 149port element, 695–696port type element, 685port types, WSDL, 685–690Portable Application Description (PAD), 230–234,

262–268position() function, 136positiveInteger type, 842

■INDEX906

Page 66: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

POST, HTTPin REST architecture, 636, 637XML-RPC request headers, 601–602

preceeding axis, XPath, 128preceeding-sibling axis, XPath, 128predicates, XPath, 130

calculations in expressions, 146complex XPath expressions, 141–146equivalent XPointer expressions, 147filtering node sets, 133–134namespaces and, 141–143optimizing XPath expressions, 138–139value comparisons, 135–136, 144–145XPath functions, 136–138, 144–145, 146XPath operators, 130

prefix property, 321, 330–331, 851, 858prefixes

attribute uniqueness, 35–36in exclusive XML canonicalization, 457–459in RELAX NG schemas, 101in XMLReader, 330–331in XPath expressions, 142namespace prefixes, 31, 33, 34, 218–219, 227qualified names, RELAX NG schemas, 117reserved prefixes, 33user-defined functions, EXSLT, 378–380WSDL prefix/namespace mappings, 674

preserveWhiteSpace property, 859previousSibling property, 198, 857Price element, 655PriceFrom element, 652PriceTo element, 652primitive types, 73, 839–841priority attribute, 343–344procedural interface, XMLWriter, 819–820procedure calls, 595. See also XML-RPCprocessContents attribute, 84processing instruction nodes

canonical XML, 455–456creating using XSLT, 353–354

processing instructions (PIs), 28annotation elements, 88SAX event handlers, 279

processing speedoptimizing, 429–433parser comparisons, 410, 420–423

ProcessingInstruction interface, 187Product Search service, Yahoo, 651–659ProductName element, 652, 655prolog, 18–20properties

domxml/DOM extension migration, 229extending DOM classes, 220–221system properties, 375–376

proxy servers, 176–177proxy_host option, 711proxy_login option, 711proxy_password option, 711pubDate element, 541public identifiers, 46–47public keys, 465PUBLIC keyword, 47

publicId propertyDOMDocumentType class, 864DOMEntity class, 865DOMNotation class, 865

published element, 550Publisher API, UDDI, 767–768, 773–780Publisher parameter, 664publisherAssertion structure, 763–764publishing

Web services. See UDDI (Universal Description,Discovery, and Integration)

XML applications, 6–7pull parsers, 165, 312PurchaseURL element, 670, 672push parsers, 165, 270, 312PUT (HTTP), 636, 637

■Qq parameter, 748QName type, 841QNames (qualified names). See also namespaces

namespaces and, 31, 32, 35XPath expressions, 128–130

qualified names, RELAX NG schemas, 116–117quantified expressions, 161queries, XPath. See expressions, XPathquery() method, 216, 217, 856query parameter, 648, 652

■Rrange() function, 150range-inside() function, 150range node type, 149range-to() function, 149–150RatingUrl element, 653rawurlencode() function, 665RDF element, 524RDF Site Summary, 522. See also RSS 1.0 (RDF Site

Summary)read() method, 319–320, 333, 334, 852readInnerXml() method, 852, 878readOuterXml() method, 852, 878readString() method, 852, 878Really Simple Syndication. See RSS 2.0 (Really

Simple Syndication)recordset element, 574–576recordset type, 569recover property, 859ref attribute, 79, 93Reference element, 464, 466, 467references

character references, 15–16digital signatures, 467–469, 472–473element group references, 79entity references, 28–29for restricted characters, 17

registering DOM classes, 885–887registerNamespace() method, 218–219, 856registerNodeClass() method, 861, 885–887registerPHPFunctions() method, 390, 396, 867registerXPathNamespace() method, 261, 853registries. See UDDI registries

■INDEX 907

Find it faster at http://superindex.apress.com/

Page 67: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

rel attribute, 546relative paths, XPath, 127relative URIs, 42–43RELAX NG schemas. See schemas, RELAX NGrelaxNGValidate() method, 216, 861relaxNGValidateSource() method, 216, 861remote content, including. See XIncluderemote document access, 176–177Remote Method Invocation (RMI), 10remote procedure calls, 595. See also XML-RPC

complex type document literal calls, 717–718eBay Web services, 743–744simple type RPC-encoded calls, 715–717SoapClient class, 715–718xmlrpc extension, 166

remote shopping cart. See shopping cart, AmazonremoveAttribute() method, 862removeAttributeNode() method, 862removeAttributeNS() method, 862removeChild() method, 212–213, 858removeLineBreaks option, 503removeParameter() method, 390, 393, 395, 867removing nodes from trees, 212–213, 225repetitive processing, XSLT, 358replaceChild() method, 213, 858replaceData() method, 863replacing text in documents. See entitiesRepresentational State Transfer. See REST

(Representational State Transfer)representations of resources. See REST

(Representational State Transfer)request-response operation, WSDL, 686–698requests, XML-RPC. See also XML-RPC

request format, 603–605request header, 601–602XML-RPC client (example), 612–613, 614–616XML-RPC server (example), 617–618, 619–620XML_RPC_Message class, 624–625

#REQUIRED attribute default, 60#REQUIRED value, 36–38reserved names, 16resetOptions() method, 503, 510resolveExternals property, 859Resource Description Framework (RDF), 522resource identifiers, 633resources, 633

links between (XLink), 157–159representations of. See REST (Representational

State Transfer)ResponseGroup parameter, 664responses, XML-RPC. See also XML-RPC

error handling, 607, 614, 618response format, 606–607response header, 605XML-RPC client (example), 613, 614XML-RPC server (example), 618, 620XML_RPC_Response class, 626

REST (Representational State Transfer), 12, 14, 633adding integers (example), 639–640Amazon item search query (example), 664–666Amazon remote shopping cart query (example),

667–672Amazon Web services and, 660–661

client (example), 643–645HTTP methods, 636–637server (example), 641–643URIs and, 638–639Web services, 11–12, 634XML representation of resources, 634–636Yahoo Product Search query (example), 653–659Yahoo Web Search query (example), 648–651Yahoo Web services and, 12, 646

restricted characters, 17restriction element, 80restricts option, 788restricts parameter, 748Result element, 647, 652result trees, XSLT

attributes, 351–352comment nodes, 354copying nodes, 354–355elements, 350–351formatted numbers, 362–366, 372–373HTML documents, generating, 356–357named attribute sets, 352–353node sets, 358–360, 360–362, 406–407outputting, 381–387processing instruction nodes, 353–354retrieving current node, 374saving to URIs, 378text nodes, 353, 356

results parameter, 648, 652ResultSet element, 646–647, 652retrieving resources, 636–637. See also REST

(Representational State Transfer)reusing content. See XIncludeRich Site Summary, 522. See also RSS 2.0 (Really

Simple Syndication)rights element, 548, 550RNG files, 101. See also schemas, RELAX NGroot element

RELAX NG schemas, 101scope of declarations, 89–91XML documents, 18, 20

root node, 124, 125, 453round() function, 138rowCount attribute, 574–575RPC/encoded message format, WSDL, 682RPC/literal message format, WSDL, 682–683RSS 1.0 (RDF Site Summary)

channels, 524–526, 531, 532content blocks, 527–528, 532–534Content module, 532–534document structure, 524Dublin Core module, 530–531forms, 528–529history of RSS, 521–522images, 526–527sample document, 523–524selecting feed technologies, 550–551Syndication module, 531–532using DOM (example), 551–557using XML_RSS (example), 563–566

RSS 2.0 (Really Simple Syndication)channels, 536–537content blocks, 539–541

■INDEX908

Page 68: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

document structure, 535–536forms, 538–539history of RSS, 521–522images, 538modules. See modules, RSSparser, SimpleXML (example), 560–561sample document, 535selecting feed technologies, 550–551using DOM (example), 551–555, 556–557using XML_RSS (example), 563–566

RSS1 class, 555–556RSS2 class, 556–557RSS documents, 391–392rss element, 535RSS technologies

Atom. See Atomhistory of, 521–522RSS 1.0. See RSS 1.0 (RDF Site Summary)RSS 2.0. See RSS 2.0 (Really Simple Syndication)

Ruby, Sam, 522

■SSafe Mode support, PHP 5, 175–176safe_mode_gid setting, PHP, 175–176safeSearch option, 788safeSearch parameter, 748SAP UDDI registry, 765, 767, 769–772, 773–780. See

also UDDI (Universal Description,Discovery, and Integration)

save() method, 191, 861save_binding() function, 768save_business() function, 768, 774saveDocumentToFile() method, 825saveHTML() method, 192, 861saveHTMLFile() method, 192, 861save_publisherAssertions() function, 768save_service() function, 768, 776save_tModel() function, 768, 778saveXML() method, 191, 483, 861SAX (Simple API for XML), 14, 165, 269–270

DOM parser (example), 306–310event handlers, 274–285, 297–300, 302–303,

305–306namespaces and, 294–297parser, creating, 272parser options, 273–274parsing documents

byte index, 291–292, 304chunking data, 286–287, 304column number, 291–292, 303–304data from files, 287encoding conversions, 293–294error handling, 292–293line number, 291–292parser information, 291–292parsing into array structures, 288–291releasing parser, 294xml_parse() function, 285

target encoding, 300using xml extension, 270–272

scalar property, 611scalarval() method, 623schema element, 72

schemaLocation attribute, 93, 99schemas, RELAX NG, 100–104. See also DTDs

(Document Type Definitions); schemas,XML

attributes, 113–114data types, 102, 114defines, 117–119elements. See elements (RELAX NG)external patterns, 119–121mixed element content, 107–108, 111–112namespaces and, 101, 115–117patterns. See patternsroot element, 101specifications and tutorial, 121validation, 216

schemas, XML, 71. See also DTDs (Document TypeDefinitions); schemas, RELAX NG

annotation elements, 88attributes. See attributes (XML schemas)complex element content, 86–87complex types, 73–76, 84–85data types, 72–76DTDs vs., 71, 90element name substitutions, 77–78elements. See elements (XML schemas)empty elements, 85mixed element content, 85–86multiple, combining, 91–93, 94–97namespace declarations, 76namespaced schemas, 94–100schema element, 72scope of declarations, 89–91, 93SDO Data Access Services, 821–823simple types, 72–73, 83–84specifying namespaces, 72structure, 76type definitions, 839validation, 45–46, 215–216

schemaValidate() method, 215–216schemaValidateSource() method, 215–216, 861scheme attribute, 546scope

extending DOM classes, 221–223, 226, 885–887global declarations, 95names in RELAX NG schemas, 117namespaces, 33–35parameters, 367–368qualified local declarations, 95–97root element declaration, 95schema declarations, 89–91, 93unqualified local declarations, 94–95variables, 367–368

screen scraping, 12SDO Data Access Service, 820–826SDO_XML_DAS, 825–826search() method, 788, 790search services, Google

doGetCachedPage() function, 746–747doGoogleSearch() function, 746, 747–748doSpellingSuggestion() function, 746–747GoogleSearchResult structure, 745, 748–750registration and setup, 744Services_Google package, 788–789

■INDEX 909

Find it faster at http://superindex.apress.com/

Page 69: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

SearchIndex parameter, 664, 665searching

Amazon item searches, 663–666using Google. See search services, Googleusing Technorati, 789–793Yahoo Product Search service, 651–659Yahoo Web Search service, 648–651

searchLocation() method, 794secret keys, HMAC hash, 444security

canonical XML. See canonical XMLencryption. See encryptionfile security support, PHP 5, 175–176general considerations, 441–442message integrity, 442–445PHP function calls, restricting, 396signatures. See digital signatures

select attributexsl:apply-templates element, 346–347xsl:for-each element, 358xsl:variable, xsl:param elements, 366

self axis, XPath, 128send() method, 625Seq element, 525, 555sequence element, 74, 75, 78–79sequence lists, 51sequences, XPath 2.0, 159–160serialize() method

PHP, 224XML_RPC_Response class, 626XML_Serialize class, 509XML_WDDX package, 590

serialized datacanonical XML, 450–451encrypting and decrypting, 446–448, 483hashing, 443–445node order for canonical XML, 451–453

serializing dataarrays. See XML_Serializer packageDOM objects, 224–225objects. See XML_Serializer packageWDDX data

complex data, 579–581, 583–584, 590–591simple data, 577–579, 583–584, 590–591unserializing data, 581–583, 584–585,

591–592XML_WDDX package, 590–591

Server fault code, SOAP, 702servers

REST Web service (example), 641–643SOAP servers. See SOAP serversvalidating server-based data, 826–830WDDX Web service server (example), 586–587XML-RPC server (example), 617–622, 626–628

Service Data Objects (SDO), 820–826service element, 695–696Service parameter, 665serviceKey attribute, 758, 759services() method, 794Services_Amazon package, 781–785Services_AmazonECS4 class, 782Services_Delicious package, 785–786Services_Ebay package, 786

Services_Google package, 786–789Services_Technorati class, 789–790Services_Technorati package, 789–793serviceSubset option, 767Services_Weather package, 793–797Services_Webservice class, 798Services_Webservice package, 797–802Services_Yahoo package, 802–806Services_Yahoo_ContentAnalysis class, 805–806Services_Yahoo_Search class, 802–805setAdultOK() method, 803setAppID() method, 803, 806setAttribute() method, 208–209, 862setAttributeNode() method, 208, 862setAttributeNodeNS() method, 208, 862setAttributeNS() method, 203, 208–209, 863setClass() method, 728, 871setContext() method, 806_setCookie() method, 871setFormat() method, 803setIdAttribute() method, 227, 863, 883setIdAttributeNode() method, 863, 883setIdAttributeNS() method, 863, 883setIndent() method, 816, 872setIndentString() method, 816setInput() method, 495setInputFile() method, 495setInputString() method, 495setLocale() method, 782_setLocation() method, 714–715, 871setOption(), setOptions() methods, 503, 509, 510setParameter() method, 390, 393–394, 862setParserProperty() method, 316–317, 852setPersistence() method, 728, 871setQuery() method, 804, 806setRelaxNGSchema() method, 334, 335, 852setRelaxNGSchemaSource() method, 334setResultNumber() method, 804_setSoapHeaders() method, 718–719, 871setStart() method, 804setType() method, 804SGML (Standardized Generalized Markup

Language), 2–3SHA1 hash, 443shallow copies of nodes, 354–355shared external subsets, 68–70shopping cart, Amazon, 666–672, 784–785short type, 842show attribute, 158–159sibling nodes, DOM extension, 198Signature element, 463signature key, 626, 627SignatureMethod element, 464, 470, 473signatures. See digital signaturesSignatureValue element, 463, 466, 470SignedInfo element, 463, 470, 473signer authentication, 460. See also digital

signaturesSIGNIFICANT_WHITESPACE constant, 318, 850similar_ok parameter, 648SimpleXML, 164, 239, 852–854, 879–883

attributes, 255–256, 256–257child elements, 252–253

■INDEX910

Page 70: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

choosing parsers, 424–425, 426document editing, 415, 416document navigation, 414–415DOM interoperability, 250, 253, 255, 434–436ease of use, 410, 416–417element content, 243–244, 251–252element names, 247–250element nodes, 242–243, 245–250importing nodes from DOM extension, 434–435large document processing, 410, 411, 412, 413locating specific elements, 432, 433memory usage, 426–427namespace support, 410, 419, 879–883namespaces, registering, 261optimizing, 426–427, 432, 433PAD template (example), 262–268performance, 432, 433removing elements from tree, 253–255replacing subtrees, 253RSS 2.0 parser (example), 560–561saving XML content, 241SimpleXMLElement class, 240–241, 257–258system resource usage, 410, 411, 412, 413XPath support, 260–261Yahoo Web Search query (example), 650–651

SimpleXML extension, 258–260, 879–883simplexml mode, 506SimpleXMLElement class, 239–258, 257–258simplexml_import_dom() function, 434–435, 853simplexml_load_file() function, 239–241, 853simplexml_load_string() function, 239–241, 853simplified inline style sheets, 343site parameter, 648sleep() method, 224–225SOA (Service Oriented Architecture), 10SOAP, 11–12, 14, 867–871

clients. See SOAP clientseBay and. See eBay Web servicesencoded variables, 706–708encoding style, 698Envelope element, 698–699error handling, 700, 701–704faults, 701–704, 709–710, 729–730, 870Google and. See Google Web servicesheader entries, 699–701, 708, 718–719low-level function calls, 719–720messages, 697, 701, 720–722named parameters, 709PHP functions, 725–728request messages, 697, 704response messages, 697, 705servers. See SOAP serversServices_Webservice package, 797–802UDDI APIs, 765–768XML-RPC and, 10

SOAP_... options constants, 867SOAP clients

creating, 710–712debugging client calls, 722–723eBay Web services implementation, 737–740header entries, 718–719low-level function calls, 719–720messages, modifying, 720–722

remote function calls, 715–718service location, specifying, 714–715services, inspecting, 712–714SoapClient class. See SoapClient class

SOAP extension, 166, 867–871clients. See SOAP clientsenabling, 706servers. See SOAP serversSoapClient class, 710–723SoapFault class, 709–710, 729–730, 870SoapHeader class, 708SoapParam class, 709SoapServer class, 724–734SoapVar class, 706–708

SOAP faults, 701–704, 709–710, 729–730, 870SOAP header entries, 699–701, 708, 718–719,

730–732SOAP package, 734–735, 806SOAP servers

creating, 724–725eBay. See eBay Web serviceshandling client requests, 729registering function handlers, 725–728returning SOAP faults, 729–730SOAP headers, 730–732WSDL and, 723–724, 732–734

soapAction attribute, 692SOAP_ACTOR_NEXT constant, 731soap:address element, 695–696soap:binding element, 691_soapCall() method, 719–720, 744, 871SoapClient class, 870–871

_construct() method, 710–712_doRequest() method, 720–722, 870_getFunctions() method, 712_getLastRequest() method, 722_getLastRequestHeaders() method, 722_getLastResponse() method, 722_getLastResponseHeaders() method, 722_getTypes() method, 712options, 711remote function calls, 715–718_setLocation() method, 714–715_setSoapHeaders() method, 718–719_soapCall() method, 719–720, 871

SoapFault class, 709–710, 729–730, 870soap:fault element, 694SOAP_FUNCTIONS_ALL constant, 727SoapHeader class, 869soap:header element, 694soap:headerfault element, 694soap:operation element, 692SoapParam class, 709, 869SOAP_PERSISTENCE_REQUEST option, 728SOAP_PERSISTENCE_SESSION option, 728SoapServer class, 724–725, 728, 729, 871SoapVar class, 706–708, 868–869soap_version option, 711soap_version parameter, 724soap.wsdl_cache_dir option, 706soap.wsdl_cache_enabled option, 706soap.wsdl_cache_ttl option, 706solicit-response operation, WSDL, 698

■INDEX 911

Find it faster at http://superindex.apress.com/

Page 71: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

some quantifier, 161Sort parameter, 664sort parameter, 652sortByDateDesc option, 766sortByNameAsc option, 766sortByNameDesc option, 766sortCode attribute, 757sorting node sets

canonical XML, 450, 451–453XSLT, 360–362, 406–407

source element, 541, 550space attribute, 41–42space character, 16, 81–82space notation, 16special characters, 53, 450Specification element, 653SpecificationLabel element, 653SpecificationList element, 653SpecificationValue element, 653speed of parsing or processing, 410, 420–423,

429–433spell check, Google Web services, 787spelling suggestions, Yahoo Web services, 805–806spellingSuggestion() method, 787splitText() method, 864src attribute, 546stacking XPointer expressions, 147–148standalone attribute, 382standalone declaration, 19standalone property, 859standardized data descriptions, 5–6start element, 117–119, 120start option, 788start parameter

GoogleSearchResult structure, 748Yahoo Product Search request, 652Yahoo Web Search request, 648

start-point() function, 151start tags, 21, 23–24startAttribute() method, 872startAttributeNs() method, 872startCdata() method, 872startComment() method, 872startDocument() method, 814, 872startDtd() method, 873startDtdElement() method, 873startElement() method, 814, 872startElementNs() method, 872startHandler() method, 494startPi() method, 872starts-with() function, 137steps, XPath, 127stock trader (XML-RPC example), 615–616,

619–622stream contexts, 176–177stream_context option, 711streaming parsers

document editing capabilities, 410document navigation, 413, 415document navigation capabilities, 410ease of use, 410namespace support, 410parser comparisons, 410, 423–424

parsing and processing speed, 410, 420, 423SAX (Simple API for XML). See SAX (Simple API

for XML)system resource usage, 410, 411, 413tree-based parsers vs., 410xml extension, 165, 270–272XMLReader extension, 165

streams, PHP 5, 174–177strictErrorChecking property, 859string comparisons, XPath expressions, 135–136,

144–145string element, 572, 598string() function, 137string-length() function, 137string-range() function, 150string type

RELAX NG, 103, 111–112WDDX, 569XML schemas, 840

string values of XPath nodes, 124struct element, 573–574, 577, 600struct type, 569style attribute, 691, 692style option, 711style sheets, 342

DOM extension (example), 399–400importing to XSLT processor, 390–391simplified inline style sheets, 343templates. See templates, XSLvariables and parameters, 366–369, 393–395WAP Cascading Style Sheets (WCSS), 835XSL. See XSL (Extensible Stylesheet Language)XSLT. See XSLT (Extensible Stylesheet Language

Transformations)subclasses, DOM extension, 219–223submit() method, 804, 806subscription parameter, 648SUBST_ENTITIES constant, 850substituteEntities property, 860substitutionGroup attribute, 77–78substitutions, element names, 77–78substring-after() function, 137substring-before() function, 137substring() function, 137substringData() method, 863subtitle element, 548subtrees

accessing, 197bypassing in XMLReader, 323–325copying, 436–438modifying, 252replacing, 253

sum() function, 138Summary element

Catalog element, Yahoo, 652Offer element, Yahoo, 655Result element, Yahoo Web Search, 650

summary element, 549super encryption, 476–477syndication, 6

Atom. See Atomfeeds using DOM, 551–560history of, 521–522

■INDEX912

Page 72: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

parser, SimpleXML (example), 560–561RSS 1.0. See RSS 1.0 (RDF Site Summary)RSS 2.0. See RSS 2.0 (Really Simple Syndication)selecting technologies, 550–551

Syndication module, 531–532Syndicator class, 552–555system identifiers, 46–47SYSTEM keyword, 46–47system-property() function, 375–376system resource usage, parser comparisons, 410,

411–413systemId property

DOMDocumentType class, 864DOMEntity class, 865DOMNotation class, 865

system.listMethods() method, 608system.methodHelp() method, 608system.methodSignature() method, 608

■Ttab character, 16, 23–24, 81–82, 455tag key, array structures, 289tagName property, 862tags, 2, 3, 17–18, 21–22target property, 866targetNamespace attribute, 94–95, 99Technorati Web service, 789–793templates, XSL, 343, 344–345

applying, 345–347attribute value templates, 349–350built-in templates, 347–348calling, 348–349conflicts, resolving, 343–344elements, matching, 343elements, specifying for processing, 346–347mode, specifying, 347names of templates, 343, 348–349priority, specifying, 343–344variables and parameters, 366–369Yahoo Product Search query (example), 657

templates (examples)PAD template, 230–234, 262–268XSL template, 235–237

term attribute, 546term extraction, Yahoo Web services, 805–806terminate attribute, 376test attribute, 360testing parsers. See parser comparisonstext and text content. See also text nodes

character data handlers, SAX, 276–277in element type declarations, 53–54replacing. See entitiessimple types, 72–73, 83–84text-only content, 53–54

TEXT constant, 317, 318, 850Text construct, 544text declarations, 47Text interface, 187text() method, 872text nodes. See also text and text content

in canonical XML, 455in DOM extension, 209–211in XPath, 124, 126

in XSLT, 353, 356whitespace in DOM tree, 182, 213

text output, XSLT result trees, 387text pattern, 103, 111–112text value, Text construct, 544textContent property, 858textInput element, 537, 538–539textinput element, 526, 528–529, 530Thumbnail element, 652, 655time type, 840timestamp property, 611title attribute, 546Title element, 650title element

channel element, RSS 1.0, 525channel element, RSS 2.0, 536entry element, Atom, 549feed element, Atom, 547image element, RSS 1.0, 527image element, RSS 2.0, 538item element, RSS 1.0, 528item element, RSS 2.0, 539textinput element, RSS 1.0, 528textInput element, RSS 2.0, 538

tModel structure, 761–763, 778tModelInstanceDetails element, 760, 763tModelKey attribute, 757, 761token type, 842toKey element, 764topTags() method, 790totalDigits element, 82totalResultsAvailable attribute, 647totalResultsReturned attribute, 647toXML() method, 519trace option, 711, 722transformations, XSL

attribute value templates, 349–350attributes, 351–352CDATA sections and, 173–174comment nodes, 354copying nodes, 354–355current node, retrieving, 374elements, 350–351formatted numbers, 362–366, 372–373HTML documents, 356–357named attribute sets, 352–353node sets

processing, 358–360sorting, 360–362, 406–407

processing instruction nodes, 353–354RSS feed aggregation (example), 400–407style sheet, DOM extension (example), 399–400templates. See templates, XSLtext nodes, 353, 356XSL extension, 166XSLT processor. See XSLT processorYahoo Product Search query (example), 657

transformToDoc() method, 390, 391, 392–393, 867transformToURI() method, 390, 391, 392, 867transformToXML() method, 390, 391–392, 867translate() function, 137transport attribute, 691

■INDEX 913

Find it faster at http://superindex.apress.com/

Page 73: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

tree, DOMattribute nodes, 207–209, 208–209attributes, 201–203CDATA section nodes, 211child nodes, 196–197comments, 211creating and instantiating documents, 188–189document element, 193–194document fragments, 211document node, 199, 203–204element nodes, 204–206, 206–207elements, accessing by name, 199–201entity reference nodes, 211loading HTML data, 190–191loading XML data, 189–190, 193namespace declarations, 203navigating between nodes, 196–201node information, 194–196parent nodes, 198–199processing instruction nodes, 211removing nodes, 212–213, 225replacing nodes, 213saving HTML data, 192saving XML data, 191sibling nodes, 198subtrees, 197text nodes, 209–210

tree-based parsersdocument editing capability, 410document navigation, 410, 413, 415DOM extension, 165ease of use, 410namespace support, 410parser comparisons, 409–410, 423–424parsing and processing speed, 410, 420, 423SimpleXML extension, 164streaming parsers vs., 409–410system resource usage, 410, 411, 413

tree (document tree), 20, 182–183troubleshooting

corrupted XML documents, 389default namespaces, element access, 227DTDs, adding manually, 227elements, retrieving by ID, 226entity errors, 227keys in style sheets, libxslt and, 389node access, extended classes and, 226nodes, removing from documents, 225serializing DOM objects, 224–225

true() function, 138type attribute

content element, Atom, 546link element, Atom, 546Text construct, 544XLink, 158XML schemas, 73, 74, 102

type definitions, 839type key, array structures, 289type parameter, 648type_name parameter, 707, 869type_namespace parameter, 707, 869types. See data typestypes element, 678

■UUDDI package, 806–808UDDI registries, 752

adding and updating information, 767–768,773–780

deleting information, 780querying, 765–767, 769–772, 807–808SAP test registry, 765, 767, 768–780

UDDI (Universal Description, Discovery, andIntegration), 11–12, 751–752

address structure, 756–757bindings for services, 777–778bindingTemplate structure, 758–760businessEntity structure, 754–757businessService structure, 757–758contact structure, 756data structures hierarchy, 753–754deleting registry information, 780Inquiry API, 765–767Publisher API, 767–768publisherAssertion structure, 763–764registries. See UDDI registriesservices, creating, 776–777specifications, 753tModel structure, 761–763usage of, 752

Unicode character set, 15union data types, 83union element, 84Universal Business Registry (UBR), 751. See also

UDDI (Universal Description, Discovery,and Integration)

Universal Description, Discovery, and Integration.See UDDI (Universal Description,Discovery, and Integration)

universally unique IDs (UUIDs), 753UNKNOWN_TYPE constant, 868unloading time, 429–430unparsed entities

declaration event handlers, 281–283entity declarations, 57notation declarations, 66–67referencing, 65–66URIs, retrieving, 374–375

unparsed-entity-uri() function, 374–375unparsedHandler() method, 494unqualified names, RELAX NG schemas, 115–116unserialize() method, 511unserializing WDDX data, 581–583, 584–585, 590,

591–592unset() method, 253–254, 257, 428unsignedByte type, 842unsignedInt type, 842unsignedLong type, 842unsignedShort type, 842updated element, 547, 549updating resources, 636, 637. See also REST

(Representational State Transfer)uppercase characters, 17–18uri element, 545uri option, 711uri parameter, 724

■INDEX914

Page 74: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

URIs (Uniform Resource Identifiers), 14API versioning and, 638–639base URIs, 42–43combining multiple schemas, 93in REST architecture, 638–639namespaces, 31outputting to, XSLT, 392relative URIs, 42–43XML Base specification, 42–43XPointer references, 146, 147

Url elementCatalog element, Yahoo, 652Offer element, Yahoo, 655Result element, Yahoo Web Search, 650

url element, 527, 538URLs (Uniform Resource Locators), 14, 147use attribute

attribute element, 79WSDL, 693xsl:key element, 371

use-attribute-sets attribute, 351use option, 711user-derived types, 73, 80–83, 117–119UserLand Software, 522UserRating element, 652use_soap_error_handler() function, 868useType attribute, 756, 757UTF-8, UTF-16 encodings, 15, 19, 169, 170–172

DOM extension and, 188, 226SAX parser and, 293–294

utf8_decode() function, 293, 849utf8_encode() function, 293, 849UUencode encoding, 67UUIDs (universally unique IDs), 753

■Vvalid documents, 45VALIDATE constant, 850validate() method, 214–215, 861validateOnParse property, 860validating server-based information, 826–830validation, 45–46

DTDs. See DTDs (Document Type Definitions)entity errors, 227libxml2-derived errors, 177malformed document errors, 177RELAX NG schemas. See schemas, RELAX NGscope of declarations, 89–91, 93XInclude and, 152XML schemas. See schemas, XMLXML_DTD package, 512, 515XMLReader, 313

value attribute, 80, 363value comparisons, XPath expressions, 135–136,

144–145value element, 533, 596, 599, 600, 603value key, array structures, 289value() method, 626value pattern, 112–113, 113, 114value property, 321, 851, 861values

attribute default values, 60–62attribute values, 24, 25, 326, 450

name/value pairs, 24node values, DOM extension, 195

var element, 573–574, 577variable variables, 561variables, XSLT, 366–368verbosity option, 613version attribute, 342, 381, 383, 386version information

API versioning, URIs and, 638–639in XML declaration, 19libxml2 version, 172–173

version option, 613version property, 860VersionMismatch fault code, SOAP, 702

■Wwakeup() method, 224–225WAP Cascading Style Sheets (WCSS), 835WAP (Wireless Application Protocol), 830–838W3C (World Wide Web Consortium), 14, 15W3C XML Schemas namespace, 72WCSS (WAP Cascading Style Sheets), 835wddx extension, 166WDDX (Web Distributed Data Exchange), 166,

567–568data types, 568–569, 571–576enabling, 576packets, 570serializing data, 577–581, 583–584, 590–591unserializing data, 581–583, 584–585, 591–592Web service client (example), 587–589Web service server (example), 586–587XML_WDDX package, 589–592

wddx_add_vars() function, 580wddx_deserialize() method, 581–583wddxPacket element, 570wddx_packet_end() function, 580, 581wddx_packet_start() function, 580wddx_serialize_value() method, 577, 583wddx_serialize_vars() method, 577–578weather information, Web service, 793–797Weather.com, 793–797Web Search service, Yahoo, 648–651Web service definitions, WSDL, 695–696Web services, 10, 11–13

Amazon. See Amazon Web servicescreating, 797–802del.icio.us Web service, 785–786discovering. See UDDI (Universal Description,

Discovery, and Integration)eBay. See eBay Web servicesGoogle. See Google Web servicesPEAR Web service packages, 781publicly accessible (XMethods listing), 715registries. See UDDI (Universal Description,

Discovery, and Integration)REST. See REST (Representational State

Transfer)Technorati Web service, 789–793UDDI. See UDDI (Universal Description,

Discovery, and Integration)WDDX (example), 586–589weather information service, 793–797

■INDEX 915

Find it faster at http://superindex.apress.com/

Page 75: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

WSDL. See WSDL (Web Services DescriptionLanguage)

Yahoo. See Yahoo Web servicesWeb Services Architecture Working Group (W3C),

11Web Services Description Language. See WSDL

(Web Services Description Language)Web services extensions, 166Web Services Interoperability Organization (WS-I),

11, 673, 674, 699well-formed documents, 45whitespace

formatting XML documents, 23–24in canonical XML, 450, 455in DOM tree, 182, 197, 213in element type declarations, 50–52in NMTOKEN, NMTOKENS types, 65in SAX parser, 273, 276–277, 290–291, 301in user-derived types, 81–82in XML documents, 16in XMLReader, 317, 318, 320migrating to PHP 5, 301xml:space attribute, 41–42

WHITESPACE constant, 317, 318, 850whiteSpace element, 81–82wholeText property, 864width element, 538wildcards, markup declarations, 49–50Winer, Dave, 10, 522Wireless Application Protocol (WAP), 830–838wml element, 832WML (Wireless Markup Language), 830, 831–833wrapper code, 229–230writeAttribute() method, 814, 872writeCdata() method, 872writeComment() method, 872writeDtd() method, 873writeElement() method, 814, 872writeElementNs() method, 872writePi() method, 872WS-I (Web Services Interoperability Organization),

11, 673, 674, 699WSDL (Web Services Description Language),

11–12, 673–674binding definitions, 690–695data type definitions, 678–681document structure, 677–678example document, 675–677faults, 687, 693Google Web services and. See Google Web

servicesmessage definitions, 681–685port type definitions, 685–690prefix/namespace mappings, 674Services_Webservice package, 797–802SOAP messages (examples), 697SOAP servers and, 723–724Web service definitions, 695–696

■XXBRL (Extensible Business Reporting Language), 6XHTML Basic, 833XHTML documents, 516–519

XHTML (Extensible HTML), 24XHTML Mobile Profile (XHTML MP), 830, 833–836xhtml value, Text construct, 544xi prefix, 152xi:fallback element, 155–157xi:include element, 152–155XInclude, 152

failed XIncludes, handling, 155–156including external content, 152–155, 876–879optimizing memory usage, 426–427XML Base specification, 42–43

xinclude() method, 861XLink, 42–43, 157–159xlink prefix, 158XMethods, 715XML Base specification, 42–43XML data

loading in DOM trees, 189–190saving as HTML, 192saving as XML, 191SDO access, 823–825

XML declaration, 18–19, 450XML documents

adding DTDs manually, 227adding images to, 65–66body, 20breaking into smaller documents, 426–427,

436–438CDATA sections, 26–27characters in, 15–18cloning, libxslt library and, 389comments, 27–28as databases, 7–8document encryption, 476DOM extension. See DOM extensionentity errors, 227external content. See XIncludeformatting, 23–24, 502–504keys in style sheets, troubleshooting, 389large document processing, 426–427, 429–430layout and components of, 18–20markup declarations. See markup declarationsnative XML databases, 8–9outputting, SimpleXML, 241parsing. See parsers and parsingprocessing instructions, 28prolog, 18–20root element, 18, 20signing. See digital signaturessyntax, 21tree representation of (DOM), 182–183using XMLWriter, 814–819validation. See validation

XML-enabled databases. See native XML databases(NXDs)

XML encryptioncharacter data encryption, 476decrypting data, 484–489detached encryption, 477document encryption, 476element encryption, 475encrypting data, 480–484enveloping encryption, 477

■INDEX916

Page 76: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

mixed content encryption, 475–476super encryption, 476–477XML encryption structure, 477–480

XML encryption structure, 477–480XML (Extensible Markup Language), 1

history of, 2–4HTML vs., 22–24uses for, 4–9W3C design goals, 3–4

xml extension, 165, 270–272, 847–849, 875–876. Seealso SAX (Simple API for XML)

character data handlers, 301choosing parsers, 424, 426default handler, 302–303, 876document editing, 415document navigation, 413–414, 415DOM parser, example code, 306–310ease of use, 410, 416large document processing, 410, 412, 413namespace support, 410, 417–418, 419system resource usage, 410, 412, 413target encoding, 300XML_Parser package, 493–498XMLReader compared to, 312–314

XML extensions, PHP, 164–167. See also names ofspecific extensions

XML() method, 315, 852XML output, XSLT result trees, 382–385xml prefix, 16, 33XML representation of resources, 634–636. See also

REST (Representational State Transfer)XML-RPC, 595–596. See also xmlrpc extension

data type elements, 596–600encoding and decoding data, 609–610error handling, 607, 614, 618faults, 607, 618relationship to SOAP, 10requests, 601–602, 603–605, 612–613, 614–616,

617–618, 619–620responses, 605, 606–607, 613, 614, 618, 620return values, 606–607server information, retrieving, 608stock trader (example), 615–616, 619–622XML-RPC client (example), 612–617, 625, 628XML-RPC server (example), 617–622, 626–628

XML schemas. See schemas, XMLXML signatures, 460–461. See also encryption

creating, 466–471detached signatures, 462enveloped signatures, 461enveloping signatures, 461–462references, 467–469, 472–473signatures, 470–471, 473–474XML signature structure, 462–465

XML_ATTRIBUTE_NODE constant, 854XML_Beautifier package, 502–504XML_CDATA_SECTION_NODE constant, 854XML_COMMENT_NODE constant, 854XML_DECLARATION constant, 318, 850XML_DOCUMENT_FRAG_NODE constant, 854XML_DOCUMENT_NODE constant, 854XML_DOCUMENT_TYPE_NODE constant, 854XML_DTD package, 512–516

XML_DTD_Parser class, 513–514XML_DTD_Tree class, 513–514XML_DTD_XmlValidator class, 513, 515XML_ELEMENT_NODE constant, 854xmlEncoding property, 860XML_ENTITY_NODE constant, 854XML_ENTITY_REF_NODE constant, 854XML_ERROR... constants, 848xml_error_string() function, 293, 849XML_FastCreate class, 517XML_FastCreate package, 516–519xml_get_current_byte_index() function, 291–292,

303–304, 849xml_get_current_column_number() function,

291–292, 303–304, 849xml_get_current_line_number() function,

291–292, 849xml_get_error_code() function, 293, 849XML_HTML_DOCUMENT_NODE constant, 854XML_HTMLSax package, 504–506xmlLang property, 321, 851XML_NOTATION_NODE constant, 854xmlns prefix, 31, 33. See also namespacesXML_OPTION_CASE_FOLDING option, 273, 505,

847XML_OPTION_ENTITIES_PARSED option, 505XML_OPTION_ENTITIES_UNPARSED option, 505XML_OPTION_LINEFEED_BREAK option, 505XML_OPTION_SKIP_TAGSTART option, 273, 274,

290–291, 847XML_OPTION_SKIP_WHITE option, 273, 274,

290–291, 847XML_OPTION_TAB_BREAK option, 505XML_OPTION_TARGET_ENCODING option, 273,

300, 847XML_OPTION_TRIM_DATA_NODES option, 505xml_parse() function, 285, 849xml_parse_into_struct() function, 288, 849XML_Parser class, 494–497xml_parser_create() function, 272, 848xml_parser_create_ns() function, 296, 848xml_parser_free() function, 294, 849xml_parser_get_option() function, 273, 849xml_parser_set_option() function, 273XML_Parser_Simple class, 497–498XML_PI_NODE constant, 854XMLReader, 311, 849–852, 876–879

Atom parser (example), 561–563choosing parsers, 424, 426copying subtrees, 436–438document editing, 415document navigation, 413–414, 415document processing example, 335–339DOM interoperability, 436–438ease of use, 410, 416, 417large document processing, 410, 413locating specific elements, 430–431, 433memory usage, 426–427namespace support, 410, 418, 419namespaces and, 312–313, 328–333node object properties, 320–321node type constants, 317–319, 850nodes, exporting to DOM objects, 328

■INDEX 917

Find it faster at http://superindex.apress.com/

Page 77: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

optimizing, 426–427, 430–431, 433parser properties, 316–317parsing XML documents, 317–327, 338–339performance, 430–431, 433processing speed, 313–314reading XML data, 315system resource usage, 410, 413validation, 313xml extension compared to, 312–314XMLReader object, creating, 314–315XSL interoperability, 438–439

XMLReader extension, 165, 876–879XMLReader object, 314–315XMLREADER_DEFAULTATTRS property, 316XMLREADER_LOADDTD property, 316, 333XMLREADER_SUBST_ENTITIES property, 316XMLREADER_VALIDATE property, 316, 333xmlrpc extension, 166, 608. See also XML-RPC

converting to XML-RPC data types, 610–611encoding and decoding data, 609–610stock trader (example), 615–616, 619–622XML-RPC client (example), 612–617, 625, 628XML-RPC server (example), 617–622, 626–628

XML_RPC package, 622–628XML_RPC_Client class, 625xmlrpc_decode() function, 609–610, 613xmlrpc_encode() function, 609–610xmlrpc_encode_request() function, 612–613, 618xmlrpc_get_type() function, 610xmlrpc_is_fault() function, 614XML_RPC_Message class, 624–625XML_RPC_Response class, 626XML_RPC_Server class, 626–628xmlrpc_server_call_method() function, 620xmlrpc_server_create() function, 619xmlrpc_server_destroy() function, 619xmlrpc_server_register_method() function, 619xmlrpc_set_type() function, 610xmlrpc_type property, 611XML_RPC_Value class, 623–624XML_RSS package, 512XML_Serializer class, 506–510XML_Serializer package, 506–512xml_set_character_data_handler() function, 275,

848xml_set_default_handler() function, 849xml_set_element_handler() method, 274, 275, 848xml_set_end_namespace_decl_handler() function,

849xml_set_external_entity_ref_handler() method,

280, 305–306, 849xml_set_notation_decl_handler() method,

281–282, 849xml_set_object() function, 297–300, 848xml_set_processing_instruction_handler()

method, 279, 849xml_set_start_namespace_decl_handler() method,

297, 849xml_set_unparsed_entity_decl_handler() method,

281–282, 849xmlStandalone property, 860XML_TEXT_NODE constant, 854XML_Tree class, 499–501

XML_Tree package, 498–501XML_Tree_Node class, 499XML_Unserializer class, 510–512XML_Util package, 501–502xmlVersion property, 860XML_WDDX package, 589–592XMLWriter extension, 811–820, 871–873xmlwriter_open_memory() function, 819xmlwriter_open_uri() function, 819XPath, 14, 123. See also XPointer

axes, 127–128calculations, 146complex expressions, 141–146data model, 124–127DOM extension support, 216–219equivalent XPointer expressions, 147filtering node sets, 133–134locating elements, 432–433location paths, 127–132namespaces, registering, 218–219, 227, 261node sets, 127node tests, 128–130nodes and node types, 124–127NXDs and, 8–9optimizing expressions, 138–139predicates, 130SimpleXML support, 260–261value comparisons, 135–136, 144–145XPath 2.0, 159–161XPath functions, 136–138, 144–145, 146XPath operators, 130XPointer extensions, 149–151

XPath 2.0, 159–161XPath functions, 136–138xpath() method, 260–261, 853XPath operators, 130XPointer. See also XPath

character escaping, 146extending XPath functionality, 149–151namespaces and, 148stacking XPointer expressions, 147–148URI references, 146, 147XPath expression equivalents, 147

xpointer attribute, 153XQuery, 159XSD_... SOAP constants, 868XSD files, 71xsd prefix, 72XSL (Extensible Stylesheet Language), 341

templates. See XSL templatestransformations. See XSLT (Extensible

Stylesheet Language Transformations)XMLReader interoperability, 438–439XSL extension. See XSL extension

XSL extension, 387–388, 866–867constants, 388–389corrupted XML, troubleshooting, 389EXSLT modules and, 395–396output methods, 391–393parameters, 393–395PHP functions, 396–399, 401RSS feed aggregation (example), 400–407style sheets. See style sheets

■INDEX918

Page 78: XML Schema Built-in Data Types Reference - Home - Springer978-1-4302-0139-7/1.pdf · XML Schema Built-in Data Types Reference X ML Schemas provide a number of built-in data types.

transforming data, 391–393XSLT processor. See XSLT processorYahoo Product Search service query (example),

656–659XSL functions, CDATA sections and, 173–174XSL templates, 343, 344–345

applying, 345–347built-in templates, 347–348calling, 348–349elements, matching, 343elements, specifying for processing, 346–347mode, specifying, 347names of templates, 343, 348–349priority, specifying, 343–344resolving conflicts, 343–344using DOM extension (example), 235–237

xsl:apply-templates element, 345–347, 359xsl:attribute element, 351xsl:attribute-set element, 352xsl:call-template element, 348–349xsl:choose element, 358, 359–360xsl:comment element, 354xsl:copy element, 354–355xsl:copy-of element, 355xsl:decimal-format element, 372–373xsl:element element, 350xsl:fallback element, 380xsl:for-each element, 358xsl:if element, 358–359xsl:key element, 370–372xsl:message element, 376xsl:number element, 362–366xsl:otherwise element, 359–360xsl:output element, 381–382xsl:param element, 366–369, 379xsl:processing-instruction element, 353–354xsl:sort element, 358, 360–362, 406–407xsl:stylesheet element, 342xsl:template element, 343xsl:text element, 353xsl:transform element, 342xsl:value-of element, 356xsl:variable element, 366–369xsl:when element, 359–360xsl:with-param element, 368–369XSL_CLONE_ALWAYS constant, 388–389, 866XSL_CLONE_AUTO constant, 388–389, 866XSL_CLONE_NEVER constant, 388–389, 866XSLT 2.0, 159XSLT (Extensible Stylesheet Language

Transformations), 14, 341attribute value templates, 349–350attributes, 351–352

comment nodes, 354conditional processing, 358–360copying nodes, 354–355current node, retrieving, 374debugging, 376elements, 350–351extension modules, 376–380external documents, 370fallback capabilities, 380formatted numbers, 362–366, 372–373HTML document generation (example),

356–357IDs, generating for node sets, 375keys, 370–372, 389messages, 376named attribute sets, 352–353outputting result trees, 381–387processing instruction nodes, 353–354processing node sets, 358sorting node sets, 360–362, 406–407style sheet, DOM extension (example), 399–400system property values, 375–376templates. See templates, XSLtext nodes, 353, 356unparsed entity URIs, 374–375user-defined functions, 378–380XML Base specification, 42–43XSLT processor. See XSLT processor

XSLT processorcorrupted XML, troubleshooting, 389methods, 390output methods, 391–393parameters, 393–395PHP functions, 396–399, 401, 402RSS feed aggregation (example), 400–407style sheet, importing, 390–391transforming data, 391–393

XSLTProcessor class, 389–390, 866–867

■YYahoo Web services, 12, 646

error format, 660Flickr, 646Product Search service, 651–659registering, 649results format, 646–647Services_Yahoo package, 802–806Web Search service, 647–651, 802–806

■Zzero-digit attribute, 373zeroOrMore pattern, 103, 109–110

■INDEX 919

Find it faster at http://superindex.apress.com/