当前位置: 首页>>代码示例>>PHP>>正文


PHP DomDocument::validate方法代码示例

本文整理汇总了PHP中DomDocument::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP DomDocument::validate方法的具体用法?PHP DomDocument::validate怎么用?PHP DomDocument::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DomDocument的用法示例。


在下文中一共展示了DomDocument::validate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testPageValid

	/**
	 * @dataProvider provider
	 */
	public function testPageValid ($page, $user)
	{
		if (!empty ($user)) $this->login ($user);
		$this->dispatch ($page);
		$dom = new DomDocument;
		Logger::get_logger ()->debug ($this->getResponse()->getBody());
		$dom->loadXML ($this->getResponse()->getBody(), LIBXML_DTDLOAD);
		$this->assertTrue ($dom->validate (), $this->getResponse()->getBody());
	}
开发者ID:rajatkhanduja,项目名称:opc,代码行数:12,代码来源:XHTMLValidationTest.php

示例2: validateXML

function validateXML($xmlFile)
{
    $dom = new DomDocument();
    $dom->load($xmlFile);
    if (@$dom->validate()) {
        echo $xmlFile . " valido<br/>";
    } else {
        echo $xmlFile . " no valido<br/>";
    }
}
开发者ID:Nilphy,项目名称:moteguardian,代码行数:10,代码来源:dtdcheck.php

示例3: HandleXmlError

<body>
<?php 
include 'stylearray.php';
//Denna rad inkluderar PHP-filen som styr layouten på sidan.
//Rad 10-32 används till DTD-valideringen!
function HandleXmlError($errno, $errstr, $errfile, $errline)
{
    echo $errno . " " . $errstr . "<br>";
}
$file = 'xdxf.xml';
$dom = new DomDocument();
$dom->preserveWhiteSpace = FALSE;
set_error_handler('HandleXmlError');
$loadstate = $dom->load($file);
if ($loadstate) {
    $validatestate = $dom->validate();
    if ($validatestate) {
        echo "<div class='validate'>Validation of DTD successful!</div>";
    } else {
        echo "<div class='validate'>Validation of DTD-test failed!</div><br/>";
    }
} else {
    echo "<div class='validate'>Well-formedness test Failed!</div><br/>";
}
restore_error_handler();
//Rad 35-40 används för att skapa layoutalternativstaggar som skall kunna väljas mellan.
echo "<div id='colors'>";
echo "Choose your preferred color-scheme: ";
while (list($key, $val) = each($styleSheets)) {
    echo "<a href='styleswitcher.php?SETSTYLE=" . $key . "'>" . $val["name"] . "</a> ";
}
开发者ID:emmiz,项目名称:xdxf,代码行数:31,代码来源:xdxf.php

示例4: validate

 /**
  * Validates the document against its DTD.
  *
  * \param 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.
  *
  * \retval bool
  *      \b true if the document validates,
  *      \b 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.
  *
  * \note
  *      There is currently no way to embed Schematron rules
  *      into a Document Type Declaration. Therefore, the
  *      value of the $schematron parameter is always ignored.
  */
 public function validate($schematron = false)
 {
     $success = parent::validate();
     $quiet = !libxml_use_internal_errors();
     if (!$quiet) {
         $this->errors = array_merge($this->errors, libxml_get_errors());
         libxml_clear_errors();
     }
     return $success;
 }
开发者ID:erebot,项目名称:dom,代码行数:34,代码来源:DOM.php

示例5: parse_spec_error

