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


PHP XMLReader::setRelaxNGSchema方法代码示例

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


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

示例1: parse

 /**
  * Creates a Map of devices from the xml file
  *
  * @param string $fileName path to the xml file to parse
  * @return Map of <deviceId ModelDevice>
  */
 public static function parse($fileName, $validationSchema)
 {
     $devicesMap = array();
     $deviceID = null;
     $groupID = null;
     $reader = new XMLReader();
     $reader->open($fileName);
     $fullFileName = dirname(__FILE__) . DIRECTORY_SEPARATOR . $validationSchema;
     $reader->setRelaxNGSchema($fullFileName);
     libxml_use_internal_errors(TRUE);
     while ($reader->read()) {
         if (!$reader->isValid()) {
             throw new Exception(libxml_get_last_error()->message);
         }
         $nodeName = $reader->name;
         switch ($reader->nodeType) {
             case XMLReader::ELEMENT:
                 switch ($nodeName) {
                     case WURFL_Xml_Interface::DEVICE:
                         $groupIDCapabilitiesMap = array();
                         $deviceID = $reader->getAttribute(WURFL_Xml_Interface::ID);
                         $userAgent = $reader->getAttribute(WURFL_Xml_Interface::USER_AGENT);
                         $fallBack = $reader->getAttribute(WURFL_Xml_Interface::FALL_BACK);
                         $actualDeviceRoot = $reader->getAttribute(WURFL_Xml_Interface::ACTUAL_DEVICE_ROOT);
                         $currentCapabilityNameValue = array();
                         if ($reader->isEmptyElement) {
                             $device = new WURFL_Xml_ModelDevice($deviceID, $userAgent, $fallBack, $actualDeviceRoot);
                             $devicesMap[$deviceID] = $device;
                         }
                         break;
                     case WURFL_Xml_Interface::GROUP:
                         $groupID = $reader->getAttribute(WURFL_Xml_Interface::GROUP_ID);
                         $groupIDCapabilitiesMap[$groupID] = array();
                         break;
                     case WURFL_Xml_Interface::CAPABILITY:
                         $capabilityName = $reader->getAttribute(WURFL_Xml_Interface::CAPABILITY_NAME);
                         $capabilityValue = $reader->getAttribute(WURFL_Xml_Interface::CAPABILITY_VALUE);
                         $currentCapabilityNameValue[$capabilityName] = $capabilityValue;
                         $groupIDCapabilitiesMap[$groupID][$capabilityName] = $capabilityValue;
                         break;
                 }
                 break;
             case XMLReader::END_ELEMENT:
                 if ($nodeName == WURFL_Xml_Interface::DEVICE) {
                     $device = new WURFL_Xml_ModelDevice($deviceID, $userAgent, $fallBack, $actualDeviceRoot, $groupIDCapabilitiesMap);
                     $devicesMap[$device->id] = $device;
                 }
                 break;
         }
     }
     // end of while
     $reader->close();
     return $devicesMap;
 }
开发者ID:eusholli,项目名称:drupal,代码行数:60,代码来源:ParserUtil.php

示例2: _getReader

 protected function _getReader($data, $request)
 {
     if (!is_bool($request)) {
     }
     /// @TODO
     $this->_currentNode = NULL;
     $reader = new XMLReader();
     $reader->xml($data, NULL, LIBXML_NONET | LIBXML_NOENT);
     if ($this->_validate) {
         if ('@data_dir@' != '@' . 'data_dir' . '@') {
             $schema = '@data_dir@' . DIRECTORY_SEPARATOR . 'pear.erebot.net' . DIRECTORY_SEPARATOR . 'XRL';
         } else {
             $schema = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'data';
         }
         $schema .= DIRECTORY_SEPARATOR;
         $schema .= $request ? 'request.rng' : 'response.rng';
         $reader->setRelaxNGSchema($schema);
     }
     return $reader;
 }
开发者ID:inscriptionweb,项目名称:PhotoShow,代码行数:20,代码来源:Decoder.php

