本文整理汇总了PHP中DOMDocument::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMDocument::validate方法的具体用法?PHP DOMDocument::validate怎么用?PHP DOMDocument::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMDocument
的用法示例。
在下文中一共展示了DOMDocument::validate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validates the XML of this template.
* @returns boolean true on sucess
*/
public function validate()
{
if ($this->working_dir !== null) {
$dir = getcwd();
chdir($this->working_dir);
}
libxml_use_internal_errors(true);
if (!$this->doc->validate()) {
$this->raiseError($this->xmlError(libxml_get_errors(), "Invalid XML Configuration"));
if ($this->working_dir !== null) {
chdir($dir);
}
return false;
}
libxml_clear_errors();
if (count($errors) > 0) {
$this->raiseError("Invalid XML Configuaration");
if ($this->working_dir !== null) {
chdir($dir);
}
return false;
}
if ($this->working_dir !== null) {
chdir($dir);
}
libxml_use_internal_errors(false);
return true;
}
示例2: setup
/**
* @throws SMSConfigurationException
* @version : v0.1
*/
public function setup()
{
$fileNamespace = $this->getXMLFileNamespace();
$vendor = RootClassLoader::getVendor($fileNamespace);
$libPath = RootClassLoader::getLoaderByVendor($vendor)->getRootPath();
$basePath = str_replace('\\', '/', RootClassLoader::getNamespaceWithoutVendor($fileNamespace));
$filename = $this->getXMLFilename();
$fullPath = $libPath . (empty($basePath) ? '' : '/' . $basePath) . '/' . $filename;
if (!file_exists($fullPath)) {
throw new SMSConfigurationException('[SMSXMLMapper::setup()] XML file "' . $filename . '" in namespace "' . $fileNamespace . '" could not be found. (Full path: "' . $fullPath . '").', E_USER_ERROR);
}
$this->XML_DOMDocument = new \DOMDocument();
$this->XML_DOMDocument->load($fullPath);
// we need to validate the document, to let the DTD be parsed and the id attribute be recognized as id by DOMDocument::getElementById().
// do not care about failures this time
$this->XML_DOMDocument->validate();
}
示例3: testSpecialCharsFillinValidXhtml
public function testSpecialCharsFillinValidXhtml()
{
$this->form->bind(array('username' => '&<>&', 'password' => '&%$""<>'));
$xhtml = $this->xhtmlDecl . $this->form->__toString();
$doc = new DOMDocument();
$doc->loadXML($xhtml);
$this->assertTrue($doc->validate(), 'The rendered form is valid xhtml');
}
示例4: xmlValidateDTD
/**
* Validated the current document against the defined DTD
*
* @return bool
*/
public function xmlValidateDTD()
{
if ($this->objDocument != null) {
if ($this->objDocument->validate() !== false) {
return true;
}
}
return false;
}
示例5: validate_xml
/**
* Validate an XML document which is bound to a DTD.
*
* @param (string) $filename - The name of the XML document
* @return (string) - Results of the validation
*/
function validate_xml($filename)
{
$doc = new DOMDocument();
$doc->validateOnParse = true;
libxml_use_internal_errors(true);
$doc->load($filename);
if ($doc->validate()) {
return 'The XML document "' . $filename . '" has validated successfully.';
} else {
$result = "<b>Oh nooooo...</b><br/>";
foreach (libxml_get_errors() as $error) {
$result .= $error->message . '<br/>';
}
libxml_clear_errors();
return $result;
}
}
示例6: validate
private function validate()
{
libxml_use_internal_errors(true);
shopYandexmarketPlugin::path('shops.dtd');
$this->loadDom($this->data['path']['offers']);
$valid = @$this->dom->validate();
$strict = waSystemConfig::isDebug();
if ((!$valid || $strict) && ($r = libxml_get_errors())) {
$this->data['error'] = array();
$error = array();
if ($valid) {
$this->data['error'][] = array('level' => 'info', 'message' => 'YML-файл валиден');
} else {
$this->data['error'][] = array('level' => 'error', 'message' => 'YML-файл содержит ошибки');
}
foreach ($r as $er) {
/**
* @var libXMLError $er
*/
$level_name = '';
switch ($er->level) {
case LIBXML_ERR_WARNING:
$level_name = 'LIBXML_ERR_WARNING';
break;
case LIBXML_ERR_ERROR:
$level_name = 'LIBXML_ERR_ERROR';
break;
case LIBXML_ERR_FATAL:
$level_name = 'LIBXML_ERR_FATAL';
break;
}
if ($er->code != 505) {
$this->data['error'][] = array('level' => $valid ? 'warning' : 'error', 'message' => "{$level_name} #{$er->code} [{$er->line}:{$er->column}]: {$er->message}");
}
$error[] = "Error #{$er->code}[{$er->level}] at [{$er->line}:{$er->column}]: {$er->message}";
}
if ($valid && count($this->data['error']) == 1) {
$this->data['error'] = array();
}
$this->error(implode("\n\t", $error));
}
}
示例7: getContent
function getContent()
{
$this->mContent = null;
$source = $this->mSource;
$source = str_replace('class="padded"', 'id="confluence_content"', $source);
// add DTD
$dtd = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
$source = $dtd . $source;
$dom = new DOMDocument();
echo "Loading document... ";
$status = $dom->loadHTML($source);
$this->msgStatus($status);
$this->msg("Validating document... ");
$dom->validate();
$this->msgStatus(true);
// we don't really care if it validates or not ;)
$this->msg("Looking for node... ");
$node = $dom->getElementById('confluence_content');
$this->msgStatus((bool) $node);
$this->mContent = $dom->saveXML($node);
return (bool) $this->mContent;
}
示例8: getInstance
public static function getInstance($path)
{
global $plugin;
$plugin = $path;
if (!self::$obj instanceof self) {
self::$obj = new self();
$dom = new DOMDocument();
$dom->load(dirname(__FILE__) . "/{$path}/actions.xml");
if (@$dom->validate()) {
$packages = $dom->getElementsByTagName("package");
foreach ($packages as $package) {
$actions = $package->getElementsByTagName('action');
$action_tem = array();
foreach ($actions as $action) {
$action_tem['file'] = $action->getAttributeNode('file')->value;
unset($action_tem['class']);
if ($action->hasAttribute('class')) {
$action_tem['class'] = $action->getAttributeNode('class')->value;
}
$action_tem['method'] = $action->getAttributeNode('method')->value;
$returns = $action->getElementsByTagName('return');
$return_tem = array();
foreach ($returns as $return) {
$return_tem[$return->getAttributeNode('name')->value] = $return->nodeValue;
}
$action_tem['returns'] = $return_tem;
self::$action_info[$package->getAttributeNode('name')->value . '_' . $action->getAttributeNode('name')->value] = $action_tem;
}
// var_dump( self::$action_info);
}
} else {
echo "此XML文件不符合规范!";
exit;
}
}
return self::$obj;
}
示例9: checkType
/**
* @copydoc TypeDescription::checkType()
*/
function checkType(&$object)
{
// We only accept DOMDocument objects and source strings.
if (!is_a($object, 'DOMDocument') && !is_string($object)) {
return false;
}
// No validation...
if ($this->_validationStrategy == XML_TYPE_DESCRIPTION_VALIDATE_NONE) {
return true;
}
// Validation - requires DOMDocument
if (is_string($object)) {
$xmlDom = new DOMDocument();
$xmlDom->loadXML($object);
} else {
$xmlDom =& $object;
}
switch ($this->_validationStrategy) {
// We have to suppress validation errors, otherwise the script
// will stop when validation errors occur.
case XML_TYPE_DESCRIPTION_VALIDATE_DTD:
if (!$xmlDom->validate()) {
return false;
}
break;
case XML_TYPE_DESCRIPTION_VALIDATE_SCHEMA:
if (!$xmlDom->schemaValidate($this->_validationSource)) {
return false;
}
break;
case XML_TYPE_DESCRIPTION_VALIDATE_RELAX_NG:
if (!$xmlDom->relaxNGValidate($this->_validationSource)) {
return false;
}
break;
default:
assert(false);
}
return true;
}
示例10:
<?php
DOMDocument::validate();
示例11: jdVideoPlayerFunction
function jdVideoPlayerFunction($atts, $content = null)
{
try {
if (preg_match("/youtube/", $content)) {
preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=[0-9]/)[^&\n]+|(?<=v=)[^&\n]+#", $content, $results);
$videoid = $results[0];
$someurl = "http://gdata.youtube.com/feeds/api/videos/" . $videoid;
$somedoc = new DOMDocument();
@$somedoc->load($someurl);
if (@$somedoc->validate()) {
@($ourtitle = $somedoc->getElementsByTagName("title")->item(0)->nodeValue);
} else {
$ourtitle = "Title";
}
$service = "youtube";
$videolink = "http://www.youtube.com/watch?v=" . $videoid;
$videoimagelink = "http://img.youtube.com/vi/" . $videoid . "/0.jpg";
} elseif (preg_match("/vimeo/", $content)) {
preg_match("/(?<=vimeo\\.com\\/)\\d+/", $content, $results);
$videoid = $results[0];
$url = 'http://vimeo.com/api/v2/video/' . $videoid . '.php';
$array = unserialize(file_get_contents($url));
$anotherarray = $array[0];
$thumbnail = $anotherarray["thumbnail_large"];
$height = $anotherarray["height"];
$width = $anotherarray["width"];
$service = "vimeo";
$ourtitle = $anotherarray["title"];
$videolink = 'http://vimeo.com/moogaloop.swf?clip_id=' . $videoid;
$videoimagelink = $thumbnail;
}
$linkimage = videoThumb($videoimagelink, 'made_thumbstored' . $videoid);
return '<div class="jddivclass">
<a data-fb-options="width:1280 height:745 autoFitMedia:true enableDragResize:true outerBorder:0 innerBorder:0 padding:0 panelPadding:0 roundCorners:none showClose:false imageClickCloses:true" class="floatbox" href="' . $videolink . '">
<div style="position:absolute;right:4px;bottom:4px;">
<img style="border:0 !important;" src="http://redesigndavid.com/wp-content/themes/redesigndavid-wp/socialicons/24/' . $service . '.png"/></div>
<img class="imageclass" width="620px" src="' . $linkimage . '" >
</a>
</div>';
} catch (Exception $e) {
echo "helloworld";
}
}
示例12: exit
$new_service->appendChild($memory);
$cpu = $dom->createElement("cpu", $record->cpu);
$new_service->appendChild($cpu);
$pid = $dom->createElement("pid", $record->pid);
$new_service->appendChild($pid);
$uptime = $dom->createElement("uptime", $record->uptime);
$new_service->appendChild($uptime);
$children = $dom->createElement("children", $record->children);
$new_service->appendChild($children);
}
$status = $dom->createElement("status", $record->status);
$new_service->appendChild($status);
$alert = $dom->createElement("alert", $record->alert);
$new_service->appendChild($alert);
$monitor = $dom->createElement("monitor", $record->monitor);
$new_service->appendChild($monitor);
$service->appendChild($new_service);
}
$dom->validate();
if (!($handle = fopen($file, 'w'))) {
exit("Cannot open {$filename}");
}
$dom->preserveWhiteSpace = false;
$dom->formatOutput = false;
if (fwrite($handle, $dom->saveXML()) === FALSE) {
fclose($handle);
exit("Cannot write to {$filename}");
}
fclose($handle);
}
}
示例13: die
}
}
}
}
}
}
}
if (isset($_POST["law_import"]) && isset($_FILES["law_import_file"])) {
$file = $_FILES["law_import_file"];
if (!is_uploaded_file($file['tmp_name'])) {
die(T_('Please enter a valid path for the file to upload'));
}
$doc = new DOMDocument();
$doc->load($file['tmp_name']);
$doc->xinclude();
$doc->validate() or die('Malformed XML file');
if ($doc->doctype->publicId != 'DemoWave//law//0.1.0') {
die('Not a DemoWave Law file');
}
function domNodeIsEmpty($node)
{
return $node->nodeType == XML_TEXT_NODE && trim($node->data) == '';
}
function insertNode($path, $node)
{
$children = $node->childNodes;
$virtual = true;
$title = '';
$text = '';
$pos = 0;
while ($pos < $children->length && domNodeIsEmpty($children->item($pos))) {
示例14: validateXmlConfig
protected function validateXmlConfig($configFiles)
{
foreach ($configFiles as $configFile) {
if (file_exists($configFile)) {
$xmlDom = new DOMDocument();
$xmlDom->load($configFile);
self::assertTrue($xmlDom->validate());
unset($xmlDom);
}
}
}
示例15: DOMDocument
<?php
$dom = new DOMDocument('1.0');
$dom->validate(true);