function parse_spec_error(&$info)
{
    global $message, $errortype, $fix, $xml, $history;
    // This means that the page was redirected from upload_spec.php and
    // indicates that an error occurred during specialisation. We can thus
    // try and parse the xml error message and inform the user.
    $error = $_SESSION['specerror'];
    // first check that there is actually an error message containing XML
    if ($error != '' && preg_match('/\\n\\<\\<\\n(.*?)\\>\\>\\n/s', $error, $matches)) {
        global $backend_dir;
        $dom = new DomDocument();
        $xml = "<?xml version='1.0' encoding='utf-8'?>\n" . "<!DOCTYPE error SYSTEM 'file://{$backend_dir}/error.dtd'>\n" . $matches[1];
        $dom->loadXML($xml);
        set_error_handler("validate_error_handler");
        if (!$dom->validate()) {
            ?>
<html><head>
			<link type="text/css" rel="stylesheet" href="xmlverbatim.css"/>
			</head><body><p><?php 
            global $validate_error;
            echo $validate_error;
            echo "</p>\n";
            echo process_xml($xml, 'xmlverbatim.xsl');
            echo "<p><b>XML does not validate!</b></p></body></html>";
            exit;
        }
        restore_error_handler();
        //echo process_xml($xml, 'xmlverbatim.xsl');
        $xml = simplexml_load_string($xml);
        // should be the following but it doesn't work!
        //$xml = simplexml_import_dom($dom);
        $message = (string) $xml->message;
        $errortype = (string) $xml->type;
        $problem = (string) $xml->problem;
        $fix = false;
        $info = array();
        if ($xml->xpath('programpoint')) {
            $pp = $xml->programpoint;
            $currentpred = (string) $pp->predicate;
            $currentpredarity = (string) $pp->predicate['arity'];
            $currentpredclause = (string) $pp->localclause;
            $annotation = (string) $pp->annotation;
            $path = '[';
            if ($xml->xpath('/error/programpoint/path')) {
                $path_xml = $xml->xpath('/error/programpoint/path/point');
                for ($i = 0; $i < count($path_xml); ++$i) {
                    $ann = (string) $path_xml[$i];
                    $arg = (string) $path_xml[$i]['arg'];
                    if ($i > 0) {
                        $path .= ', ';
                    }
                    $path .= "({$ann}, {$arg})";
                }
            }
            $path .= ']';
            $extra['ann'] = 'unsafe';
            $extra['pred'] = $currentpred;
            $extra['arity'] = $currentpredarity;
            $extra['clause'] = $currentpredclause;
            $extra['path'] = $path;
            if ($xml->xpath('/error/programpoint/correctann')) {
                if ($xml->xpath('/error/programpoint/correctann/annotation')) {
                    $extra['type'] = 'correctann';
                    $extra['fix'] = (string) $pp->correctann->annotation;
                    $fix = true;
                } else {
                    $extra['type'] = 'fix_hide_nf';
                    $fix = true;
                }
            } else {
                $extra['type'] = 'infoann';
            }
            $info[] = $extra;
        }
        if ($xml->xpath('filter')) {
            $f = $xml->filter;
            $extra = array();
            $extra['pred'] = (string) $f->predicate;
            $extra['arity'] = (string) $f->predicate['arity'];
            if ($xml->xpath('/error/filter/correctfilt')) {
                $make_dynamic = $xml->xpath('/error/filter/correctfilt/make_dynamic');
                if ($make_dynamic) {
                    if (count($info)) {
                        $info[0]['type'] = 'correctann';
                        $info[0]['fix'] = (string) $xml->programpoint->annotation;
                    }
                    $extra['type'] = 'correctfilt';
                    for ($i = 0; $i < count($make_dynamic); ++$i) {
                        $a = $extra;
                        $a['make_dyn'] = (string) $make_dynamic[$i];
                        $info[] = $a;
                    }
                    $fix = true;
                } else {
                    $extra['type'] = 'replacefilt';
                    $extra['newfilt'] = $xml->filter->correctfilt->replace_filt;
                    $fix = true;
                    $info[] = $extra;
                }
            } else {
//.........这里部分代码省略.........
开发者ID:jfmc,项目名称:logen,代码行数:101,代码来源:annerrors.php

示例6: assertValid

 /**
  * Make sure response content HTML passes DTD validation
  *  this doesn't seem to work with HTML 4.01 Trans.
  *
  * {{code: php
  *  ...
  *  $this->assertValid();
  *  ...
  *  ?>
  * }}
  *
  * @param   string  $msg
  */
 public function assertValid($msg = null)
 {
     $responseBody = $this->response->getBody();
     $dom = new DomDocument();
     $dom->loadHTML($responseBody);
     $this->assertTrue($dom->validate(), $msg);
 }
开发者ID:lerre,项目名称:framework,代码行数:20,代码来源:Functional.php


注:本文中的DomDocument::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。