Class DOMIT_Utilities
A collection of utilities for use with the DOMIT! parser. This class is meant to be called statically.

isPublic? yes
isAbstract? no

Inheritance tree:

DOMIT_Utilities (top level class)

Known subclasses:

None

Source file: xml_domit_utilities.php




Constructor



Public Constants



Private Constants



Public Fields



Private Fields



Public Methods
removeExtension
Strips the extension from the passed file.

Signature: removeExtension($fileName)

Parameters:

String fileName - The name of the file whose extension is to be stripped.

Returns:

String - The file name minus its extension.

Example:

Removes the extension from the specified file name.

$fileNameWithoutExt = DOMIT_Utilities::removeExtension("myDoc.xml");

printUTF8Header
Prints an HTTP header that informs the client (browser) to interpret all data as UTF-8 encoded. This method must be called <i><b>before</b></i> any HTTP content is sent.

Signature: printUTF8Header($contentType = "text/html")

Parameters:

String contentType - The mime type of the content. Default is text/html.

Example:

The HTTP header is set to interpret UTF-8 encoding:

DOMIT_Utilities::printUTF8Header();
echo $encodedNode->getText();

forHTML
Outputs <pre> formatted text that has had htmlEntities() applied.

Signature: forHTML($text, $doPrint = false)

Parameters:

String text - The text to be output.

String doPrint - True if output should be dumped to the browser, false if it should just be returned. Default is false.

Returns:

String - The resulting formatted text.




Private Methods
toNormalizedString
Returns a readable representation of the current xml document or node. Called by the DOMIT! method by the same name.

Signature: toNormalizedString (&$node, $subEntities=false, $definedEntities)

Parameters:

DOMIT_Node node - The node which is to be rendered as a string.

boolean subEntities - True if entity substitution is to be performed.

Array definedEntities - A user defined translation table of entities and their replacement values.

Returns:

String - A readable representation of the current xml document or node.

getNormalizedString
Returns a readable representation of the current xml node. Called by the toNormalizedString() method.

Signature: getNormalizedString(&$node, $node_level, $subEntities=false, $definedEntities

Parameters:

DOMIT_Node node - The current node to be normalized.

int node_level - The level in the xml tree of the current node.

boolean subEntities - True if entity substitution is to be performed.

Array definedEntities - A user defined translation table of entities and their replacement values.

Returns:

String - A readable representation of the current node.

convertEntities
Converts illegal XML characters to their entity representations.

Signature: convertEntities($text, $definedEntities)

Parameters:

string text - The text on which the entity conversion is to be performed.

Array definedEntities - A user defined translation table of entities and their replacement values.

Returns:

String - The entity converted text.

getNormalizedElementString
Gets a normalized (formatted for readability) representation of the current element

Signature: getNormalizedElementString(&$node, $response, $node_level, $subEntities, $definedEntities)

Parameters:

DOMIT_Node node - The node to be normalized.

string response - The current normalized text.

int node_level - The level in the DOM hierarchy where the node is located.

boolean subEntities - True if illegal xml characters in text nodes and attributes should be converted to entities.

Array definedEntities - A user defined translation table of entities and their replacement values.

Returns:

String - The normalized string representation.

isTextNode
Determines whether the specified node is a Text node.

Signature: isTextNode($node)

Parameters:

DOMIT_Node node - The node to be tested.

Returns:

boolean - True if the node is a Text node.

getIndentation
Sets the indentation for the normalization of the current node.

Signature: getIndentation($node_level)

Parameters:

int node_level - The level in the xml tree of the current node.

Returns:

String - A sequence of spaces corresponding to the indentation width.

validateXML
Performs some minor validation of the xml string about to be parsed. Note that this does not validate against a DTD or XML Schema Definition.

Signature: validateXML($xmlText)

Parameters:

String xmlText - The xml string to be validated.

Returns:

boolean - True is valid, false if invalid.


Documentation generated by ClassyDoc, using the DOMIT! and SAXY parsers.
Please visit Engage Interactive to download free copies.