本文整理汇总了PHP中DomDocument::relaxNGValidateSource方法的典型用法代码示例。如果您正苦于以下问题:PHP DomDocument::relaxNGValidateSource方法的具体用法?PHP DomDocument::relaxNGValidateSource怎么用?PHP DomDocument::relaxNGValidateSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomDocument
的用法示例。
在下文中一共展示了DomDocument::relaxNGValidateSource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: relaxNGValidateSource
/**
* Validates the current document against a RelaxNG schema,
* optionally validates embedded Schematron rules too.
*
* \param string $source
* Source of 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 relaxNGValidateSource($source, $schematron = true)
{
$success = parent::relaxNGValidateSource($source);
return $this->schematronValidation('string', $source, 'RNG', $success, $schematron);
}
示例2: __construct
/**
* Constructs a new ezcTreeXml object from the XML data in $xmlFile and using
* the $store to retrieve data from.
*
* @param string $xmlFile
* @param ezcTreeXmlDataStore $store
*/
public function __construct($xmlFile, ezcTreeXmlDataStore $store)
{
if (!file_exists($xmlFile)) {
throw new ezcBaseFileNotFoundException($xmlFile, "XML");
}
$previous = libxml_use_internal_errors(true);
$dom = new DomDocument();
$dom->load($xmlFile);
$dom->formatOutput = true;
$errors = libxml_get_errors();
libxml_clear_errors();
if (count($errors)) {
throw new ezcTreeInvalidXmlException($xmlFile, $errors);
}
$valid = $dom->relaxNGValidateSource(self::relaxNG);
if (!$valid) {
$errors = libxml_get_errors();
libxml_clear_errors();
throw new ezcTreeInvalidXmlFormatException($xmlFile, $errors);
}
libxml_use_internal_errors($previous);
// Associate the DOM tree with the data store
$store->setDomTree($dom);
// Figure out the prefix - which is the "prefix" attribute on the root node.
$document = $dom->documentElement;
$prefix = $document->getAttribute('prefix');
// Figure out the last auto generated ID
$autoId = false;
$this->autoNodeId = $document->getAttribute('lastNodeId');
if ($this->autoNodeId !== "") {
$autoId = true;
}
// Set member variables
$this->dom = $dom;
$this->xmlFile = $xmlFile;
$this->properties['store'] = $store;
$this->properties['prefix'] = $prefix;
$this->properties['autoId'] = $autoId;
}
示例3: relaxNGValidate
private function relaxNGValidate(\DomDocument $dom, $ng)
{
try {
$dom->relaxNGValidateSource($ng);
$this->throwError();
} catch (\DOMException $e) {
throw new \RuntimeException($e->getMessage());
}
}