Erebot  latest
A modular IRC bot for PHP 5.3+
Erebot\DOM Class Reference

An extension of PHP's DomDocument class that implements Schematron validation on top of RelaxNG/XML Schema. More...

+ Inheritance diagram for Erebot\DOM:

Public Member Functions

 __construct ($version=null, $encoding=null)
 
 clearErrors ()
 
 getErrors ()
 
 relaxNGValidate ($filename, $schematron=true)
 
 relaxNGValidateSource ($source, $schematron=true)
 
 schemaValidate ($filename, $schematron=true)
 
 schemaValidateSource ($source, $schematron=true)
 
 validate ($schematron=false)
 

Static Public Member Functions

static getNodeLineNo (array $nodes)
 

Protected Member Functions

 schematronValidation ($source, $data, $schemaSource, $success, $schematron)
 

Protected Attributes

 $errors
 Stores the LibXMLError errors raised during validation.
 

Detailed Description

An extension of PHP's DomDocument class that implements Schematron validation on top of RelaxNG/XML Schema.

This class also makes it easier to deal with libxml errors, by providing methods to clear or retrieve errors directly.

See also
http://php.net/domdocument
http://www.schematron.com/

Definition at line 41 of file DOM.php.

Constructor & Destructor Documentation

Erebot\DOM::__construct (   $version = null,
  $encoding = null 
)

Constructs a new DOM document.

Parameters
string$version(optional) XML version to use.
string$encoding(optional) Encoding for the document.

Definition at line 55 of file DOM.php.

Member Function Documentation

Erebot\DOM::clearErrors ( )

Clears all validation errors.

Definition at line 395 of file DOM.php.

Erebot\DOM::getErrors ( )

Returns an array of errors raised during validation.

Return values
arrayArray of LibXMLError objets raised during validation.

Definition at line 387 of file DOM.php.

Erebot\DOM::relaxNGValidate (   $filename,
  $schematron = true 
)

Validates the current document against a RelaxNG schema, optionally validates embedded Schematron rules too.

Parameters
string$filenamePath to the RelaxNG schema to use for validation.
bool$schematron(optional) Whether embedded Schematron rules should be validated too (true) or not (false). The default is to also do $schematron validation.
Return values
booltrue if the document validates, false otherwise.

Definition at line 83 of file DOM.php.

Erebot\DOM::relaxNGValidateSource (   $source,
  $schematron = true 
)

Validates the current document against a RelaxNG schema, optionally validates embedded Schematron rules too.

Parameters
string$sourceSource of the RelaxNG schema to use for validation.
bool$schematron(optional) Whether embedded Schematron rules should be validated too (true) or not (false). The default is to also do $schematron validation.
Return values
booltrue if the document validates, false otherwise.

Definition at line 111 of file DOM.php.

Erebot\DOM::schematronValidation (   $source,
  $data,
  $schemaSource,
  $success,
  $schematron 
)
protected

Proceed to the actual Schematron validation.

Parameters
string$sourceSource of the Schematron rules:
  • 'file' when $data refers to a filename.
  • 'string' when $data refers to an in-memory string.
string$dataSchematron data. The interpretation of this parameter depends on the value of the $source parameter.
string$schemaSourceThe original schema type used to validate the document. This is "XSD" for XML Schema documents or "RNG" for RelaxNG schemas.
bool$successWhether the original validation process succeeded (true) or not (false). This is used to abort the Schematron validation process earlier.
bool$schematronWhether a Schematron validation pass should occur (true) or not (false).
Return values
boolWhether the overall validation passed (true) or not (false).
Note
In case validation failed, ::Erebot::DOM::DOM::getErrors() may be used to retrieve further information on why it failed.

Definition at line 214 of file DOM.php.

Erebot\DOM::schemaValidate (   $filename,
  $schematron = true 
)

Validates the current document against an XML schema, optionally validates embedded Schematron rules too.

Parameters
string$filenamePath to the XML schema to use for validation.
bool$schematron(optional) Whether embedded Schematron rules should be validated too (true) or not (false). The default is to also do $schematron validation.
Return values
booltrue if the document validates, false otherwise.

Definition at line 139 of file DOM.php.

Erebot\DOM::schemaValidateSource (   $source,
  $schematron = true 
)

Validates the current document against an XML schema, optionally validates embedded Schematron rules too.

Parameters
string$sourceSource of the XML schema to use for validation.
bool$schematron(optional) Whether embedded Schematron rules should be validated too (true) or not (false). The default is to also do $schematron validation.
Return values
booltrue if the document validates, false otherwise.

Definition at line 167 of file DOM.php.

Erebot\DOM::validate (   $schematron = false)

Validates the document against its DTD.

Parameters
bool$schematron(optional) The value of this parameter is currently unused as there is no way to embed Schematron rules into a DTD. This parameter is provided only to make the API uniform accross the different methods of this class.
Return values
booltrue if the document validates, false otherwise.
Note
This method is the same as the regular DomDocument::validate() method excepts that it captures errors so they can be later retrieved with the ::Erebot::DOM::DOM::getErrors() method.
There is currently no way to embed Schematron rules into a Document Type Declaration. Therefore, the value of the $schematron parameter is always ignored.

Definition at line 370 of file DOM.php.


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