An extension of PHP's DomDocument class that implements Schematron validation on top of RelaxNG/XML Schema.
More...
|
|
static | getNodeLineNo (array $nodes) |
| |
|
|
| $errors |
| | Stores the LibXMLError errors raised during validation.
|
| |
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.
| 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.
| 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
-
| array | Array 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 | $filename | Path 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
-
| bool | true 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 | $source | Source 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
-
| bool | true 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 | $source | Source of the Schematron rules:
- 'file' when $data refers to a filename.
- 'string' when $data refers to an in-memory string.
|
| string | $data | Schematron data. The interpretation of this parameter depends on the value of the $source parameter. |
| string | $schemaSource | The original schema type used to validate the document. This is "XSD" for XML Schema documents or "RNG" for RelaxNG schemas. |
| bool | $success | Whether the original validation process succeeded (true) or not (false). This is used to abort the Schematron validation process earlier. |
| bool | $schematron | Whether a Schematron validation pass should occur (true) or not (false). |
- Return values
-
| bool | Whether 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 | $filename | Path 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
-
| bool | true 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 | $source | Source 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
-
| bool | true 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
-
| bool | true 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: