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


PHP XMLWriter::startDocument方法代码示例

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


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

示例1: writeRels

 /**
  * Write relationships
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param null|array $xmlRels
  * @param null|array $mediaRels
  * @param integer $relId
  */
 private function writeRels(XMLWriter $xmlWriter, $xmlRels = null, $mediaRels = null, $relId = 1)
 {
     $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
     $xmlWriter->startElement('Relationships');
     $xmlWriter->writeAttribute('xmlns', self::RELS_BASE . 'package/2006/relationships');
     // XML files relationships
     if (is_array($xmlRels)) {
         foreach ($xmlRels as $target => $type) {
             $this->writeRel($xmlWriter, $relId++, $type, $target);
         }
     }
     // Media relationships
     if (!is_null($mediaRels) && is_array($mediaRels)) {
         $mapping = array('image' => 'image', 'object' => 'oleObject', 'link' => 'hyperlink');
         $targetPaths = array('image' => 'media/', 'object' => 'embeddings/');
         foreach ($mediaRels as $mediaRel) {
             $mediaType = $mediaRel['type'];
             $type = array_key_exists($mediaType, $mapping) ? $mapping[$mediaType] : $mediaType;
             $target = array_key_exists($mediaType, $targetPaths) ? $targetPaths[$mediaType] : '';
             $target .= $mediaRel['target'];
             $targetMode = $type == 'hyperlink' ? 'External' : '';
             $this->writeRel($xmlWriter, $relId++, "officeDocument/2006/relationships/{$type}", $target, $targetMode);
         }
     }
     $xmlWriter->endElement();
     // Relationships
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:35,代码来源:Rels.php

示例2: writeRels

 /**
  * Write relationships.
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param array $xmlRels
  * @param array $mediaRels
  * @param int $relId
  * @return void
  */
 protected function writeRels(XMLWriter $xmlWriter, $xmlRels = array(), $mediaRels = array(), $relId = 1)
 {
     $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
     $xmlWriter->startElement('Relationships');
     $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
     // XML files relationships
     foreach ($xmlRels as $target => $type) {
         $this->writeRel($xmlWriter, $relId++, $type, $target);
     }
     // Media relationships
     foreach ($mediaRels as $mediaRel) {
         $this->writeMediaRel($xmlWriter, $relId++, $mediaRel);
     }
     $xmlWriter->endElement();
     // Relationships
 }
开发者ID:Senasum,项目名称:PHPWord,代码行数:25,代码来源:Rels.php


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