1<?php 2 3namespace dokuwiki\plugin\wordimport\docx; 4 5/** 6 * Word Documents are ZIP files containing a bunch of XML files 7 * 8 * This class is the base for all classes that parse these XML files 9 */ 10abstract class AbstractXMLFile 11{ 12 protected $docx; 13 14 /** 15 * @param DocX $docx The DocX object to work on 16 */ 17 public function __construct(DocX $docx) 18 { 19 $this->docx = $docx; 20 $this->parse(); 21 } 22 23 /** 24 * Parse the XML file 25 */ 26 abstract protected function parse(); 27 28 /** 29 * Register all namespaces that we access in XPath queries 30 * 31 * This needs to be extended when new namespaces are used 32 * 33 * @param \SimpleXMLElement $xml 34 */ 35 protected function registerNamespaces($xml) 36 { 37 $namespaces = [ 38 'rs' => 'http://schemas.openxmlformats.org/package/2006/relationships', 39 'w' => 'http://schemas.openxmlformats.org/wordprocessingml/2006/main', 40 'wp' => 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing', 41 'a' => 'http://schemas.openxmlformats.org/drawingml/2006/main', 42 ]; 43 44 foreach ($namespaces as $prefix => $namespace) { 45 $xml->registerXPathNamespace($prefix, $namespace); 46 } 47 } 48} 49