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.
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
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:
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:
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
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 & 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.
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.
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
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
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.
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
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
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
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.
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
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
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
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
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
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
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
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
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
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
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
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.
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
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
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.
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
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
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
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
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.
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:
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
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
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
Method Description
endDocument() Closes an open document.
startDtd(string name[, string Starts a DTD tag.pubid[, string sysid]])
startDtdElement(string name) Starts a DTD element.
endDtdElement() Closes an open DTD element.
APPENDIX B ■ EXTENSION APIS 873
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.
<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
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
<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') {
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()
<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
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
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
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
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
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:
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
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;
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:
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
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
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.
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
clientsREST Web service (example), 643–645SOAP. See SOAP clientsvalidating server-based data, 826–830WDDX Web service (example), 587–589XML-RPC, 612–617, 625, 628
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
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
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)
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
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)
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,
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
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
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
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
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
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
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/
WSDL. See WSDL (Web Services DescriptionLanguage)
Yahoo. See Yahoo Web servicesWeb Services Architecture Working Group (W3C),
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
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