SXMLHelper Class Reference

Help with XML-related tasks. More...

Inheritance diagram for SXMLHelper:

Inheritance graph
[legend]

List of all members.

Static Public Member Functions

static contentFromXML ($input)
 Decode content stored as XML.
static contentToXML ($input)
 Encode content for storage as XML.
static formatXML ($xml, $highlight=false, $lineNumbers=false)
 Formats XML, optionally adding syntax highlighting.
static parse ($xml, $intoDOM=false)
 Parse an XML string and catch any parsing errors.
static validateXML ($xml, $useSchema=true)
 Validates XML for well-formedness and against Shodor schema.


Detailed Description

Help with XML-related tasks.

Author:
jwsm@shodor.org
Date:
2/19/09

Member Function Documentation

static SXMLHelper::contentFromXML ( input  )  [static]

Decode content stored as XML.

Replace all XML entity encodings with the characters they represent

Parameters:
$input [string]: An XML string
Returns:
[string]: The content with safe entities replaced by normal characters

static SXMLHelper::contentToXML ( input  )  [static]

Encode content for storage as XML.

Replace all XML illegal characters with the proper entity encodings

Parameters:
$input [string]: A string of content to be made safe for XML
Returns:
[string]: The content with normal characters replaced by safe entities

static SXMLHelper::formatXML ( xml,
highlight = false,
lineNumbers = false 
) [static]

Formats XML, optionally adding syntax highlighting.

Parameters:
$xml [string]: XML to format
Returns:
[string]: formatted XML

static SXMLHelper::parse ( xml,
intoDOM = false 
) [static]

Parse an XML string and catch any parsing errors.

Use this static function to help with XML parsing. All parse errors are caught and sent to SErrorManager.

Parameters:
$xml [string]: A string of XML
Returns:
[mixed]: An XML object if the parse is successful; false if not

static SXMLHelper::validateXML ( xml,
useSchema = true 
) [static]

Validates XML for well-formedness and against Shodor schema.

Validation against Shodor schema is optional. If there is an error, an array of error information is returned. Each entry in the return array is an array containing four entries:

  • type: "Warning", "Error" or "Fatal Error"
  • code: libxml2 error code
  • line: line number of error
  • message: error message for error from libxml2
Parameters:
$xml [string]: String of XML to validate
$useSchema [boolean]: If true, validate XML against Shodor schema (default)
Returns:
[boolean/array]: True if validation succeeds, an array of errors as described above if not.


The documentation for this class was generated from the following file:

Generated on Wed Nov 24 02:04:01 2010 for Common by  doxygen 1.5.6