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


PHP kXml::getLibXmlErrorDescription方法代码示例

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


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

示例1: validateXsdData

 public static function validateXsdData($xsdData, &$errorMessage)
 {
     // validates the xsd
     libxml_use_internal_errors(true);
     libxml_clear_errors();
     $xml = new KDOMDocument();
     if (!$xml->loadXML($xsdData)) {
         $errorMessage = kXml::getLibXmlErrorDescription($xsdData);
         return false;
     }
     libxml_clear_errors();
     libxml_use_internal_errors(false);
     return true;
 }
开发者ID:DBezemer,项目名称:server,代码行数:14,代码来源:kMetadataProfileManager.php

示例2: doTest

 public function doTest($xmlPath, $type)
 {
     echo "\tTesting File [{$xmlPath}]\n";
     $serviceUrl = $this->client->getConfig()->serviceUrl;
     $xsdPath = "{$serviceUrl}/api_v3/index.php/service/schema/action/serve/type/{$type}";
     //		libxml_use_internal_errors(true);
     //		libxml_clear_errors();
     $doc = new DOMDocument();
     $doc->Load($xmlPath);
     //Validate the XML file against the schema
     if (!$doc->schemaValidate($xsdPath)) {
         $description = kXml::getLibXmlErrorDescription(file_get_contents($xmlPath));
         $this->fail("Type [{$type}] File [{$xmlPath}]: {$description}");
     }
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:15,代码来源:SchemaServiceTestValidate.php

示例3: addFromFileAction

 /**
  * Allows you to add a metadata profile object and metadata profile file associated with Kaltura object type
  * 
  * @action addFromFile
  * @param KalturaMetadataProfile $metadataProfile
  * @param file $xsdFile XSD metadata definition
  * @param file $viewsFile UI views definition
  * @return KalturaMetadataProfile
  * @throws MetadataErrors::METADATA_FILE_NOT_FOUND
  */
 function addFromFileAction(KalturaMetadataProfile $metadataProfile, $xsdFile, $viewsFile = null)
 {
     $filePath = $xsdFile['tmp_name'];
     if (!file_exists($filePath)) {
         throw new KalturaAPIException(MetadataErrors::METADATA_FILE_NOT_FOUND, $xsdFile['name']);
     }
     // validates the xsd
     libxml_use_internal_errors(true);
     libxml_clear_errors();
     $xml = new KDOMDocument();
     if (!$xml->load($filePath)) {
         $errorMessage = kXml::getLibXmlErrorDescription(file_get_contents($xsdFile));
         throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_PROFILE_SCHEMA, $errorMessage);
     }
     libxml_clear_errors();
     libxml_use_internal_errors(false);
     // must be validatebefore checking available searchable fields count
     $metadataProfile->validatePropertyNotNull('metadataObjectType');
     kMetadataManager::validateMetadataProfileField($this->getPartnerId(), $xsdFile, false, $metadataProfile->metadataObjectType);
     $dbMetadataProfile = $metadataProfile->toInsertableObject();
     $dbMetadataProfile->setStatus(KalturaMetadataProfileStatus::ACTIVE);
     $dbMetadataProfile->setPartnerId($this->getPartnerId());
     $dbMetadataProfile->save();
     $key = $dbMetadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_DEFINITION);
     kFileSyncUtils::moveFromFile($filePath, $key);
     if ($viewsFile && $viewsFile['size']) {
         $filePath = $viewsFile['tmp_name'];
         if (!file_exists($filePath)) {
             throw new KalturaAPIException(MetadataErrors::METADATA_FILE_NOT_FOUND, $viewsFile['name']);
         }
         $key = $dbMetadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_VIEWS);
         kFileSyncUtils::moveFromFile($filePath, $key);
     }
     kMetadataManager::parseProfileSearchFields($this->getPartnerId(), $dbMetadataProfile);
     $metadataProfile = new KalturaMetadataProfile();
     $metadataProfile->fromObject($dbMetadataProfile);
     return $metadataProfile;
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:48,代码来源:MetadataProfileService.php

示例4: xslTransform

 /**
  * Transform Xml file with conversion profile xsl
  * If xsl is not found, original Xml returned
  * @param string $filePath the original xml that was taken from partner file path
  * @return string - transformed Xml
  */
 protected function xslTransform($filePath)
 {
     $xdoc = file_get_contents($filePath);
     if (is_null($xdoc) || is_null($this->conversionProfileXsl)) {
         return $xdoc;
     }
     libxml_clear_errors();
     $xml = new KDOMDocument();
     if (!$xml->loadXML($xdoc)) {
         KalturaLog::debug("Could not load xml");
         $errorMessage = kXml::getLibXmlErrorDescription($xdoc);
         throw new KalturaBatchException("Could not load xml [{$this->job->id}], {$errorMessage}", KalturaBatchJobAppErrors::BULK_VALIDATION_FAILED);
     }
     libxml_clear_errors();
     $proc = new XSLTProcessor();
     $proc->registerPHPFunctions(kXml::getXslEnabledPhpFunctions());
     $xsl = new KDOMDocument();
     if (!$xsl->loadXML($this->conversionProfileXsl)) {
         KalturaLog::debug("Could not load xsl" . $this->conversionProfileXsl);
         $errorMessage = kXml::getLibXmlErrorDescription($this->conversionProfileXsl);
         throw new KalturaBatchException("Could not load xsl [{$this->job->id}], {$errorMessage}", KalturaBatchJobAppErrors::BULK_VALIDATION_FAILED);
     }
     $proc->importStyleSheet($xsl);
     libxml_clear_errors();
     $transformedXml = $proc->transformToXML($xml);
     if (!$transformedXml) {
         KalturaLog::debug("Could not transform xml" . $this->conversionProfileXsl);
         $errorMessage = kXml::getLibXmlErrorDescription($this->conversionProfileXsl);
         throw new KalturaBatchException("Could not transform xml [{$this->job->id}], {$errorMessage}", KalturaBatchJobAppErrors::BULK_VALIDATION_FAILED);
     }
     return $transformedXml;
 }