示例3: chr

<?php

$file = '/etc/passwd' . chr(0) . 'asdf';
$reader = new XMLReader();
var_dump($reader->open($file));
var_dump($reader->setRelaxNGSchema($file));
开发者ID:RavuAlHemio,项目名称:hhvm,代码行数:6,代码来源:xmlreader_null_byte.php

示例4: while

    while ($reader->read()) {
    }
}
if ($reader->isValid()) {
    print "file relaxNG: ok\n";
} else {
    print "file relaxNG: failed\n";
}
$reader->close();
unlink($file);
$reader = new XMLReader();
$reader->XML($xmlstring);
if ($reader->setRelaxNGSchema($relaxngfile)) {
    while ($reader->read()) {
    }
}
if ($reader->isValid()) {
    print "string relaxNG: ok\n";
} else {
    print "string relaxNG: failed\n";
}
$reader->close();
$reader = new XMLReader();
$reader->XML($xmlstring);
if ($reader->setRelaxNGSchema('')) {
    echo 'failed';
}
$reader->close();
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:30,代码来源:007.php

示例5: XMLReader

<?php

$indent = 5;
/* Number of spaces to indent per level */
$reader = new XMLReader();
$reader->open('relaxNG.xml');
/*
Example setting relaxNG using string:
$reader->setRelaxNGSchemaSource(file_get_contents('relaxNG.rng'));
*/
if ($reader->setRelaxNGSchema('relaxNG.rng')) {
    while ($reader->read()) {
        /* Print node name indenting it based on depth and $indent var */
        print str_repeat(" ", $reader->depth * $indent) . $reader->name . "\n";
    }
}
print "\n";
if (!$reader->isValid()) {
    print "Document is not valid\n";
} else {
    print "Document is valid\n";
}
开发者ID:cefalo19,项目名称:php-src,代码行数:22,代码来源:xmlreader_relaxNG.php

示例6: getReader

 /**
  * Returns an XML reader for some data.
  *
  * \param string $URI
  *      URI to the XML data to process.
  *
  * \param bool $request
  *      Whether the data refers to an XML-RPC
  *      request (\c true) or a response (\c false).
  *
  * \retval XMLReader
  *      An XML reader for the given data.
  *
  * \throw InvalidArgumentException
  *      You tried to pass something that is not
  *      a boolean as the \c $request parameter.
  *
  * \note
  *      The reader is set to validate the document
  *      on the fly if that's what this decoder was
  *      configured to do during construction.
  */
 protected function getReader($URI, $request)
 {
     if (!is_string($URI)) {
         throw new \InvalidArgumentException('Not a string');
     }
     if (!is_bool($request)) {
         throw new \InvalidArgumentException('Not a boolean');
     }
     $this->currentNode = null;
     $reader = new \XMLReader();
     $reader->open($URI, null, LIBXML_NONET | LIBXML_NOENT);
     if ($this->validate) {
         $schema = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR;
         $schema .= $request ? 'request.rng' : 'response.rng';
         $reader->setRelaxNGSchema($schema);
     }
     return $reader;
 }
开发者ID:fpoirotte,项目名称:xrl,代码行数:40,代码来源:Decoder.php

示例7: validateString

 /**
  * validates the xml string
  *
  * @return boolean true if the xml string is valid
  * @access private
  */
 private function validateString($xml_feed_string)
 {
     $reader = new XMLReader();
     $reader->XML($xml_feed_string);
     if ($reader->setRelaxNGSchema(RELAX_NG_IMPORT_SCHEMA)) {
         while ($reader->read()) {
         }
     }
     if (!$reader->isValid()) {
         return false;
     }
     $reader->close();
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:medialib-svn,代码行数:20,代码来源:HgkMediaLib_MetaDataFeed.php

示例8: setRelaxNGSchema

 public function setRelaxNGSchema($filename)
 {
     return parent::setRelaxNGSchema($filename);
 }
开发者ID:philip,项目名称:phd,代码行数:4,代码来源:Reader.php


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