src/Styling.php
protected static function parseTemplate($source)
    {
        $source =
            '<msg xmlns="http://www.erebot.net/xmlns/erebot/styling">'.
            $source.
            '</msg>';
        $schema = dirname(__DIR__) .
                    DIRECTORY_SEPARATOR . 'data' .
                    DIRECTORY_SEPARATOR . 'styling.rng';
        $dom    =   new \Erebot\DOM();
        $dom->substituteEntities    = true;
        $dom->resolveExternals      = false;
        $dom->recover               = true;
        $ue     = libxml_use_internal_errors(true);
        $dom->loadXML($source);
        $valid  = $dom->relaxNGValidate($schema);
        $errors = $dom->getErrors();
        libxml_use_internal_errors($ue);

        if (!$valid || count($errors)) {
            // Some unpredicted error occurred,
            // show some (hopefully) useful information.
            if (class_exists('\\Plop\\Plop')) {
                $logger = \Plop\Plop::getInstance();
                $logger->error(print_r($errors, true));
            }
            throw new \InvalidArgumentException(
                'Error while validating the message'
            );
        }
        return $dom;
    }
protected static function parseTemplate($source)
    {
        $source =
            '<msg xmlns="http://www.erebot.net/xmlns/erebot/styling">'.
            $source.
            '</msg>';
        $schema = dirname(__DIR__) .
                    DIRECTORY_SEPARATOR . 'data' .
                    DIRECTORY_SEPARATOR . 'styling.rng';
        $dom    =   new \Erebot\DOM();
        $dom->substituteEntities    = true;
        $dom->resolveExternals      = false;
        $dom->recover               = true;
        $ue     = libxml_use_internal_errors(true);
        $dom->loadXML($source);
        $valid  = $dom->relaxNGValidate($schema);
        $errors = $dom->getErrors();
        libxml_use_internal_errors($ue);

        if (!$valid || count($errors)) {
            // Some unpredicted error occurred,
            // show some (hopefully) useful information.
            if (class_exists('\\Plop\\Plop')) {
                $logger = \Plop\Plop::getInstance();
                $logger->error(print_r($errors, true));
            }
            throw new \InvalidArgumentException(
                'Error while validating the message'
            );
        }
        return $dom;
    }
protected static function parseTemplate ( $ source ) { $ source = '<msg xmlns="http://www.erebot.net/xmlns/erebot/styling">' . $ source . '</msg>' ; $ schema = dirname ( __DIR__ ) . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'styling.rng' ; $ dom = new \ Erebot \ DOM ( ) ; $ dom -> substituteEntities = true ; $ dom -> resolveExternals = false ; $ dom -> recover = true ; $ ue = libxml_use_internal_errors ( true ) ; $ dom -> loadXML ( $ source ) ; $ valid = $ dom -> relaxNGValidate ( $ schema ) ; $ errors = $ dom -> getErrors ( ) ; libxml_use_internal_errors ( $ ue ) ; if ( ! $ valid || count ( $ errors ) ) { // Some unpredicted error occurred, // show some (hopefully) useful information. if ( class_exists ( '\\Plop\\Plop' ) ) { $ logger = \ Plop \ Plop :: getInstance ( ) ; $ logger -> error ( print_r ( $ errors , true ) ) ; } throw new \ InvalidArgumentException ( 'Error while validating the message' ) ; } return $ dom ; }
Parses a template into a DOM.

\param string $source
Template to parse.

\retval Erebot::DOM
DOM object constructed
from the template.

\throw ::InvalidArgumentException
The template was malformed
or invalid.
Parses a template into a DOM .