[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/includes/domit/ -> xml_domit_lite_parser.php (sommaire)

DOMIT! Lite is a non-validating, but lightweight and fast DOM parser for PHP

Author: John Heinstein <johnkarl@nbnet.nb.ca>
Copyright: (C) 2004 John Heinstein. All rights reserved
License: http://www.gnu.org/copyleft/lesser.html LGPL License
Version: 1.01
Poids: 1903 lignes (58 kb)
Inclus ou requis: 2 fois
Référencé: 0 fois
Nécessite: 9 fichiers
 includes/domit/php_file_utilities.php
 includes/domit/xml_domit_nodemaps.php
 includes/domit/xml_domit_doctor.php
 includes/domit/xml_domit_shared.php
 includes/domit/php_http_proxy.php
 includes/domit/php_http_client_generic.php
 includes/domit/xml_saxy_lite_parser.php
 includes/domit/xml_domit_getelementsbypath.php
 includes/domit/xml_domit_utilities.php

Définit 7 classes

DOMIT_Lite_Node:: (19 méthodes):
  DOMIT_Lite_Node()
  _constructor()
  appendChild()
  insertBefore()
  replaceChild()
  removeChild()
  getChildNodeIndex()
  hasChildNodes()
  cloneNode()
  getNamedElements()
  setOwnerDocument()
  nvl()
  getElementsByPath()
  getText()
  forHTML()
  toArray()
  onLoad()
  clearReferences()
  toNormalizedString()

DOMIT_Lite_ChildNodes_Interface:: (7 méthodes):
  DOMIT_Lite_ChildNodes_Interface()
  appendChild()
  insertBefore()
  replaceChild()
  removeChild()
  getElementsByAttribute()
  _getElementsByAttribute()

DOMIT_Lite_Document:: (42 méthodes):
  DOMIT_Lite_Document()
  resolveErrors()
  setConnection()
  preserveWhitespace()
  setAuthorization()
  setProxyConnection()
  setProxyAuthorization()
  useHTTPClient()
  getErrorCode()
  getErrorString()
  expandEmptyElementTags()
  setDocumentElement()
  appendChild()
  replaceChild()
  insertBefore()
  removeChild()
  createElement()
  createTextNode()
  createCDATASection()
  getElementsByTagName()
  getElementsByPath()
  parseXML_utf8()
  parseXML()
  loadXML_utf8()
  loadXML()
  establishConnection()
  getTextFromFile()
  saveXML_utf8()
  saveXML()
  saveTextToFile()
  parsedBy()
  getText()
  getDocType()
  getXMLDeclaration()
  setXMLDeclaration()
  getDOMImplementation()
  load()
  getVersion()
  appendEntityTranslationTable()
  toArray()
  cloneNode()
  toString()

DOMIT_Lite_Element:: (15 méthodes):
  DOMIT_Lite_Element()
  getTagName()
  getNamedElements()
  getText()
  setText()
  getElementsByTagName()
  getElementsByPath()
  getAttribute()
  setAttribute()
  removeAttribute()
  hasAttribute()
  normalize()
  toArray()
  cloneNode()
  toString()

DOMIT_Lite_TextNode:: (6 méthodes):
  DOMIT_Lite_TextNode()
  getText()
  setText()
  toArray()
  cloneNode()
  toString()

DOMIT_Lite_CDATASection:: (2 méthodes):
  DOMIT_Lite_CDATASection()
  toString()

DOMIT_Lite_Parser:: (8 méthodes):
  parse()
  parseSAXY()
  dumpTextNode()
  startElement()
  endElement()
  dataElement()
  cdataElement()
  defaultDataElement()


Classe: DOMIT_Lite_Node  - X-Ref

The base class of all DOMIT node types

DOMIT_Lite_Node()   X-Ref
Raises error if abstract class is directly instantiated


_constructor()   X-Ref
DOMIT_Lite_Node constructor, assigns a uid


appendChild(&$child)   X-Ref
Appends a node to the childNodes list of the current node

param: Object The node to be appended
return: Object The appended node

insertBefore(&$newChild, &$refChild)   X-Ref
Inserts a node to the childNodes list of the current node

param: Object The node to be inserted
param: Object The node before which the insertion is to occur
return: Object The inserted node

replaceChild(&$newChild, &$oldChild)   X-Ref
Replaces a node with another

param: Object The new node
param: Object The old node
return: Object The new node

removeChild(&$oldChild)   X-Ref
Removes a node from the childNodes list of the current node

param: Object The node to be removed
return: Object The removed node

getChildNodeIndex(&$arr, &$child)   X-Ref
Returns the index of the specified node in a childNodes list

param: Array The childNodes array to be searched
param: Object The node targeted by the search
return: int The index of the target node, or -1 if not found

hasChildNodes()   X-Ref
Determines whether a node has any children

return: boolean True if any child nodes are present

cloneNode($deep = false)   X-Ref
Copies a node and/or its children

param: boolean True if all child nodes are also to be cloned
return: Object A copy of the node and/or its children

getNamedElements(&$nodeList, $tagName)   X-Ref
Adds elements with the specified tag name to a NodeList collection

param: Object The NodeList collection
param: string The tag name of matching elements

setOwnerDocument(&$rootNode)   X-Ref
Sets the ownerDocument property of a node to the containing DOMIT_Document

param: Object A reference to the document element of the DOMIT_Document

nvl(&$value,$default)   X-Ref
Tests whether a value is null, and if so, returns a default value

param: mixed The value to be tested
param: mixed The default value
return: mixed The specified value, or the default value if null

getElementsByPath($pattern, $nodeIndex = 0)   X-Ref
Retrieves an element or DOMIT_NodeList of elements corresponding to an Xpath-like expression.

param: string The query pattern
param: int If a single node is to be returned (rather than the entire NodeList) the index of that node
return: mixed A NodeList or single node that matches the pattern

getText()   X-Ref
Returns the concatented text of the current node and its children

return: string The concatented text of the current node and its children

forHTML($str, $doPrint = false)   X-Ref
Formats a string for presentation as HTML

param: string The string to be formatted
param: boolean True if the string is to be sent directly to output
return: string The HTML formatted string

toArray()   X-Ref
Generates an array representation of the node and its children

return: Array A representation of the node and its children

onLoad()   X-Ref
A node event that can be set to fire upon document loading, used for node initialization


clearReferences()   X-Ref
Clears previousSibling, nextSibling, and parentNode references from a node that has been removed


toNormalizedString($htmlSafe = false, $subEntities = false)   X-Ref
Generates a normalized (formatted for readability) representation of the node and its children

param: boolean True if HTML readable output is desired
param: boolean True if illegal xml characters in text nodes and attributes should be converted to entities
return: string The formatted string representation

Classe: DOMIT_Lite_ChildNodes_Interface  - X-Ref

A parent class for nodes which possess child nodes

DOMIT_Lite_ChildNodes_Interface()   X-Ref
Raises error if abstract class is directly instantiated


appendChild(&$child)   X-Ref
Appends a node to the childNodes list of the current node

param: Object The node to be appended
return: Object The appended node

insertBefore(&$newChild, &$refChild)   X-Ref
Inserts a node to the childNodes list of the current node

param: Object The node to be inserted
param: Object The node before which the insertion is to occur
return: Object The inserted node

replaceChild(&$newChild, &$oldChild)   X-Ref
Replaces a node with another

param: Object The new node
param: Object The old node
return: Object The new node

removeChild(&$oldChild)   X-Ref
Removes a node from the childNodes list of the current node

param: Object The node to be removed
return: Object The removed node

getElementsByAttribute($attrName = 'id', $attrValue = '',$returnFirstFoundNode = false, $treatUIDAsAttribute = false)   X-Ref
Searches the element tree for an element with the specified attribute name and value.

param: string The value of the attribute
param: string The name of the attribute
param: boolean True if the first found node is to be returned as a node instead of a nodelist
param: boolean True if uid is to be considered an attribute
return: object A NodeList of found elements, or null

_getElementsByAttribute(&$nodelist, $attrName, $attrValue,$returnFirstFoundNode, $treatUIDAsAttribute, $foundNode = false)   X-Ref
Searches the element tree for an element with the specified attribute name and value.

param: object The node list of found elements
param: string The value of the attribute
param: string The name of the attribute
param: boolean True if the first found node is to be returned as a node instead of a nodelist
param: boolean True if uid is to be considered an attribute
param: boolean True the node has been found

Classe: DOMIT_Lite_Document  - X-Ref

A class representing the DOM Document

DOMIT_Lite_Document()   X-Ref
DOM Document constructor


resolveErrors($truthVal)   X-Ref
Specifies whether DOMIT! Lite will try to fix invalid XML before parsing begins

param: boolean True if errors are to be resolved

setConnection($host, $path = '/', $port = 80, $timeout = 0, $user = null, $password = null)   X-Ref
Specifies the parameters of the http conection used to obtain the xml data

param: string The ip address or domain name of the connection
param: string The path of the connection
param: int The port that the connection is listening on
param: int The timeout value for the connection
param: string The user name, if authentication is required
param: string The password, if authentication is required

preserveWhitespace($truthVal)   X-Ref
Specifies whether DOMIT! preserves whitespace when parsing

param: boolean True if whitespace is to be preserved

setAuthorization($user, $password)   X-Ref
Specifies basic authentication for an http connection

param: string The user name
param: string The password

setProxyConnection($host, $path = '/', $port = 80, $timeout = 0, $user = null, $password = null)   X-Ref
Specifies that a proxy is to be used to obtain the xml data

param: string The ip address or domain name of the proxy
param: string The path to the proxy
param: int The port that the proxy is listening on
param: int The timeout value for the connection
param: string The user name, if authentication is required
param: string The password, if authentication is required

setProxyAuthorization($user, $password)   X-Ref
Specifies basic authentication for the proxy

param: string The user name
param: string The password

useHTTPClient($truthVal)   X-Ref
Specifies whether an HTTP client should be used to establish a connection

param: boolean True if an HTTP client is to be used to establish the connection

getErrorCode()   X-Ref
Returns the error code from the underlying SAX parser

return: int The error code

getErrorString()   X-Ref
Returns the error string from the underlying SAX parser

return: string The error string

expandEmptyElementTags($truthVal, $expandEmptyElementExceptions = false)   X-Ref
Specifies whether elements tags will be rendered to string as <element></element> rather than <element/>

param: boolean True if the expanded form is to be used
param: mixed An array of tag names that should be excepted from expandEmptyElements rule (optional)

setDocumentElement(&$node)   X-Ref
Set the specified node as document element

param: Object The node that is to become document element
return: Object The new document element

appendChild(&$node)   X-Ref
Appends a node to the childNodes list of the current node

param: Object The node to be appended
return: Object The appended node

replaceChild(&$newChild, &$oldChild)   X-Ref
Replaces a node with another

param: Object The new node
param: Object The old node
return: Object The new node

insertBefore(&$newChild, &$refChild)   X-Ref
Inserts a node to the childNodes list of the current node

param: Object The node to be inserted
param: Object The node before which the insertion is to occur
return: Object The inserted node

removeChild(&$oldChild)   X-Ref
Removes a node from the childNodes list of the current node

param: Object The node to be removed
return: Object The removed node

createElement($tagName)   X-Ref
Creates a new DOMIT_Lite_Element node

param: string The tag name of the element
return: Object The new element

createTextNode($data)   X-Ref
Creates a new DOMIT_Text node

param: string The text of the node
return: Object The new text node

createCDATASection($data)   X-Ref
Creates a new DOMIT_Lite_CDATASection node

param: string The text of the CDATASection
return: Object The new CDATASection node

getElementsByTagName($tagName)   X-Ref
Retrieves a NodeList of child elements with the specified tag name

param: string The matching element tag name
return: Object A NodeList of found elements

getElementsByPath($pattern, $nodeIndex = 0)   X-Ref
Retrieves an element or DOMIT_NodeList of elements corresponding to an Xpath-like expression.

param: string The query pattern
param: int If a single node is to be returned (rather than the entire NodeList) the index of that node
return: mixed A NodeList or single node that matches the pattern

parseXML_utf8($xmlText, $useSAXY = true, $preserveCDATA = true, $fireLoadEvent = false)   X-Ref
Parses an xml string; first encodes string as UTF-8

param: string The xml text to be parsed
param: boolean True if SAXY is to be used instead of Expat
param: boolean False if CDATA Section are to be generated as Text nodes
param: boolean True if onLoad is to be called on each node after parsing
return: boolean True if parsing is successful

parseXML($xmlText, $useSAXY = true, $preserveCDATA = true, $fireLoadEvent = false)   X-Ref
Parses an xml string

param: string The xml text to be parsed
param: boolean True if SAXY is to be used instead of Expat
param: boolean False if CDATA Section are to be generated as Text nodes
param: boolean True if onLoad is to be called on each node after parsing
return: boolean True if parsing is successful

loadXML_utf8($filename, $useSAXY = true, $preserveCDATA = true, $fireLoadEvent = false)   X-Ref
Parses an xml file; first encodes text as UTF-8

param: string The xml file to be parsed
param: boolean True if SAXY is to be used instead of Expat
param: boolean False if CDATA Section are to be generated as Text nodes
param: boolean True if onLoad is to be called on each node after parsing
return: boolean True if parsing is successful

loadXML($filename, $useSAXY = true, $preserveCDATA = true, $fireLoadEvent = false)   X-Ref
Parses an xml file

param: string The xml file to be parsed
param: boolean True if SAXY is to be used instead of Expat
param: boolean False if CDATA Section are to be generated as Text nodes
param: boolean True if onLoad is to be called on each node after parsing
return: boolean True if parsing is successful

establishConnection($url)   X-Ref
Establishes a connection, given an url

param: string The url of the data

getTextFromFile($filename)   X-Ref
Retrieves text from a file

param: string The file path
return: string The text contained in the file

saveXML_utf8($filename, $normalized=false)   X-Ref
Saves the current DOM document as an xml file; first encodes text as UTF-8

param: string The path of the xml file
param: boolean True if xml text is to be normalized before saving
return: boolean True if save is successful

saveXML($filename, $normalized=false)   X-Ref
Saves the current DOM document as an xml file

param: string The path of the xml file
param: boolean True if xml text is to be normalized before saving
return: boolean True if save is successful

saveTextToFile($filename, $text)   X-Ref
Saves text to a file

param: string The file path
param: string The text to be saved
return: boolean True if the save is successful

parsedBy()   X-Ref
Indicates the SAX parser used to parse the current document

return: string Either "SAXY_LITE" or "EXPAT"

getText()   X-Ref
Returns the concatented text of the current node and its children

return: string The concatented text of the current node and its children

getDocType()   X-Ref
Returns the doctype text

return: string The doctype text, or an emty string

getXMLDeclaration()   X-Ref
Returns the xml declaration text

return: mixed The xml declaration text, or an empty string

setXMLDeclaration( $decl )   X-Ref
Returns the xml declaration text

return: mixed The xml declaration text, or an empty string

getDOMImplementation()   X-Ref
Returns a reference to the DOMIT_DOMImplementation object

return: Object A reference to the DOMIT_DOMImplementation object

load(&$contextNode)   X-Ref
Manages the firing of the onLoad() event

param: Object The parent node of the current recursion

getVersion()   X-Ref
Returns the current version of DOMIT! Lite

return: Object The current version of DOMIT! Lite

appendEntityTranslationTable($table)   X-Ref
Appends an array of entity mappings to the existing translation table

Intended mainly to facilitate the conversion of non-ASCII entities into equivalent characters

param: array A list of entity mappings in the format: array('&amp;' => '&');

toArray()   X-Ref
Generates an array representation of the node and its children

return: Array A representation of the node and its children

cloneNode($deep = false)   X-Ref
Copies a node and/or its children

param: boolean True if all child nodes are also to be cloned
return: Object A copy of the node and/or its children

toString($htmlSafe = false, $subEntities = false)   X-Ref
Generates a string representation of the node and its children

param: boolean True if HTML readable output is desired
param: boolean True if illegal xml characters in text nodes and attributes should be converted to entities
return: string The string representation

Classe: DOMIT_Lite_Element  - X-Ref

A class representing the DOM Element

DOMIT_Lite_Element($tagName)   X-Ref
DOM Element constructor

param: string The tag name of the element

getTagName()   X-Ref
Returns the tag name of the element

return: string The tag name of the element

getNamedElements(&$nodeList, $tagName)   X-Ref
Adds elements with the specified tag name to a NodeList collection

param: Object The NodeList collection
param: string The tag name of matching elements

getText()   X-Ref
Returns the concatented text of the current node and its children

return: string The concatented text of the current node and its children

setText($data)   X-Ref
If a child text node exists, sets the nodeValue to $data. A child text node is created if none exists

param: string The text data of the node

getElementsByTagName($tagName)   X-Ref
Retrieves a NodeList of child elements with the specified tag name

param: string The matching element tag name
return: Object A NodeList of found elements

getElementsByPath($pattern, $nodeIndex = 0)   X-Ref
Retrieves an element or DOMIT_NodeList of elements corresponding to an Xpath-like expression.

param: string The query pattern
param: int If a single node is to be returned (rather than the entire NodeList) the index of that node
return: mixed A NodeList or single node that matches the pattern

getAttribute($name)   X-Ref
Gets the value of the specified attribute, if it exists

param: string The attribute name
return: string The attribute value

setAttribute($name, $value)   X-Ref
Sets the value of the specified attribute; creates a new attribute if one doesn't exist

param: string The attribute name
param: string The desired attribute value

removeAttribute($name)   X-Ref
Removes the specified attribute

param: string The name of the attribute to be removed

hasAttribute($name)   X-Ref
Determines whether an attribute with the specified name exists

param: string The name of the attribute
return: boolean True if the attribute exists

normalize()   X-Ref
Collapses adjacent text nodes in entire element subtree


toArray()   X-Ref
Generates an array representation of the node and its children

return: Array A representation of the node and its children

cloneNode($deep = false)   X-Ref
Copies a node and/or its children

param: boolean True if all child nodes are also to be cloned
return: Object A copy of the node and/or its children

toString($htmlSafe = false, $subEntities = false)   X-Ref
Generates a string representation of the node and its children

param: boolean True if HTML readable output is desired
param: boolean True if illegal xml characters in text nodes and attributes should be converted to entities
return: string The string representation

Classe: DOMIT_Lite_TextNode  - X-Ref

A class representing the DOM Text Node

DOMIT_Lite_TextNode($data)   X-Ref
DOM Text Node constructor

param: string The text of the node

getText()   X-Ref
Returns the text contained in the current node

return: string The text of the current node

setText($data)   X-Ref
Sets the text contained in the current node to $data.

param: string The text data of the node

toArray()   X-Ref
Generates an array representation of the node and its children

return: Array A representation of the node and its children

cloneNode($deep = false)   X-Ref
Copies a node and/or its children

param: boolean True if all child nodes are also to be cloned
return: Object A copy of the node and/or its children

toString($htmlSafe = false, $subEntities = false)   X-Ref
Generates a string representation of the node and its children

param: boolean True if HTML readable output is desired
param: boolean True if illegal xml characters should be converted to entities
return: string The string representation

Classe: DOMIT_Lite_CDATASection  - X-Ref

A class representing the DOM CDATA Section

DOMIT_Lite_CDATASection($data)   X-Ref
DOM CDATA Section node constructor

param: string The text of the node

toString($htmlSafe = false, $subEntities = false)   X-Ref
Generates a string representation of the node and its children

param: boolean True if HTML readable output is desired
param: boolean True if illegal xml characters should be converted to entities
return: string The string representation

Classe: DOMIT_Lite_Parser  - X-Ref

Manages the generation of a DOMIT! document from SAX events

parse(&$myXMLDoc, $xmlText, $preserveCDATA = true)   X-Ref
Parses xml text using Expat

param: Object A reference to the DOM document that the xml is to be parsed into
param: string The text to be parsed
param: boolean True if CDATA Section nodes are not to be converted into Text nodes
return: boolean True if the parsing is successful

parseSAXY(&$myXMLDoc, $xmlText, $preserveCDATA, $definedEntities)   X-Ref
Parses xml text using SAXY

param: Object A reference to the DOM document that the xml is to be parsed into
param: string The text to be parsed
param: boolean True if CDATA Section nodes are not to be converted into Text nodes
return: boolean True if the parsing is successful

dumpTextNode()   X-Ref
Generates and appends a new text node from the parseContainer text


startElement(&$parser, $name, $attrs)   X-Ref
Catches a start element event and processes the data

param: Object A reference to the current SAX parser
param: string The tag name of the current element
param: Array An array of the element attributes

endElement(&$parser, $name)   X-Ref
Catches an end element event and processes the data

param: Object A reference to the current SAX parser
param: string The tag name of the current element

dataElement(&$parser, $data)   X-Ref
Catches a data event and processes the text

param: Object A reference to the current SAX parser
param: string The current text data

cdataElement(&$parser, $data)   X-Ref
Catches a CDATA Section event and processes the text

param: Object A reference to the current SAX parser
param: string The current text data

defaultDataElement(&$parser, $data)   X-Ref
Catches a default data event and processes the data

param: Object A reference to the current SAX parser
param: string The current data



Généré le : Wed Nov 21 14:43:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics