Documentation automatically generated from the source-code using phpDocumentor.
Official Homepage: xao-php.sourceforge.net
XAO
Official homepage | API home | class tree: XAO | index: XAO | all elements

Class: DomDoc

Source Location: Program_Root/XAO_DomDoc.php

Class DomDoc

Class Overview

General purpose DOM class

This class provides three forms of functionality. 1) shortcut functions to operations made tedious by the DOM API. 2) additional features not supported by the DOM API. 3) a thread-safe way of interacting with files associated with the class' DOM document.

Located in Program_Root/XAO_DomDoc.php [line 102]

XaoRoot
   |
   --DomDoc

Properties

Methods

[ Top ]
Direct descendents
Child Class Description
AppDoc XML Application Object
DbToXml Convert a result table from an SQL query into basic XML.
DomXsl XSL Stylesheet as a DomDoc object
InputControl Collection for grouping InputFields and other InputControls.
InputField Collection requirements for a single information item.
InputValidator Base class for servants filling out requests for RpcController.
RpcServant Base class for servants filling out requests for RpcController.
XmlDB Convert a result table from an SQL query into basic XML.

[ Top ]
Property Summary
node   $ndErr   Element containing the last(current) error message.
node   $ndRoot   Document root node
object   $objDoc   An instance of the main DOM XML object.
object   $objErr   Singleton instance of Exceptions object.

[ Top ]
Method Summary
void   DomDoc()   Constructor method
void   Arr2Atts()   Turn an associative array into attributes
void   &arrNdXPath()   Return a list of nodes resulting from an XPath Query
void   blnTestElementNode()   Test if the supplied node is on object of type "domelement"
void   blnTestXmlName()   Do a reliable test for a valid element name
void   CommitToFile()   mass storage serialisation
void   ConsumeDocData()   Import well-balenced XML data to append below $this->ndRoot
node   &ndAppendToNode()   quickly add a new element under an exising element node.
node   &ndAppendToRoot()   quickly add a new element under the root element.
void   &ndConsumeDoc()   Import a foreign PHP DOM XML document and append it below $this->ndRoot
void   ndConsumeFile()   Import an XML document from a file and append it below $this->ndRoot
void   ndConsumeFragData()   Import well-balenced XML data to append below $this->ndRoot
node   &ndGetOneEl()   fetch a single element node by name
node   &ndImportChildFrag()   Import a fragment from a foreign PHP DOM XML document
void   ProcessCustomTags()   Process all nodes (domelements) due for processing.
void   SetCustomTagName()   Have all elements of a specified name processed by a call-back function.
void   SetCustomTagQuery()   Use an XPath to nominate nodes for processing by a call-back function.
void   Throw()   Base error logger
xml   xmlGetDoc()   Serialise and return the entire document object as stand-alone XML.
xml   xmlGetFrag()   Serialise and return the entire document as an XML fragment.

[ Top ]
Properties
node   $ndErr [line 127]

Element containing the last(current) error message.

This is populated by $this->Throw() and is always appended to the root node. in order for consumed DOM documents to have their errors displayed the consume function of the context DomDoc needs to search for these and copy them to the root node of itself.

API Tags:
Access:  public


[ Top ]
node   $ndRoot [line 154]

Document root node

This object variable conains a reference to the root element node of this DomDoc. It's a handy shortcut to $this->objDoc->document_root() because it is used a lot.

API Tags:
Access:  public


[ Top ]
object   $objDoc [line 142]

An instance of the main DOM XML object.

The native PHP DOM XML object is kept here. Any PHP DOM methods may be accessed directly from this object. For instance, $objMy->objDoc->get_element_by_id(); The user can also pass this member to functions requiring a native PHP DOM XML object. It is important to note that the XAO API in no way limits the user's access to PHP's built-in functions.

API Tags:
Access:  public


[ Top ]
object   $objErr [line 114]

Singleton instance of Exceptions object.

This is only instantiated if $this->Throw() is called. This object encapsulates error data management. It keeps all the error data on the referenced DOM doc rather than a stack local to this class.

API Tags:
Access:  public


[ Top ]
Methods
Constructor DomDoc  [line 202]

  void DomDoc( mixed &$mxdData, [int $intUse = XAO_DOC_NEW]  )

Constructor method

Create the objDoc instance property and associated ndRoot property based on the user-selected mode of document creation.

Parameters:
mixed   &$mxdData:  information required to create a DOM document
int   $intUse:  constant specifying how the document is to be created

API Tags:
Access:  public


[ Top ]
Arr2Atts  [line 679]

  void Arr2Atts( node &$ndEl, array $arrAttribs  )

Turn an associative array into attributes

The hash keys are used for the attribute names and the values are used for the attribute values.

Parameters:
node   &$ndEl: 
array   $arrAttribs: 

API Tags:
Access:  public


[ Top ]
arrNdXPath  [line 808]

  void &arrNdXPath( string $strExpr  )

Return a list of nodes resulting from an XPath Query

This function runs the XPath query and returns an array of nodes matching the results. Unfortunately, xpath_eval() never divulges any error information. I assume that $objRes->nodeset holds a false value if the query errored.

Parameters:
string   $strExpr:  The XPath query

API Tags:
Access:  public


[ Top ]
blnTestElementNode  [line 832]

  void blnTestElementNode( string $ndEl  )

Test if the supplied node is on object of type "domelement"

This function is useful for testing variables that need to be accessed as domelement objects..

Parameters:
string   $ndEl:  The name to test.

API Tags:
Access:  public


[ Top ]
blnTestXmlName  [line 847]

  void blnTestXmlName( string $strName  )

Do a reliable test for a valid element name

This function tries to create an element using the supplied name. If it fails, then the name is assumed to be invalid.

Parameters:
string   $strName:  The name to test.

API Tags:
Access:  public


[ Top ]
CommitToFile  [line 352]

  void CommitToFile( uri $uriDestination  )

mass storage serialisation

