Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
RepresentationNativeXmlFilter.inc.php
1 <?php
2 
16 import('lib.pkp.plugins.importexport.native.filter.NativeExportFilter');
17 
23  function RepresentationNativeXmlFilter($filterGroup) {
24  $this->setDisplayName('Native XML representation export');
25  parent::NativeExportFilter($filterGroup);
26  }
27 
28 
29  //
30  // Implement template methods from PersistableFilter
31  //
35  function getClassName() {
36  return 'lib.pkp.plugins.importexport.native.filter.RepresentationNativeXmlFilter';
37  }
38 
39 
40  //
41  // Implement template methods from Filter
42  //
48  function &process(&$representation) {
49  // Create the XML document
50  $doc = new DOMDocument('1.0');
51  $deployment = $this->getDeployment();
52  $rootNode = $this->createRepresentationNode($doc, $representation);
53  $doc->appendChild($rootNode);
54  $rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
55  $rootNode->setAttribute('xsi:schemaLocation', $deployment->getNamespace() . ' ' . $deployment->getSchemaFilename());
56 
57  return $doc;
58  }
59 
60  //
61  // Representation conversion functions
62  //
69  function createRepresentationNode($doc, $representation) {
70  $deployment = $this->getDeployment();
71  $context = $deployment->getContext();
72 
73  // Create the representation node
74  $representationNode = $doc->createElementNS($deployment->getNamespace(), $deployment->getRepresentationNodeName());
75 
76  // Add metadata
77  $this->createLocalizedNodes($doc, $representationNode, 'name', $representation->getName(null));
78  $sequenceNode = $doc->createElementNS($deployment->getNamespace(), 'seq');
79  $sequenceNode->appendChild($doc->createTextNode($representation->getSeq()));
80  $representationNode->appendChild($sequenceNode);
81 
82  // Add files
83  foreach ($this->getFiles($representation) as $submissionFile) {
84  $fileRefNode = $doc->createElementNS($deployment->getNamespace(), 'submission_file_ref');
85  $fileRefNode->setAttribute('id', $submissionFile->getFileId());
86  $fileRefNode->setAttribute('revision', $submissionFile->getRevision());
87  $representationNode->appendChild($fileRefNode);
88  }
89 
90  return $representationNode;
91  }
92 
93 
94  //
95  // Abstract methods to be implemented by subclasses
96  //
102  function getFiles($representation) {
103  assert(false); // To be overridden by subclasses
104  }
105 }
106 
107 ?>
setDisplayName($displayName)
Definition: Filter.inc.php:140
Base class that converts a representation to a Native XML document.
Base class that converts a DataObject to a Native XML document.
createLocalizedNodes($doc, $parentNode, $name, $values)