Swat/SwatXHTMLTextarea.php
protected function getValidationErrorMessage(array $xml_errors)
    {
        $ignored_errors = array(
            'extra content at the end of the document',
            'premature end of data in tag html',
            'opening and ending tag mismatch between html and body',
            'opening and ending tag mismatch between body and html'
        );

        $errors = array();
        foreach ($xml_errors as $error_object) {
            $error = $error_object->message;

            // further humanize
            $error = str_replace(
                'tag mismatch:',
                Swat::_('tag mismatch between'),
                $error
            );

            // remove some stuff that only makes sense in document context
            $error = preg_replace('/\s?line:? [0-9]+\s?/ui', ' ', $error);
            $error = preg_replace('/in entity[:,.]?/ui', '', $error);
            $error = mb_strtolower($error);

            $error = str_replace(
                'xmlparseentityref: no name',
                Swat::_('unescaped ampersand. Use &amp;amp; instead of &amp;'),
                $error
            );

            $error = str_replace(
                'starttag: invalid element name',
                Swat::_('unescaped less-than. Use &amp;lt; instead of &lt;'),
                $error
            );

            $error = str_replace(
                'specification mandate value for attribute',
                Swat::_('a value is required for the attribute'),
                $error
            );

            $error = preg_replace(
                '/^no declaration for attribute (.*?) of element (.*?)$/',
                Swat::_('the attribute \1 is not valid for the element \2'),
                $error
            );

            $error = str_replace(
                'attvalue: " or \' expected',
                Swat::_(
                    'attribute values must be contained within quotation ' .
                        'marks'
                ),
                $error
            );

            $error = trim($error);

            if (!in_array($error, $ignored_errors)) {
                $errors[] = $error;
            }
        }

        $content = Swat::_('%s must be valid XHTML markup: ');
        $content .= '<ul><li>' . implode(',</li><li>', $errors) . '.</li></ul>';
        $message = new SwatMessage($content, 'error');
        $message->content_type = 'text/xml';

        return $message;
    }
protected function getValidationErrorMessage(array $xml_errors)
    {
        $ignored_errors = array(
            'extra content at the end of the document',
            'premature end of data in tag html',
            'opening and ending tag mismatch between html and body',
            'opening and ending tag mismatch between body and html'
        );

        $errors = array();
        foreach ($xml_errors as $error_object) {
            $error = $error_object->message;

            // further humanize
            $error = str_replace(
                'tag mismatch:',
                Swat::_('tag mismatch between'),
                $error
            );

            // remove some stuff that only makes sense in document context
            $error = preg_replace('/\s?line:? [0-9]+\s?/ui', ' ', $error);
            $error = preg_replace('/in entity[:,.]?/ui', '', $error);
            $error = mb_strtolower($error);

            $error = str_replace(
                'xmlparseentityref: no name',
                Swat::_('unescaped ampersand. Use &amp;amp; instead of &amp;'),
                $error
            );

            $error = str_replace(
                'starttag: invalid element name',
                Swat::_('unescaped less-than. Use &amp;lt; instead of &lt;'),
                $error
            );

            $error = str_replace(
                'specification mandate value for attribute',
                Swat::_('a value is required for the attribute'),
                $error
            );

            $error = preg_replace(
                '/^no declaration for attribute (.*?) of element (.*?)$/',
                Swat::_('the attribute \1 is not valid for the element \2'),
                $error
            );

            $error = str_replace(
                'attvalue: " or \' expected',
                Swat::_(
                    'attribute values must be contained within quotation ' .
                        'marks'
                ),
                $error
            );

            $error = trim($error);

            if (!in_array($error, $ignored_errors)) {
                $errors[] = $error;
            }
        }

        $content = Swat::_('%s must be valid XHTML markup: ');
        $content .= '<ul><li>' . implode(',</li><li>', $errors) . '.</li></ul>';
        $message = new SwatMessage($content, 'error');
        $message->content_type = 'text/xml';

        return $message;
    }
protected function getValidationErrorMessage ( array $ xml_errors ) { $ ignored_errors = array ( 'extra content at the end of the document' , 'premature end of data in tag html' , 'opening and ending tag mismatch between html and body' , 'opening and ending tag mismatch between body and html' ) ; $ errors = array ( ) ; foreach ( $ xml_errors as $ error_object ) { $ error = $ error_object -> message ; // further humanize $ error = str_replace ( 'tag mismatch:' , Swat :: _ ( 'tag mismatch between' ) , $ error ) ; // remove some stuff that only makes sense in document context $ error = preg_replace ( '/\s?line:? [0-9]+\s?/ui' , ' ' , $ error ) ; $ error = preg_replace ( '/in entity[:,.]?/ui' , '' , $ error ) ; $ error = mb_strtolower ( $ error ) ; $ error = str_replace ( 'xmlparseentityref: no name' , Swat :: _ ( 'unescaped ampersand. Use &amp;amp; instead of &amp;' ) , $ error ) ; $ error = str_replace ( 'starttag: invalid element name' , Swat :: _ ( 'unescaped less-than. Use &amp;lt; instead of &lt;' ) , $ error ) ; $ error = str_replace ( 'specification mandate value for attribute' , Swat :: _ ( 'a value is required for the attribute' ) , $ error ) ; $ error = preg_replace ( '/^no declaration for attribute (.*?) of element (.*?)$/' , Swat :: _ ( 'the attribute \1 is not valid for the element \2' ) , $ error ) ; $ error = str_replace ( 'attvalue: " or \' expected' , Swat :: _ ( 'attribute values must be contained within quotation ' . 'marks' ) , $ error ) ; $ error = trim ( $ error ) ; if ( ! in_array ( $ error , $ ignored_errors ) ) { $ errors [ ] = $ error ; } } $ content = Swat :: _ ( '%s must be valid XHTML markup: ' ) ; $ content .= '<ul><li>' . implode ( ',</li><li>' , $ errors ) . '.</li></ul>' ; $ message = new SwatMessage ( $ content , 'error' ) ; $ message -> content_type = 'text/xml' ; return $ message ; }
Gets a human readable error message for XHTML validation errors on
this textarea's value

@param array $xml_errors an array of LibXMLError objects.

@return SwatMessage a human readable error message for XHTML validation
errors on this textarea's value.
Gets a human readable error message for XHTML validation errors on this textarea s value