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


PHP DomDocument::schemaValidateSource方法代码示例

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


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

示例1: validate

 /**
  * That validate function takes an XSD to valid against `$this->_xml`
  * returning boolean. Optionally, a second parameter `$xml` can be
  * passed that will be used instead of `$this->_xml`.
  *
  * @since Symphony 2.3
  * @param string $xsd
  *  The XSD to validate `$this->_xml` against
  * @param string $xml (optional)
  *  If provided, this function will use this `$xml` instead of
  *  `$this->_xml`.
  * @return boolean
  *  Returns true if the `$xml` validates against `$xsd`, false otherwise.
  *  If false is returned, the errors can be obtained with `XSLTProcess->getErrors()`
  */
 public function validate($xsd, $xml = null)
 {
     if (is_null($xml) && !is_null($this->_xml)) {
         $xml = $this->_xml;
     }
     if (is_null($xsd) || is_null($xml)) {
         return false;
     }
     // Create instances of the DomDocument class
     $xmlDoc = new DomDocument();
     // Set up error handling
     if (function_exists('ini_set')) {
         $ehOLD = ini_set('html_errors', false);
     }
     // Load the xml document
     set_error_handler(array($this, 'trapXMLError'));
     $elOLD = libxml_disable_entity_loader(true);
     $xmlDoc->loadXML($xml, LIBXML_NONET | LIBXML_DTDLOAD | LIBXML_DTDATTR | defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0);
     libxml_disable_entity_loader($elOLD);
     // Must restore the error handler to avoid problems
     restore_error_handler();
     // Validate the XML against the XSD
     set_error_handler(array($this, 'trapXSDError'));
     $result = $xmlDoc->schemaValidateSource($xsd);
     // Restore error handling
     if (function_exists('ini_set') && isset($ehOLD)) {
         ini_set('html_errors', $ehOLD);
     }
     // Must restore the error handler to avoid problems
     restore_error_handler();
     return $result;
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:47,代码来源:class.xsltprocess.php

示例2: schemaValidateSource

 /**
  * Validates the current document against an XML schema,
  * optionally validates embedded Schematron rules too.
  *
  * \param string $source
  *      Source of the XML schema to use for validation.
  *
  * \param bool $schematron
  *      (optional) Whether embedded Schematron rules
  *      should be validated too (\b true) or not (\b false).
  *      The default is to also do $schematron validation.
  *
  * \retval bool
  *      \b true if the document validates,
  *      \b false otherwise.
  */
 public function schemaValidateSource($source, $schematron = true)
 {
     $success = parent::schemaValidateSource($source);
     return $this->schematronValidation('string', $source, 'XSD', $success, $schematron);
 }
开发者ID:erebot,项目名称:dom,代码行数:21,代码来源:DOM.php

示例3: DomDocument

        $doc = new DomDocument();
        $doc->loadXML(stripslashes($_POST['xml']));
        $xmlout = htmlspecialchars(stripslashes($_POST['xml']));
    }
    if ((!isset($doc) || isset($_REQUEST['itype']) && $_REQUEST['itype'] == 'url') && preg_match('%^https?://%', $_REQUEST['uri'])) {
        $xmlFile = $_REQUEST['uri'];
        $doc = new DomDocument();
        $xmlout = file_get_contents($xmlFile);
        $doc->loadXML($xmlout);
        //$doc->load( $xmlFile );
        $xmlout = htmlspecialchars($xmlout);
    }
    if (isset($doc)) {
        $xsd = file_get_contents($xsdURI);
        set_error_handler('err_handler');
        if ($doc->schemaValidateSource($xsd)) {
            $result .= "XML is valid.";
        } else {
            $result .= "XML is <em>NOT</em> valid.";
        }
    } else {
        $result = "XML File specified is not valid.";
    }
    echo '<div class="result">' . $result . '</div>';
}
if (!isset($xmlout)) {
    $xmlout = '';
}
?>

<div>Schema used for validation is: <a href="<?php 
开发者ID:habari,项目名称:scripts,代码行数:31,代码来源:pluggable_validator.php

示例4: schemaValidate

 private function schemaValidate(\DomDocument $dom, $xsd)
 {
     try {
         $dom->schemaValidateSource($xsd);
         $this->throwError();
     } catch (\DOMException $e) {
         throw new \RuntimeException($e->getMessage());
     }
 }
开发者ID:ducbin,项目名称:behatch-contexts,代码行数:9,代码来源:XmlContext.php


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