Source for file ODPElement.php
Documentation is available at ODPElement.php
* Created on 05.01.2007 by Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
* PHP versions 5.2 or better.
* 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 $
* @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 $Revision: 146 $
* @package OpenDocumentPHP
* @since 0.5.2 - 05.03.2007
* namespace OpenDocument meta
const META = 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0';
* namespace OpenDocument office
const OFFICE = 'urn:oasis:names:tc:opendocument:xmlns:office:1.0';
* namespace OpenDocument manifest
const MANIFEST = 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0';
* namespace OpenDocument style
const STYLE = 'urn:oasis:names:tc:opendocument:xmlns:style:1.0';
* namespace OpenDocument text
const TEXT = 'urn:oasis:names:tc:opendocument:xmlns:text:1.0';
* namespace OpenDocument draw
const DRAW = 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0';
* namespace OpenDocument table
const TABLE = 'urn:oasis:names:tc:opendocument:xmlns:table:1.0';
* namespace OpenDocument number
const NUMBER = 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0';
* namespace OpenDocument chart
const CHART = 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0';
* namespace OpenDocument form
const FORM = 'urn:oasis:names:tc:opendocument:xmlns:form:1.0';
* namespace OpenDocument config
const CONFIG = 'urn:oasis:names:tc:opendocument:xmlns:config:1.0';
* namespace OpenDocument presentation
const PRESENTATION = 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0';
* namespace OpenDocument dr3d
const DR3D = 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0';
* namespace OpenDocument animation
const ANIM = 'urn:oasis:names:tc:opendocument:xmlns:animation:1.0';
* namespace OpenDocument script
const SCRIPT = 'urn:oasis:names:tc:opendocument:xmlns:script:1.0';
* namespace OpenDocument svg
const SVG = 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0';
* namespace OpenDocument fo (formation objects)
const FO = 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0';
* namespace OpenDocument smil
const SMIL = 'urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0';
const DC = 'http://purl.org/dc/elements/1.1/';
const XLINK = 'http://www.w3.org/1999/xlink';
const XFORMS = 'http://www.w3.org/2002/xforms';
const MATHML = 'http://www.w3.org/1998/Math/MathML';
* The DOMElement if this is just a cover object.
* 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.03.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.03.2007
* Retrieve elements by given tagname and namespace.
* @param string $namespace
* @return DOMNodeList List of all found elements.
* @since 0.5.2 - 16.03.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.03.2007
// Check if we 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.03.2007
$ret = parent :: hasAttributeNS($namespace, $tag);
$ret = $this->elem->hasAttributeNS($namespace, $tag);
* Set attribute with namespace.
* @since 0.5.2 - 07.03.2007
$ret = parent :: removeAttributeNS($namespace, $tag);
$ret = $this->elem->removeAttributeNS($namespace, $tag);
* Set attribute with namespace.
* @since 0.5.2 - 07.03.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.03.2007
$uc_child = $child->getElement();
$ret = parent :: appendChild($uc_child);
$ret = $this->elem->appendChild($uc_child);
$ret = parent :: appendChild($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.03.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.03.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.03.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.03.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.03.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.03.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.03.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.03.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.03.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.03.2007
|