开发者ID:kubrickfr,项目名称:server,代码行数:38,代码来源:BulkUploadEngineXml.php

示例5: generateXml

 /**
  * @param array<CuePoint> $cuePoints
  * @return string xml
  */
 public static function generateXml(array $cuePoints)
 {
     $schemaType = CuePointPlugin::getApiValue(CuePointSchemaType::SERVE_API);
     $xsdUrl = "http://" . kConf::get('cdn_host') . "/api_v3/service/schema/action/serve/type/{$schemaType}";
     $scenes = new SimpleXMLElement('<scenes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="' . $xsdUrl . '" />');
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaCuePointXmlParser');
     foreach ($cuePoints as $cuePoint) {
         $scene = null;
         foreach ($pluginInstances as $pluginInstance) {
             $scene = $pluginInstance->generateXml($cuePoint, $scenes, $scene);
         }
     }
     $xmlContent = $scenes->asXML();
     $xml = new KDOMDocument();
     libxml_use_internal_errors(true);
     libxml_clear_errors();
     if (!$xml->loadXML($xmlContent)) {
         $errorMessage = kXml::getLibXmlErrorDescription($xmlContent);
         throw new kCuePointException("XML is invalid:\n{$errorMessage}", kCuePointException::XML_INVALID);
     }
     $xsdPath = SchemaService::getSchemaPath($schemaType);
     libxml_clear_errors();
     if (!$xml->schemaValidate($xsdPath)) {
         $errorMessage = kXml::getLibXmlErrorDescription($xmlContent);
         throw new kCuePointException("XML is invalid:\n{$errorMessage}", kCuePointException::XML_INVALID);
     }
     return $xmlContent;
 }
开发者ID:dozernz,项目名称:server,代码行数:32,代码来源:kCuePointManager.php

示例6: validateMetadata

 /**
  * Validate the XML against the profile XSD and set the metadata status
  *
  * @param int $metadataProfileId
  * @param string $metadata
  * @param string $errorMessage
  * @param int $compareAgainstPreviousVersion leave it false to use the latest metadata profile version
  *
  * returns bool
  */
 public static function validateMetadata($metadataProfileId, $metadata, &$errorMessage, $compareAgainstPreviousVersion = false)
 {
     KalturaLog::debug("Validating metadata [{$metadata}]");
     $metadataProfile = MetadataProfilePeer::retrieveByPK($metadataProfileId);
     if (!$metadataProfile) {
         $errorMessage = "Metadata profile [{$metadataProfileId}] not found";
         KalturaLog::err($errorMessage);
         return false;
     }
     $metadataProfileFSVersion = null;
     if ($compareAgainstPreviousVersion) {
         $metadataProfileFSVersion = $metadataProfile->getPreviousFileSyncVersion();
     }
     $metadataProfileKey = $metadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_DEFINITION, $metadataProfileFSVersion);
     $xsdData = kFileSyncUtils::file_get_contents($metadataProfileKey, true, false);
     if (!$xsdData) {
         $errorMessage = "Metadata profile xsd not found";
         KalturaLog::err($errorMessage);
         return false;
     }
     libxml_use_internal_errors(true);
     libxml_clear_errors();
     $xml = new KDOMDocument();
     $xml->loadXML($metadata);
     if ($xml->schemaValidateSource($xsdData)) {
         if (!self::validateMetadataObjects($metadataProfileId, $xml, $errorMessage)) {
             KalturaLog::err($errorMessage);
             return false;
         }
         KalturaLog::debug("Metadata is valid");
         return true;
     }
     $errorMessage = kXml::getLibXmlErrorDescription($metadata);
     KalturaLog::err("Metadata is invalid:\n{$errorMessage}");
     return false;
 }
开发者ID:AdiTal,项目名称:server,代码行数:46,代码来源:kMetadataManager.php

