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


PHP XmlDocument::saveToString方法代码示例

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


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

示例1: testFromJson

 /**
  * Test {@link taoQtiTest_models_classes_QtiTestConverter::fromJson}
  * @dataProvider dataProvider
  * 
  * @param string $testPath            
  * @param string $json            
  */
 public function testFromJson($testPath, $json)
 {
     $doc = new XmlDocument('2.1');
     $converter = new taoQtiTest_models_classes_QtiTestConverter($doc);
     $converter->fromJson($json);
     $result = preg_replace(array('/ {2,}/', '/<!--.*?-->|\\t|(?:\\r?\\n[ \\t]*)+/s'), array(' ', ''), $doc->saveToString());
     $expected = preg_replace(array('/ {2,}/', '/<!--.*?-->|\\t|(?:\\r?\\n[ \\t]*)+/s'), array(' ', ''), file_get_contents($testPath));
     $this->assertEquals($result, $expected);
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:16,代码来源:QtiTestConverterTest.php

示例2: testLoadSaveToStringSchemaValidate

 /**
  * @dataProvider qtiImplementationGuideAssessmentTestFiles
  *
  * @param string $uri The URI describing the file to load.
  */
 public function testLoadSaveToStringSchemaValidate($uri)
 {
     $doc = new XmlDocument('2.1');
     $doc->load($uri);
     $file = tempnam('/tmp', 'qsm');
     $str = $doc->saveToString();
     file_put_contents($file, $str);
     $doc = new XmlDocument('2.1');
     try {
         $doc->load($file, true);
         // validate on load.
         $this->assertTrue(true);
         unlink($file);
     } catch (XmlStorageException $e) {
         $this->assertTrue(false, $e->getMessage());
         unlink($file);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:23,代码来源:XmlAssessmentDocumentQTIGuideTest.php

示例3: convert

 public function convert(item $item, array $questions)
 {
     // Make sure we clean up the log
     LogService::flush();
     // Try to build the identifier using item `reference`
     // Otherwise, generate an alternative identifier and store the original reference as `label`
     $itemReference = $item->get_reference();
     $itemIdentifier = Format::isIdentifier($itemReference, false) ? $itemReference : 'ITEM_' . StringUtil::generateRandomString(12);
     if ($itemReference !== $itemIdentifier) {
         LogService::log("The item `reference` ({$itemReference}) is not a valid identifier, thus can not be used for `assessmentItem` identifier. " . "Replaced it with randomly generated `{$itemIdentifier}` and stored the original `reference` as `label` attribute");
     }
     $builder = new AssessmentItemBuilder();
     $assessmentItem = $builder->build($itemIdentifier, $itemReference, $questions, $item->get_content());
     $xml = new XmlDocument();
     $xml->setDocumentComponent($assessmentItem);
     // Flush out all the error messages stored in this static class, also ensure they are unique
     $messages = array_values(array_unique(LogService::flush()));
     return [$xml->saveToString(true), $messages];
 }
开发者ID:learnosity,项目名称:learnosity-qti,代码行数:19,代码来源:ItemWriter.php

示例4: explodeRubricBlocks

 /**
  * Explode the rubric blocks of the test definition into separate QTI-XML files and
  * remove the compact XML document from the file system (useless for
  * the rest of the compilation process).
  * 
  * @param XmlCompactDocument $compiledDoc
  */
 protected function explodeRubricBlocks(XmlCompactDocument $compiledDoc)
 {
     $privateDir = $this->getPrivateDirectory();
     $explodedRubricBlocks = $compiledDoc->explodeRubricBlocks();
     foreach ($explodedRubricBlocks as $href => $rubricBlock) {
         $doc = new XmlDocument();
         $doc->setDocumentComponent($rubricBlock);
         $data = $doc->saveToString();
         $privateDir->write($href, $data);
     }
 }
开发者ID:oat-sa,项目名称:extension-tao-testqti,代码行数:18,代码来源:class.QtiTestCompiler.php

示例5: testEmbedAssets

 /**
  * @dataProvider sharedStimulusConvertProvider
  */
 public function testEmbedAssets($directory, $exception, $converted)
 {
     $xmlDocument = new XmlDocument();
     $xmlDocument->load($directory . '/stimulus.xml');
     try {
         $xmlConverted = SharedStimulusPackageImporter::embedAssets($directory . '/stimulus.xml');
         $xmlDocument->load($xmlConverted);
         $strXml = $xmlDocument->saveToString();
         $xmlDocument->load($converted);
         $convertStr = $xmlDocument->saveToString();
         $this->assertEquals($convertStr, $strXml, __('Conversion return a wrong string'));
     } catch (\tao_models_classes_FileNotFoundException $e) {
         $this->assertNotNull($exception, __('It should not throw an exception'));
         if (!is_null($e)) {
             $this->assertInstanceOf(get_class($exception), $e, __('The exception class is wrong'));
             if ($exception->getMessage() !== '') {
                 $this->assertEquals($exception->getMessage(), $e->getMessage(), __('The exception message is wrong'));
             }
         }
     }
 }
开发者ID:nagyist,项目名称:extension-tao-mediamanager,代码行数:24,代码来源:SharedStimulusPackageImporterTest.php

示例6: testUnknownClassWhileSavingBecauseOfVersion3

 public function testUnknownClassWhileSavingBecauseOfVersion3()
 {
     $doc = new XmlDocument('2.2.0');
     $doc->loadFromString('
         <div>
             <bdo dir="rtl">I am reversed!</bdo>            
         </div>');
     // This should fail because in QTI 2.2.0 because <bdo> does not exist.
     $doc->setVersion('2.1.0');
     $expectedMsg = "'bdo' components are not supported in QTI version '2.1.0'";
     $this->setExpectedException('qtism\\data\\storage\\xml\\XmlStorageException', $expectedMsg, XmlStorageException::VERSION);
     $str = $doc->saveToString(true);
 }
开发者ID:hutnikau,项目名称:qti-sdk,代码行数:13,代码来源:XmlDocumentTest.php

示例7: saveDoc

 /**
  * Save the content of test from a QTI Document
  * @param core_kernel_classes_Resource $test
  * @param qtism\data\storage\xml\XmlDocument $doc
  * @return boolean true if saved
  * @throws taoQtiTest_models_classes_QtiTestServiceException
  */
 private function saveDoc(core_kernel_classes_Resource $test, XmlDocument $doc)
 {
     $file = $this->getQtiTestFile($test);
     return $file->update($doc->saveToString());
 }
开发者ID:oat-sa,项目名称:extension-tao-testqti,代码行数:12,代码来源:class.QtiTestService.php


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