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


PHP DomDocument::relaxNGValidate方法代码示例

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


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

示例1: validate

 /**
  * Validates the xml definition using Relax NG.
  *
  * @param DomDocument $doc The document to validate
  *
  * @return boolean Whether the xml data is valid or not.
  * @throws Console_CommandLine_Exception
  * @todo use exceptions
  */
 public static function validate($doc)
 {
     if (is_dir('C:\\php\\pear\\data' . DIRECTORY_SEPARATOR . 'Console_CommandLine')) {
         $rngfile = 'C:\\php\\pear\\data' . DIRECTORY_SEPARATOR . 'Console_CommandLine' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'xmlschema.rng';
     } else {
         $rngfile = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'xmlschema.rng';
     }
     if (!is_readable($rngfile)) {
         Console_CommandLine::triggerError('invalid_xml_file', E_USER_ERROR, array('{$file}' => $rngfile));
     }
     return $doc->relaxNGValidate($rngfile);
 }
开发者ID:EmmanuelFernando,项目名称:rapport-stock-control,代码行数:21,代码来源:XmlParser.php

示例2: DomDocument

}
if (empty($data)) {
    ajax_error('Cannot accept empty form data.');
}
$config = new \NRG\Configuration(CONFIG_FILE);
try {
    $rng = null;
    //Register a new error handler to handle libxml specific errors
    $originalHandler = set_error_handler("libxml_error_handler");
    //Create a new DomDocument object and load the XML data into it
    $xmldata = new DomDocument();
    $xmldata->loadXML($data, LIBXML_NOBLANKS | LIBXML_NOCDATA | LIBXML_NOENT);
    //Remove whitespaces from the data
    purifyXML($xmldata->documentElement);
    //Validate the data received
    $valid = $xmldata->relaxNGValidate(SCHEMA_DIR . $schemaName . SCHEMA_EXT);
    //Restore the original error handler
    set_error_handler($originalHandler);
    if ($valid === false) {
        ajax_error('Schema validation failed');
    }
    //Should not see this because of the error handler
    //Retrieve the database configuration
    $dbconf = $config->Database;
    //Make sure the username is registered with this application
    $db = new Database($dbconf['host'], $dbconf['user'], $dbconf['pass'], $dbconf['name'], $dbconf['port']);
    $session = $db->searchSession($session);
    if (empty($session)) {
        ajax_error('Could not find your session id in the database.');
    }
    $db->storeForm($schemaName, $session['id'], $xmldata->saveXML());
开发者ID:nithin8702,项目名称:onlinescoring,代码行数:31,代码来源:saveform.php

示例3: validate

 /**
  * Validates the xml definition using Relax NG.
  *
  * @param DomDocument $doc The document to validate
  *
  * @return boolean Whether the xml data is valid or not.
  * @throws Console_CommandLine_Exception
  * @todo use exceptions
  */
 public static function validate($doc)
 {
     $pkgRoot = __DIR__ . '/../../';
     $paths = array('@data_dir@/Console_CommandLine/data/xmlschema.rng', $pkgRoot . 'data/Console_CommandLine/data/xmlschema.rng', $pkgRoot . 'data/console_commandline/data/xmlschema.rng', $pkgRoot . 'data/xmlschema.rng', 'xmlschema.rng');
     foreach ($paths as $path) {
         if (is_readable($path)) {
             return $doc->relaxNGValidate($path);
         }
     }
     Console_CommandLine::triggerError('invalid_xml_file', E_USER_ERROR, array('{$file}' => $rngfile));
 }
开发者ID:pear,项目名称:console_commandline,代码行数:20,代码来源:XmlParser.php

示例4: relaxNGValidate

 /**
  * Validates the current document against a RelaxNG schema,
  * optionally validates embedded Schematron rules too.
  *
  * \param string $filename
  *      Path to the RelaxNG 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 relaxNGValidate($filename, $schematron = true)
 {
     $success = parent::relaxNGValidate($filename);
     return $this->schematronValidation('file', $filename, 'RNG', $success, $schematron);
 }
开发者ID:erebot,项目名称:dom,代码行数:21,代码来源:DOM.php

示例5: validate

 /**
  * Validates the xml definition using Relax NG.
  *
  * @param DomDocument $doc The document to validate
  *
  * @return boolean Whether the xml data is valid or not.
  * @throws PEAR2\Console\CommandLine\Exception
  * @todo use exceptions only
  */
 public static function validate($doc)
 {
     $rngfile = __DIR__ . '/../../../../data/pear2.php.net/PEAR2_Console_CommandLine/xmlschema.rng';
     if (!is_file($rngfile)) {
         $rngfile = __DIR__ . '/../../../../data/xmlschema.rng';
     }
     if (!is_readable($rngfile)) {
         CommandLine::triggerError('invalid_xml_file', E_USER_ERROR, array('{$file}' => $rngfile));
     }
     return $doc->relaxNGValidate($rngfile);
 }
开发者ID:slrondon,项目名称:MikrotikCenter,代码行数:20,代码来源:XmlParser.php

示例6: loadAPI

 /**
  * Loads the XML API definition.
  *
  * @return void
  */
 protected function loadAPI()
 {
     // initialize xml mapping
     $p = is_dir('@data_dir@') ? array('@data_dir@', 'Services_Twitter', 'data') : array(dirname(__FILE__), '..', 'data');
     $d = implode(DIRECTORY_SEPARATOR, $p) . DIRECTORY_SEPARATOR;
     if ($this->getOption('validate') && class_exists('DomDocument')) {
         // this should be done only when testing
         $doc = new DomDocument();
         $doc->load($d . 'api.xml');
         $doc->relaxNGValidate($d . 'api.rng');
     }
     $xmlApi = simplexml_load_file($d . 'api.xml');
     foreach ($xmlApi->category as $category) {
         $catName = (string) $category['name'];
         $this->api[$catName] = array();
         foreach ($category->endpoint as $endpoint) {
             $this->api[$catName][(string) $endpoint['name']] = $endpoint;
         }
     }
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:25,代码来源:Twitter.php

示例7: validate

 /**
  * Validates the xml definition using Relax NG.
  *
  * @param DomDocument $doc The document to validate
  *
  * @return boolean Whether the xml data is valid or not.
  * @throws Console_CommandLine_Exception
  * @todo use exceptions
  */
 public static function validate($doc) 
 {
     if (is_dir('/Users/nojima/Sites/workspace/twitter2mixi/extlibs/pear/data' . DIRECTORY_SEPARATOR . 'Console_CommandLine')) {
         $rngfile = '/Users/nojima/Sites/workspace/twitter2mixi/extlibs/pear/data' . DIRECTORY_SEPARATOR
             . 'Console_CommandLine' . DIRECTORY_SEPARATOR . 'data' 
             . DIRECTORY_SEPARATOR . 'xmlschema.rng';
     } else {
         $rngfile = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' 
             . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data'
             . DIRECTORY_SEPARATOR . 'xmlschema.rng';
     }
     if (!is_readable($rngfile)) {
         Console_CommandLine::triggerError('invalid_xml_file',
             E_USER_ERROR, array('{$file}' => $rngfile));
     }
     return $doc->relaxNGValidate($rngfile);
 }
开发者ID:nojimage,项目名称:twitter2mixivoice,代码行数:26,代码来源:XmlParser.php

示例8: validate

 /**
  * Static helper function to validate document against a schema
  * @param string
  * @param string
  * @param boolean
  */
 public static function validate($xml, $schema, $relax = false)
 {
     $doc = new \DomDocument();
     set_error_handler(function ($errNo, $errMsg) {
         restore_error_handler();
         $errMsg = preg_replace('#^.*error :#', '', $errMsg);
         throw new DOMException($errMsg);
     });
     $doc->loadXML($xml);
     $validation = $relax ? $doc->relaxNGValidate($schema) : $doc->schemaValidate($schema);
     restore_error_handler();
     return $validation;
 }
开发者ID:oaki,项目名称:demoshop,代码行数:19,代码来源:DOM.php


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