Open Monograph Press  3.3.0
ONIXParserDOMHandler.inc.php
1 <?php
2 
22 import('lib.pkp.classes.xml.XMLParserDOMHandler');
23 import('lib.pkp.classes.xml.XMLNode');
24 
26 
28  var $_listName = null;
29 
31  var $_foundRequestedList = false;
32 
34  var $_listItems = null;
35 
37  var $_currentValue = null;
38 
40  var $_insideDocumentation = false;
41 
46  function __construct($listName) {
47  parent::__construct();
48  $this->_listName = $listName;
49  $this->_listItems = array();
50  }
51 
58  function startElement($parser, $tag, $attributes) {
59  $this->currentData = null;
60 
61  switch ($tag) {
62  case 'xs:simpleType':
63  if ($attributes['name'] == $this->_listName) {
64  $this->_foundRequestedList = true;
65  }
66  break;
67  case 'xs:enumeration':
68  if ($this->_foundRequestedList) {
69  $this->_currentValue = $attributes['value'];
70  $this->_listItems[$this->_currentValue] = array(); // initialize the array cell
71  }
72  break;
73  case 'xs:documentation':
74  if ($this->_foundRequestedList) {
75  $this->_insideDocumentation = true;
76  }
77  break;
78  }
79 
80  $node = new XMLNode($tag);
81  $node->setAttributes($attributes);
82  if (isset($this->currentNode)) {
83  $this->currentNode->addChild($node);
84  $node->setParent($this->currentNode);
85 
86  } else {
87  $this->rootNode = $node;
88  }
89 
90  $this->currentNode = $node;
91  }
92 
98  function characterData($parser, $data) {
99  if ($this->_insideDocumentation) {
100  if (count($this->_listItems[$this->_currentValue]) == 1)
101  $this->_listItems[$this->_currentValue][0] .= $data;
102  else
103  $this->_listItems[$this->_currentValue][0] = $data;
104  }
105  }
106 
112  function endElement($parser, $tag) {
113 
114  switch ($tag) {
115  case 'xs:simpleType':
116  $this->_foundRequestedList = false;
117  break;
118  case 'xs:documentation':
119  $this->_insideDocumentation = false;
120  break;
121  }
122  }
123 
128  function getResult() {
129  return array($this->_listName => $this->_listItems);
130  }
131 }
132 
133 
ONIXParserDOMHandler\$_insideDocumentation
$_insideDocumentation
Definition: ONIXParserDOMHandler.inc.php:55
ONIXParserDOMHandler\$_currentValue
$_currentValue
Definition: ONIXParserDOMHandler.inc.php:49
ONIXParserDOMHandler\$_listName
$_listName
Definition: ONIXParserDOMHandler.inc.php:31
ONIXParserDOMHandler\$_foundRequestedList
$_foundRequestedList
Definition: ONIXParserDOMHandler.inc.php:37
ONIXParserDOMHandler\__construct
__construct($listName)
Definition: ONIXParserDOMHandler.inc.php:61
XMLParserDOMHandler\__construct
__construct()
Definition: XMLParserDOMHandler.inc.php:45
ONIXParserDOMHandler\$_listItems
$_listItems
Definition: ONIXParserDOMHandler.inc.php:43
XMLParserDOMHandler
Default handler for XMLParser returning a simple DOM-style object. This handler parses an XML documen...
Definition: XMLParserDOMHandler.inc.php:22
ONIXParserDOMHandler\endElement
endElement($parser, $tag)
Definition: ONIXParserDOMHandler.inc.php:127
ONIXParserDOMHandler\characterData
characterData($parser, $data)
Definition: ONIXParserDOMHandler.inc.php:113
XMLNode
Default handler for XMLParser returning a simple DOM-style object. This handler parses an XML documen...
Definition: XMLNode.inc.php:18
ONIXParserDOMHandler\getResult
getResult()
Definition: ONIXParserDOMHandler.inc.php:143
ONIXParserDOMHandler\startElement
startElement($parser, $tag, $attributes)
Definition: ONIXParserDOMHandler.inc.php:73
ONIXParserDOMHandler
This parser extracts a specific xs:simpleType based on a name attribute representing a code list with...
Definition: ONIXParserDOMHandler.inc.php:25