示例7: getOriginalOrTransformIfNeeded

 protected function getOriginalOrTransformIfNeeded(DropFolder $folder, $xmlPath)
 {
     if (!file_exists($xmlPath) || !filesize($xmlPath)) {
         throw new Exception('Empty file supplied as input');
     }
     if (!$folder->getConversionProfileId()) {
         KalturaLog::debug('No conversion profile found on drop folder [' . $folder->getId() . '] assuming no xsl transformation is needed');
         return file_get_contents($xmlPath);
     }
     $conversionProfile = conversionProfile2Peer::retrieveByPK($folder->getConversionProfileId());
     if (!$conversionProfile || strlen($conversionProfile->getXsl()) == 0) {
         KalturaLog::debug('No conversion profile found Or no xsl transform found');
         return file_get_contents($xmlPath);
     }
     $originalXmlDoc = file_get_contents($xmlPath);
     $origianlXml = new KDOMDocument();
     if (!$origianlXml->loadXML($originalXmlDoc)) {
         KalturaLog::debug('Could not load original xml');
         $errorMessage = kXml::getLibXmlErrorDescription($originalXmlDoc);
         throw new Exception(DropFolderXmlBulkUploadPlugin::MALFORMED_XML_FILE_MESSAGE, DropFolderXmlBulkUploadPlugin::getErrorCodeCoreValue(DropFolderXmlBulkUploadErrorCode::MALFORMED_XML_FILE));
     }
     libxml_clear_errors();
     $proc = new XSLTProcessor();
     $xsl = new KDOMDocument();
     if (!$xsl->loadXML($conversionProfile->getXsl())) {
         KalturaLog::debug('Could not load xsl ' . $conversionProfile->getXsl());
         $errorMessage = kXml::getLibXmlErrorDescription($conversionProfile->getXsl());
         throw new Exception(DropFolderXmlBulkUploadPlugin::MALFORMED_XML_FILE_MESSAGE, DropFolderXmlBulkUploadPlugin::getErrorCodeCoreValue(DropFolderXmlBulkUploadErrorCode::MALFORMED_XML_FILE));
     }
     $proc->importStyleSheet($xsl);
     libxml_clear_errors();
     $transformedXml = $proc->transformToXML($origianlXml);
     if (!$transformedXml) {
         KalturaLog::debug('Could not transform xml ' . $conversionProfile->getXsl());
         $errorMessage = kXml::getLibXmlErrorDescription($conversionProfile->getXsl());
         throw new Exception(DropFolderXmlBulkUploadPlugin::MALFORMED_XML_FILE_MESSAGE, DropFolderXmlBulkUploadPlugin::getErrorCodeCoreValue(DropFolderXmlBulkUploadErrorCode::MALFORMED_XML_FILE));
     }
     $xmlDoc = new KDOMDocument();
     $res = $xmlDoc->loadXML($transformedXml);
     if (!$res) {
         throw new Exception(DropFolderXmlBulkUploadPlugin::MALFORMED_XML_FILE_MESSAGE, DropFolderXmlBulkUploadPlugin::getErrorCodeCoreValue(DropFolderXmlBulkUploadErrorCode::MALFORMED_XML_FILE));
     }
     return $transformedXml;
 }
开发者ID:kubrickfr,项目名称:server,代码行数:44,代码来源:kDropFolderXmlFileHandler.php

示例8: validateMetadata

 /**
  * Validate the XML against the profile XSD and set the metadata status
  * 
  * @param Metadata $metadata
  * 
  * returns metadata status
  */
 public static function validateMetadata(Metadata $metadata, &$errorMessage)
 {
     KalturaLog::debug('Validating metadata [' . $metadata->getId() . ']');
     $metadataProfile = $metadata->getMetadataProfile();
     if (!$metadataProfile) {
         $errorMessage = 'Metadata profile [' . $metadata->getMetadataProfileId() . '] not found';
         KalturaLog::err($errorMessage);
         return self::setMetadataStatus($metadata, Metadata::STATUS_INVALID);
     }
     $metadataKey = $metadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA);
     $xmlPath = kFileSyncUtils::getLocalFilePathForKey($metadataKey);
     if (!file_exists($xmlPath)) {
         $errorMessage = "Metadata xml [{$xmlPath}] not found";
         KalturaLog::err($errorMessage);
         return self::setMetadataStatus($metadata, Metadata::STATUS_INVALID);
     }
     $metadataProfileKey = $metadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_DEFINITION);
     $xsdPath = kFileSyncUtils::getLocalFilePathForKey($metadataProfileKey);
     if (!file_exists($xsdPath)) {
         $errorMessage = "Metadata profile xsd [{$xsdPath}] not found";
         KalturaLog::err($errorMessage);
         return self::setMetadataStatus($metadata, Metadata::STATUS_INVALID);
     }
     libxml_use_internal_errors(true);
     libxml_clear_errors();
     $xml = new DOMDocument();
     $xml->load($xmlPath);
     if ($xml->schemaValidate($xsdPath)) {
         KalturaLog::debug("Metadata is valid");
         return self::setMetadataStatus($metadata, Metadata::STATUS_VALID, $metadataProfile->getVersion());
     }
     $errorMessage = kXml::getLibXmlErrorDescription(file_get_contents($xmlPath));
     KalturaLog::debug("Metadata is invalid:\n{$errorMessage}");
     return self::setMetadataStatus($metadata, Metadata::STATUS_INVALID);
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:42,代码来源:kMetadataManager.php


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