本文整理汇总了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
}
示例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
}