PageRenderTime 36ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/Opl/Opt/Xml/Root.php

https://bitbucket.org/kandsten/hitta.sverok.se
PHP | 107 lines | 44 code | 11 blank | 52 comment | 4 complexity | 6f22a453314fc60a8042b1382bb81047 MD5 | raw file
Possible License(s): GPL-3.0, MIT
  1. <?php
  2. /*
  3. * OPEN POWER LIBS <http://www.invenzzia.org>
  4. *
  5. * This file is subject to the new BSD license that is bundled
  6. * with this package in the file LICENSE. It is also available through
  7. * WWW at this URL: <http://www.invenzzia.org/license/new-bsd>
  8. *
  9. * Copyright (c) Invenzzia Group <http://www.invenzzia.org>
  10. * and other contributors. See website for details.
  11. *
  12. * $Id: Root.php 231 2009-09-19 07:13:14Z zyxist $
  13. */
  14. /*
  15. * XML tree root node.
  16. */
  17. class Opt_Xml_Root extends Opt_Xml_Scannable
  18. {
  19. private $_prolog = NULL;
  20. private $_dtd = NULL;
  21. /**
  22. * Constructs the root node.
  23. */
  24. public function __construct()
  25. {
  26. parent::__construct();
  27. } // end __construct();
  28. /**
  29. * Overwritten parent setter - the root node cannot have parents.
  30. *
  31. * @param Opt_Xml_Node $parent The new parent (ignored).
  32. */
  33. public function setParent($parent)
  34. {
  35. /* null */
  36. } // end setParent();
  37. /**
  38. * Sets the new document prolog.
  39. * @param Opt_Xml_Prolog $prolog The new prolog.
  40. */
  41. public function setProlog(Opt_Xml_Prolog $prolog)
  42. {
  43. $this->_prolog = $prolog;
  44. } // end setProlog();
  45. /**
  46. * Sets the new DTD.
  47. * @param Opt_Xml_Dtd $dtd The new DTD
  48. */
  49. public function setDtd(Opt_Xml_Dtd $dtd)
  50. {
  51. $this->_dtd = $dtd;
  52. } // end setDtd();
  53. /**
  54. * Returns true, if the document has a prolog.
  55. * @return Boolean
  56. */
  57. public function hasProlog()
  58. {
  59. return !is_null($this->_prolog);
  60. } // end hasProlog();
  61. /**
  62. * Returns true, if the document has DTD.
  63. * @return Boolean
  64. */
  65. public function hasDtd()
  66. {
  67. return !is_null($this->_dtd);
  68. } // end hasDtd();
  69. /**
  70. * Returns the existing document prolog
  71. * @return Opt_Xml_Prolog
  72. */
  73. public function getProlog()
  74. {
  75. return $this->_prolog;
  76. } // end getProlog();
  77. /**
  78. * Returns the existing DTD.
  79. * @return Opt_Xml_Dtd
  80. */
  81. public function getDtd()
  82. {
  83. return $this->_dtd;
  84. } // end getDtd();
  85. /**
  86. * Tests, if the specified node can be a child of root.
  87. * @param Opt_Xml_Node $node The node to test.
  88. */
  89. protected function _testNode(Opt_Xml_Node $node)
  90. {
  91. if($node->getType() == 'Opt_Xml_Expression' && $node->getType() == 'Opt_Xml_Cdata')
  92. {
  93. throw new Opt_APIInvalidNodeType_Exception('Opt_Xml_Root', $node->getType());
  94. }
  95. } // end _testNode();
  96. } // end Opt_Xml_Root;