This function will dump the ASCII version of this XML document [in it's current state] to a specified file.

Parameters:
uri   $uriDestination:  path to destination file

API Tags:
Access:  public


[ Top ]
ConsumeDocData  [line 608]

  void ConsumeDocData( xml $str  )

Import well-balenced XML data to append below $this->ndRoot

This function will consume the contents of an XML document.The content is then retained under $this->ndRoot

Parameters:
xml   $str:  Miscellaneous XML data

API Tags:
Access:  public


[ Top ]
ndAppendToNode  [line 438]

  node &ndAppendToNode( node &$ndStub, string $strElName, [string $strCont = ""]  )

quickly add a new element under an exising element node.

This function is basically a shortcut for the common task of adding a new element with some content under an existing node of the document.

Parameters:
node   &$ndStub:  a reference to the exisitng element node
string   $strElName:  the name of the new element
string   $strCont:  the content of the new element

API Tags:
Return:  the newly added element node object
Access:  public


[ Top ]
ndAppendToRoot  [line 410]

  node &ndAppendToRoot( string $strElName, [string $strCont = ""]  )

quickly add a new element under the root element.

This function is basically a shortcut for the common task of adding a new element with some content under the root element of the document.

Parameters:
string   $strElName:  the name of the new element
string   $strCont:  the content of the new element

API Tags:
Return:  the newly added element node object
Access:  public


[ Top ]
ndConsumeDoc  [line 516]

  void &ndConsumeDoc( DomDoc &$objDoc, [node $ndStub = null]  )

Import a foreign PHP DOM XML document and append it below $this->ndRoot

This function will consume the contents of an entire DOM document and retain it below the root node of this DomDoc.

Parameters:
DomDoc   &$objDoc:  a reference to an exising PHP DOM XML document
node   $ndStub:  an optional stub node to which the new data is grafted

API Tags:
Access:  public


[ Top ]
ndConsumeFile  [line 549]

  void ndConsumeFile( uri $uri, [mixed $ndStub = null]  )

Import an XML document from a file and append it below $this->ndRoot

This function will consume the contents of an entire XML document from a file and retain it below the root node of this DomDoc.

Parameters:
uri   $uri:  the location of the XML file

API Tags:
Access:  public


[ Top ]
ndConsumeFragData  [line 572]

  void ndConsumeFragData( xml $str, string $strRoot, [mixed $ndStub = null]  )

Import well-balenced XML data to append below $this->ndRoot

This function will consume the contents of some XML data after wrapping it in a root element whos name is specified in the second parameter. The content is then retained under $this->ndRoot

Parameters:
xml   $str:  Miscellaneous XML data
string   $strRoot:  The name of the root element

API Tags:
Access:  public


[ Top ]
ndGetOneEl  [line 392]

  node &ndGetOneEl( uri $strName, [integer $intIdx = 0]  )

fetch a single element node by name

A convenience function for fetching a node reference to an element by specifying only it's name.

Parameters:
uri   $strName:  name of the element whose node is to be returned
integer   $intIdx:  index of which node to return (0 for first)

API Tags:
Access:  public


[ Top ]
ndImportChildFrag  [line 484]

  node &ndImportChildFrag( node &$ndStub, node &$ndNew  )

Import a fragment from a foreign PHP DOM XML document

This function will import a fragment from a foreign PHP DOM XML document below the node specified in the first parameter. This function is especially used by the other Consume methods in this class. At the moment it EXPLOITS the fact that node::replace_node() allows the use of foreign DOM XML objects - this is not in the spec. So this behaviour cannot be relied upon. It's worth noting that there is an xinclude() function which looks like it might be the way to go but documentation is vague http://www.xmlsoft.org/html/libxml-xinclude.html http://www.php.net/manual/en/function.domdocument-xinclude.php in any case, all maintenance for this functionality is centralised at this one point in the XAO api. If neccesary, it may eploy different techniques based on detecting which version of php/domxml is in use. Needless to say that this function is PIVOTAL to the XAO framework concept which uses aggregation to accumulate content through the CONSUME methods.

Parameters:
node   &$ndStub:  the node under which the fragment is to be grafted
node   &$ndNew:  foreign node containing the fragment to be imported

API Tags:
Return:  the newly added element node object
Access:  public


[ Top ]
ProcessCustomTags  [line 763]

  void ProcessCustomTags( )

Process all nodes (domelements) due for processing.

When the user has finished nominating all the nodes for processing using either SetCustomTagName() or SetCustomTagQuery(), then this function can be called. It's a good idea to make sure this is only called as many times as it needs to be (once).


API Tags:
Access:  public


[ Top ]
SetCustomTagName  [line 733]

  void SetCustomTagName( string $elName, string $fncName  )

Have all elements of a specified name processed by a call-back function.

This functionality is dubious when using namespaces. The experimental nature of PHP's DOMXML extension makes it impossible to guarentee safe usage.

Parameters:
string   $elName:  name of element to be globally matched
string   $fncName:  name of user-defined callback function

API Tags:
Access:  public


[ Top ]
SetCustomTagQuery  [line 710]

  void SetCustomTagQuery( string $strQuery, string $fncName  )

Use an XPath to nominate nodes for processing by a call-back function.

This functionality is dubious when using namespaces. The experimental nature of PHP's DOMXML extension makes it impossible to guarentee safe usage.

Parameters:
string   $strQuery:  XPath query
string   $fncName:  name of user-defined callback function

API Tags:
Access:  public


[ Top ]
Throw  [line 288]

  void Throw( string $strErrMsg, [array $arrAttribs = null]  )

Base error logger

All DomDoc based objects should use this method to raise errors. The method will not stop execution. It will create elements on the DomDoc tree containing all the error data available. It is up to the stylsheet to extract and render error information through an appropriate template. Users should note the ability to define a custom call-back function which may be created as a method in the child object. To do this, populate $this->strErrCallbackFunc with the name of your custom error method. To find out more about how the exception elements are populated, check out the documentation in the Exceptions class.

Parameters:
string   $strErrMsg:  Main error message for display
array   $arrAttribs:  A hash of attributes/values to include in error element

API Tags:
Access:  public


Redefinition of:
XaoRoot::Throw()
Generic/default error handler.

Redefined in descendants as:
  • AppDoc::Throw() : Wrapper for parent::throw() function adding ability to abort script

[ Top ]
xmlGetDoc  [line 322]

  xml xmlGetDoc( )

Serialise and return the entire document object as stand-alone XML.

This is used when the entire XML document is required in ASCII format.


API Tags:
Return:  document
Access:  public


[ Top ]
xmlGetFrag  [line 337]

  xml xmlGetFrag( )

Serialise and return the entire document as an XML fragment.

This is used when an ASCII version of the XML document is required _without_ any XML declaration or processing instructions. Everything below and including the root element is serialised.


API Tags:
Return:  fragment
Access:  public


[ Top ]

Documentation generated on Tue, 23 Sep 2003 18:33:59 +1000 by phpDocumentor 1.2.2