Source for file ODPElement.php
Documentation is available at ODPElement.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* Created on 05. Jan. 2007 by Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* This software consists of voluntary contributions made by many individuals
* and is licensed under the GPL. For more information please see
* <http://opendocumentphp.org>.
* $Id: Fragment.php 146 2007-03-05 09:53:21Z nmarkgraf $
* @package OpenDocumentPHP
* @author Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
* @copyright Copyright in 2006, 2007 by The OpenDocumentPHP Team
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
* @version SVN: $Id: Validator.php 201 2007-07-11 11:36:55Z nmarkgraf $
* @link http://opendocumentphp.org
* @link http://www.oasis-open.org/committees/download.php/20493/UCR.pdf OpenDocument Metadata Use Cases and Requirements
* @since 0.5.2 - 05. Mar. 2007
require_once 'OpenDocumentPHP/util/Namespaces.php';
* @package OpenDocumentPHP
* @author Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
* @copyright Copyright in 2006, 2007 by OpenDocumentPHP Team
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
* @version Release: @package_version@
* @link http://opendocumentphp.org
* @since 0.5.2 - 05. Mar. 2007
* The DOMElement if this is just a cover object.
* @since 0.5.2 - 05. Mar. 2007
* This is a workaround, because DOMElements are not realy PHP classes.
* @param mixed $tagelem Either a DOMElement or a string
* @param string $namespace
* @since 0.5.2 - 07. Mar. 2007
function __construct($tagelem, $value = null, $namespace = null)
* This is a clean ODPElement
parent :: __construct($tagelem, $value, $namespace);
elseif ($tagelem instanceof DOMElement) {
* This is a cover ODPElement
elseif ($tagelem instanceof DOMDocument) {
// We should call __setRoot to get a new ODPElement and add it
// throw an ODPElement Exception!
* Return this element as uncovered DOMElement.
* @since 0.5.2 - 07. Mar. 2007
* Retrieve elements by given tagname and namespace.
* @param string $namespace
* @return DOMNodeList List of all found elements.
* @since 0.5.2 - 16. Mar. 2007
$ret = parent :: getElementsByTagNameNS($namespace, $tag);
$ret = $this->elem->getElementsByTagNameNS($namespace, $tag);
* Retrieve (first) element by given tagname and namespace.
* @param string $namespace
* @return DOMElement First found element if there is one,
* @since 0.5.2 - 07. Mar. 2007
* Check if we have got a DOMNodeList or nothing ...
if ((!is_null($ret)) && ($ret instanceof DOMNodeList)) {
* If we got a correct anwser, check if we got items in the list
* We got some, so return the first one, as requested.
* Check if this element has an attribute with given namespace and tagname.
* @since 0.5.2 - 07. Mar. 2007
$ret = parent :: hasAttributeNS($namespace, $tag);
$ret = $this->elem->hasAttributeNS($namespace, $tag);
* Set attribute with namespace.
* @since 0.5.2 - 07. Mar. 2007
$ret = parent :: removeAttributeNS($namespace, $tag);
$ret = $this->elem->removeAttributeNS($namespace, $tag);
* Set attribute with namespace.
* @since 0.5.2 - 07. Mar. 2007
$ret = parent :: setAttributeNS($namespace, $tag, $value);
$ret = $this->elem->setAttributeNS($namespace, $tag, $value);
function getAttributeNodeNS();
function setAttributeNodeNS();
function hasChildNodes();
function hasAttributes();
function isDefaultNamespace();
function lookupNamespaceURI();
* Set attribute with namespace.
* @since 0.5.2 - 07. Mar. 2007
* If the child is a ODPElement, get the uncoverd child first.
* Get uncovered part first.
$uc_child = $child->getElement();
* This is a normal DOMNode, so it is always un-covered.
* If this is a covered DOMElement, append the child it to its real DOMElement part.
$ret = parent :: appendChild($uc_child);
$ret = $this->elem->appendChild($uc_child);
* Check if the current element has a child $tag with $namespace.
* @return bool True, if there is such an element else false.
* @since 0.5.2 - 05. Mar. 2007
// Get the list and if it has more than one Element return TRUE:
* Retrieve a child by its namespace and tag from the current node.
* @return bool True, if there is such an element else false.
* @since 0.5.2 - 05. Mar. 2007
// read all possible nodes with this tag and namespace in to a node list
if ($nodelist->length != 1) {
// There is no or to many nodes in the node list.
// Get first (and only) item of the node list.
$ret = $nodeList->item(0);
* Put an attribute with namespace, tag and value.
* If an old attribute exists, it will be removed first.
* @return mixed <b>True</b> if there was no old attibute, else the old attribute node.
* @since 0.5.2 - 05. Mar. 2007
* Retrieve an attribute with namespace, tag and value.
* If a default value is given and the attribute does not exists, it will be
* @param string $namespace
* @param string $value Default value
* @since 0.5.2 - 19. Mar. 2007
* If there is no default value, setup false instead.
$ret = parent :: getAttributeNS($namespace, $tag);
* Set a Manifest attribute to the current ODPElement.
* '<... manifest:$tagname="$value"...>'
* @param string $tagname Tagname without prefix.
* @param string $value Value of the attribute.
* @return mixed <b>True</b> if there was no old attibute, else the old attribute node.
* @since 0.5.2 - 16. Mar. 2007
return $this->setAttributeNS(self :: MANIFEST, 'manifest:' . $tag, $value);
* Put (set with remove old) a FO attribute to the current ODPElement.
* '<... fo:$tagname="$value"...>'
* @param string $tagname Tagname without prefix.
* @param string $value Value of the attribute.
* @return mixed <b>True</b> if there was no old attibute, else the old attribute node.
* @since 0.5.2 - 16. Mar. 2007
* Put (set with remove old) a sytle attribute to the current ODPElement.
* '<... style:$tagname="$value"...>'
* @param string $tagname Tagname without prefix.
* @param string $value Value of the attribute.
* @return mixed <b>True</b> if there was no old attibute, else the old attribute node.
* @since 0.5.2 - 16. Mar. 2007
return $this->putAttributeNS(self :: STYLE, 'style:' . $tagname, $value);
* Retrieve a style attribute of the current element.
* '<... style:$tagname="$ret"...>'
* @since 0.5.2 - 19. Mar. 2007
* Put (set with remove old) a draw attribute to the current ODPElement.
* '<... draw:$tagname="$value"...>'
* @param string $tagname Tagname without prefix.
* @param string $value Value of the attribute.
* @return mixed <b>True</b> if there was no old attibute, else the old attribute node.
* @since 0.5.2 - 21. Mar. 2007
return $this->putAttributeNS(self :: DRAW, 'draw:' . $tagname, $value);
* Retrieve a draw attribute of the current element.
* '<... draw:$tagname="$ret"...>'
* @since 0.5.2 - 21. Mar. 2007
|