|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZDOMDocument class 00004 // 00005 // Created on: <16-Nov-2001 12:18:23 bf> 00006 // 00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00008 // SOFTWARE NAME: eZ Publish 00009 // SOFTWARE RELEASE: 4.0.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00011 // SOFTWARE LICENSE: GNU General Public License v2.0 00012 // NOTICE: > 00013 // This program is free software; you can redistribute it and/or 00014 // modify it under the terms of version 2.0 of the GNU General 00015 // Public License as published by the Free Software Foundation. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of version 2.0 of the GNU General 00023 // Public License along with this program; if not, write to the Free 00024 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00025 // MA 02110-1301, USA. 00026 // 00027 // 00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00029 // 00030 00031 /*! 00032 \class eZDOMDocument ezdomdocument.php 00033 \ingroup eZXML 00034 \brief eZDOMDocument handles DOM nodes in DOM documents 00035 00036 The DOM document keeps a tree of DOM nodes and maintains 00037 information on the various namespaces in the tree. 00038 It also has helper functions for creating nodes and serializing 00039 the tree into text. 00040 00041 Accessing and changing the name of the document is done using name() and setName(). 00042 00043 Accessing the tree is done using the root() method, use setRoot() to set 00044 a new root node. The method appendChild() will do the same as setRoot(). 00045 00046 For fetching nodes globally the methods elementsByName(), elementsByNameNS() and namespaceByAlias() 00047 can be used. They will fetch nodes according to the fetch criteria no matter where they are in the tree. 00048 00049 Creating new nodes is most easily done with the helper methods 00050 createTextNode(), createCDATANode(), createElementNode() and createAttributeNode(). 00051 They take care of creating the node with the correct type and does proper initialization. 00052 00053 Creating typical structures is also possible with the helper methods 00054 createElementTextNode(), createElementCDATANode(), createElementNodeNS(), 00055 createAttributeNamespaceDefNode() and createAttributeNodeNS(). 00056 This will not only create the node itself but also the correct subchild, attribute or namespace. 00057 00058 After nodes are created they can be registered with the methods registerElement(), registerNamespaceAlias(). 00059 This ensures that they are available globally in the DOM document. 00060 00061 Serializing the tree structure is done using toString(), this also allows specifying 00062 the character set of the output. 00063 00064 Example of using the DOM document to create a node structure. 00065 \code 00066 $doc = new eZDOMDocument(); 00067 $doc->setName( "FishCatalogue" ); 00068 00069 $root = $doc->createElementNode( "FishCatalogue" ); 00070 $doc->setRoot( $root ); 00071 00072 $freshWater = $doc->createElementNode( "FreshWater" ); 00073 $root->appendChild( $freshWater ); 00074 00075 $saltWater = $doc->createElementNode( "SaltWater" ); 00076 $root->appendChild( $saltWater ); 00077 00078 $guppy = $doc->createElementNode( "Guppy" ); 00079 $guppy->appendChild( $doc->createTextNode( "Guppy is a small livebreeder." ) ); 00080 00081 $freshWater->appendChild( $guppy ); 00082 00083 $cod = $doc->createElementNode( "Cod" ); 00084 $saltWater->appendChild( $cod ); 00085 00086 $cod->appendChild( $doc->createCDATANode( "A big dull fish <-> !!" ) ); 00087 00088 print( $doc->toString() ); 00089 00090 // will print the following 00091 <?xml version="1.0"?> 00092 <FishCatalogue> 00093 <FreshWater> 00094 <Guppy> 00095 Guppy is a small livebreeder. </Guppy> 00096 </FreshWater> 00097 <SaltWater> 00098 <Cod> 00099 <![CDATA[A big dull fish <-> !!]]> </Cod> 00100 </SaltWater> 00101 </FishCatalogue> 00102 00103 \endcode 00104 */ 00105 00106 //include_once( "lib/ezxml/classes/ezdomnode.php" ); 00107 00108 class eZDOMDocument 00109 { 00110 /*! 00111 Initializes the DOM document object with the name \a $name. 00112 */ 00113 function eZDOMDocument( $name = "", $setParentNode = false ) 00114 { 00115 $this->Name = $name; 00116 $this->setParentNode = $setParentNode; 00117 } 00118 00119 /* 00120 Clean up memory. (destructor) 00121 */ 00122 function cleanup() 00123 { 00124 if ( $this->Root ) 00125 eZDOMNode::cleanup( $this->Root ); 00126 } 00127 00128 /*! 00129 Sets the document name to \a $name. 00130 */ 00131 function setName( $name ) 00132 { 00133 $this->Name = $name; 00134 } 00135 00136 /*! 00137 \return The document root node if it exists, if not \c false is returned. 00138 */ 00139 function &root() 00140 { 00141 return $this->Root; 00142 } 00143 00144 /*! 00145 \return The document root node if it exists, if not \c false is returned. 00146 Extra method for libxml compatibility. 00147 */ 00148 function &get_root() 00149 { 00150 return $this->Root; 00151 } 00152 00153 /*! 00154 Sets the document root node to \a $node. 00155 If the parameter is not an eZDOMNode it will not be set. 00156 */ 00157 function setRoot( $node ) 00158 { 00159 $this->appendChild( $node ); 00160 } 00161 00162 /*! 00163 Sets the document root node to \a $node. 00164 If the parameter is not an eZDOMNode it will not be set. 00165 \sa setRoot() 00166 */ 00167 function appendChild( eZDomNode $node ) 00168 { 00169 if ( $this->setParentNode !== false ) 00170 $this->updateParentNodeProperty( $node ); 00171 $this->Root = $node; 00172 } 00173 00174 /*! 00175 Updates parentNode of the tree according to setParentNode property of the document. 00176 (set false, if setParentNode is false) 00177 */ 00178 00179 function updateParentNodeProperty( &$node ) 00180 { 00181 if ( $node->parentNode === false ) 00182 $node->parentNode = null; 00183 00184 foreach( array_keys( $node->Children ) as $key ) 00185 { 00186 $this->updateParentNodeProperty( $node->Children[$key] ); 00187 } 00188 } 00189 00190 /*! 00191 Finds all element nodes which matches the name \a $name and returns it. 00192 \return An array with eZDOMNode elements. 00193 */ 00194 function &elementsByName( $name ) 00195 { 00196 if ( !in_array( $name, array_keys( $this->NamedNodes ) ) ) 00197 { 00198 $emptyArray = array(); 00199 return $emptyArray; 00200 } 00201 return $this->NamedNodes[$name]; 00202 } 00203 00204 /*! 00205 Alias for libxml compatibility 00206 */ 00207 function get_elements_by_tagname( $name ) 00208 { 00209 return $this->elementsByName( $name ); 00210 } 00211 00212 /*! 00213 Finds all element nodes which matches the name \a $name and namespace URI \a $namespaceURI and returns it. 00214 \return An array with eZDOMNode elements. 00215 */ 00216 function &elementsByNameNS( $name, $namespaceURI ) 00217 { 00218 return $this->NamedNodesNS[$name][$namespaceURI]; 00219 } 00220 00221 /*! 00222 Finds all element nodes which matches the namespace alias \a $alias and returns it. 00223 \return An array with eZDOMNode elements. 00224 */ 00225 function namespaceByAlias( $alias ) 00226 { 00227 if ( isset( $this->Namespaces[$alias] ) ) 00228 { 00229 return $this->Namespaces[$alias]; 00230 } 00231 else 00232 { 00233 return false; 00234 } 00235 } 00236 00237 /*! 00238 \static 00239 Creates a DOM node of type text and returns it. 00240 00241 Text nodes are used to store text strings, 00242 use content() on the node to extract the text. 00243 00244 \param $text The text string which will be stored in the node 00245 00246 \code 00247 $dom->createTextNode( 'Edge' ); 00248 \endcode 00249 The resulting XML text will be 00250 \code 00251 Edge 00252 \endcode 00253 */ 00254 static function createTextNode( $text ) 00255 { 00256 /* We remove all control chars from the text, although they 00257 * should have not be there in the first place. This is 00258 * iso-8859-1 and UTF-8 safe. Those characters might also never exist 00259 * in an XML document in the first place 00260 * (http://w3.org/TR/2004/REC-xml-20040204/#NT-Char) so it's safe to 00261 * remove them */ 00262 $text = preg_replace('/[\x00-\x08\x0b-\x0c\x0e-\x1f]/', '', $text); 00263 00264 $node = new eZDOMNode(); 00265 $node->setName( "#text" ); 00266 $node->setContent( $text ); 00267 $node->setType( 3 ); 00268 00269 return $node; 00270 } 00271 00272 /*! 00273 \static 00274 Creates a DOM node of type CDATA and returns it. 00275 00276 CDATA nodes are used to store text strings, 00277 use content() on the node to extract the text. 00278 00279 \param $text The text string which will be stored in the node 00280 00281 \code 00282 $dom->createCDATANode( 'http://ez.no' ); 00283 \endcode 00284 The resulting XML text will be 00285 \code 00286 <![CDATA[http://ez.no]]> 00287 \endcode 00288 */ 00289 static function createCDATANode( $text ) 00290 { 00291 $node = new eZDOMNode(); 00292 $node->setName( "#cdata-section" ); 00293 $node->setContent( $text ); 00294 $node->setType( 4 ); 00295 00296 return $node; 00297 } 00298 00299 /*! 00300 \deprecated not compatible with W3C DOM standard 00301 00302 \static 00303 Creates DOMNodeElement recursivly from recursive array 00304 */ 00305 static function createElementNodeFromArray( $name, $array ) 00306 { 00307 $node = new eZDOMNode(); 00308 $node->setName( $name ); 00309 $node->setType( 1 ); 00310 00311 foreach ( $array as $arrayKey => $value ) 00312 { 00313 if ( is_array( $value ) and 00314 count( $valueKeys = array_keys( $value ) ) > 0 ) 00315 { 00316 if ( is_int( $valueKeys[0] ) ) 00317 { 00318 foreach( $value as $child ) 00319 { 00320 $node->appendChild( eZDOMDocument::createElementNodeFromArray( $arrayKey, $child ) ); 00321 } 00322 } 00323 else 00324 { 00325 $node->appendChild( eZDOMDocument::createElementNodeFromArray( $arrayKey, $value ) ); 00326 } 00327 } 00328 else 00329 { 00330 $node->appendAttribute( eZDomDocument::createAttributeNode( $arrayKey, $value ) ); 00331 } 00332 } 00333 00334 return $node; 00335 } 00336 00337 /*! 00338 \deprecated not compatible with W3C DOM standard 00339 00340 \static 00341 Creates recursive array from DOMNodeElement 00342 */ 00343 static function createArrayFromDOMNode( $domNode ) 00344 { 00345 if ( !$domNode ) 00346 { 00347 return null; 00348 } 00349 00350 $retArray = array(); 00351 foreach ( $domNode->children() as $childNode ) 00352 { 00353 if ( !isset( $retArray[$childNode->name()] ) ) 00354 { 00355 $retArray[$childNode->name()] = array(); 00356 } 00357 00358 // If the node has children we create an array for this element 00359 // and append to it, if not we assign it directly 00360 if ( $childNode->hasChildren() ) 00361 { 00362 $retArray[$childNode->name()][] = eZDOMDocument::createArrayFromDOMNode( $childNode ); 00363 } 00364 else 00365 { 00366 $retArray[$childNode->name()] = eZDOMDocument::createArrayFromDOMNode( $childNode ); 00367 } 00368 } 00369 foreach( $domNode->attributes() as $attributeNode ) 00370 { 00371 $retArray[$attributeNode->name()] = $attributeNode->content(); 00372 } 00373 00374 return $retArray; 00375 } 00376 00377 /*! 00378 \deprecated Use createElement and setAttribute instead. 00379 00380 \static 00381 Creates a DOM node of type element and returns it. 00382 00383 Element nodes are the basic node type in DOM tree, 00384 they are used to structure nodes. 00385 They can contain child nodes and attribute nodes accessible 00386 with children() and attributes(). 00387 00388 \param $name The name of the element node. 00389 \param $attributes An associative array with attribute names and attribute data. 00390 This can be used to quickly fill in node attributes. 00391 00392 \code 00393 $dom->createElementNode( 'song', 00394 array( 'name' => 'Shine On You Crazy Diamond', 00395 'track' => 1 ) ); 00396 \endcode 00397 The resulting XML text will be 00398 \code 00399 <song name='Shine On You Crazy Diamond' track='1' /> 00400 \endcode 00401 */ 00402 static function createElementNode( $name, $attributes = array() ) 00403 { 00404 $node = new eZDOMNode(); 00405 $node->setName( $name ); 00406 $node->setType( 1 ); 00407 foreach ( $attributes as $attributeKey => $attributeValue ) 00408 { 00409 $node->appendAttribute( eZDomDocument::createAttributeNode( $attributeKey, $attributeValue ) ); 00410 } 00411 00412 return $node; 00413 } 00414 00415 /*! 00416 Alias for libXML compatibility 00417 */ 00418 function create_element( $name, $attributes = array() ) 00419 { 00420 return $this->createElementNode( $name, $attributes ); 00421 } 00422 00423 /*! 00424 \deprecated Not compatible with W3C DOM standard 00425 00426 \static 00427 Creates a DOM node of type element and returns it. 00428 It will also create a DOM node of type text and add it as child of the element node. 00429 00430 \param $name The name of the element node. 00431 \param $text The text string which will be stored in the text node 00432 \param $attributes An associative array with attribute names and attribute data. 00433 This can be used to quickly fill in element node attributes. 00434 00435 \code 00436 $dom->createElementTextNode( 'name', 00437 'Archer Maclean', 00438 array( 'id' => 'archer', 00439 'game' => 'ik+' ) ); 00440 \endcode 00441 The resulting XML text will be 00442 \code 00443 <name id='archer' game='ik+'>Archer Maclean</name> 00444 \endcode 00445 00446 \sa createTextNode, createElementNode 00447 */ 00448 static function createElementTextNode( $name, $text, $attributes = array() ) 00449 { 00450 $node = eZDOMDocument::createElementNode( $name, $attributes ); 00451 $textNode = eZDOMDocument::createTextNode( $text ); 00452 $node->appendChild( $textNode ); 00453 00454 return $node; 00455 } 00456 00457 /*! 00458 \deprecated not compatible with W3C DOM standard 00459 00460 \static 00461 Creates a DOM node of type element and returns it. 00462 It will also create a DOM node of type CDATA and add it as child of the element node. 00463 00464 \param $name The name of the element node. 00465 \param $text The text string which will be stored in the CDATA node 00466 \param $attributes An associative array with attribute names and attribute data. 00467 This can be used to quickly fill in element node attributes. 00468 00469 \code 00470 $dom->createElementCDATANode( 'name', 00471 'Peter Molyneux', 00472 array( 'type' => 'developer', 00473 'game' => 'dungeon keeper' ) ); 00474 \endcode 00475 The resulting XML text will be 00476 \code 00477 <name type='developer' game='dungeon keeper'><![CDATA[Peter Molyneux]]></name> 00478 \endcode 00479 00480 \sa createCDATANode, createElementNode 00481 */ 00482 static function createElementCDATANode( $name, $text, $attributes = array() ) 00483 { 00484 $node = eZDOMDocument::createElementNode( $name, $attributes ); 00485 $cdataNode = eZDOMDocument::createCDATANode( $text ); 00486 $node->appendChild( $cdataNode ); 00487 00488 return $node; 00489 } 00490 00491 /*! 00492 \deprecated Not compatible with W3C DOM standard. 00493 Use createElementNS instead. 00494 00495 \static 00496 Creates a DOM node of type element with a namespace and returns it. 00497 00498 \param $uri The namespace URI for the element 00499 \param $name The name of the element node. 00500 00501 \code 00502 $dom->createElementNodeNS( 'http://ez.no/package', 00503 'package' ); 00504 \endcode 00505 The resulting XML text will be 00506 \code 00507 <package xmlns="http://ez.no/package" /> 00508 \endcode 00509 00510 \sa createElementNode 00511 */ 00512 static function createElementNodeNS( $uri, $name ) 00513 { 00514 $node = new eZDOMNode(); 00515 $node->setNamespaceURI( $uri ); 00516 $node->setName( $name ); 00517 $node->setType( 1 ); 00518 00519 return $node; 00520 } 00521 00522 /*! 00523 \deprecated Not compatible with W3C DOM standard. 00524 Use createAttribute instead. 00525 00526 \static 00527 Creates a DOM node of type attribute and returns it. 00528 00529 \param $name The name of the attribute 00530 \param $content The content of the attribute 00531 \param $prefix Namespace prefix which will be placed before the attribute name 00532 00533 \code 00534 $dom->createAttributeNode( 'name', 00535 'Pink Floyd', 00536 'music-group' ); 00537 \endcode 00538 The resulting XML text will be 00539 \code 00540 music-group:name="Pink Floyd" 00541 \endcode 00542 */ 00543 static function createAttributeNode( $name, $content, $prefix = false ) 00544 { 00545 $node = new eZDOMNode(); 00546 $node->setName( $name ); 00547 if ( $prefix ) 00548 $node->setPrefix( $prefix ); 00549 $node->setContent( $content ); 00550 $node->setType( 2 ); 00551 00552 return $node; 00553 } 00554 00555 /*! 00556 \deprecated Not compatible with W3C DOM standard. 00557 Use createAttributeNS instead. 00558 00559 \static 00560 Creates a DOM node of type attribute which is used for namespace definitions and returns it. 00561 00562 \param $prefix Namespace prefix which will be placed before the attribute name 00563 \param $uri The unique URI for the namespace 00564 00565 \code 00566 $dom->createAttributeNamespaceDefNode( 'music-group', 00567 'http://music.org/groups' ); 00568 \endcode 00569 The resulting XML text will be 00570 \code 00571 xmlns:music-group="http://music.org/groups" 00572 \endcode 00573 */ 00574 static function createAttributeNamespaceDefNode( $prefix, $uri ) 00575 { 00576 $node = new eZDOMNode(); 00577 $node->setName( $prefix ); 00578 $node->setPrefix( "xmlns" ); 00579 $node->setContent( $uri ); 00580 $node->setType( 2 ); 00581 00582 return $node; 00583 } 00584 00585 /*! 00586 \deprecated Not compatible with W3C DOM standard. 00587 Use createAttributeNS instead. 00588 00589 \static 00590 Creates a DOM node of type attribute which is used for namespace definitions and returns it. 00591 00592 \param $uri The unique URI for the namespace 00593 \param $name The name of the attribute 00594 \param $content The content of the attribute 00595 00596 \code 00597 $dom->createAttributeNodeNS( 'http://music.org/groups', 00598 'name', 00599 'Pink Floyd' ); 00600 \endcode 00601 The resulting XML text will be 00602 \code 00603 name="Pink Floyd" 00604 \endcode 00605 */ 00606 static function createAttributeNodeNS( $uri, $name, $content ) 00607 { 00608 $node = new eZDOMNode(); 00609 $node->setName( $name ); 00610 // $node->setPrefix( $prefix ); 00611 $node->setNamespaceURI( $uri ); 00612 $node->setContent( $content ); 00613 $node->setType( 2 ); 00614 00615 return $node; 00616 } 00617 00618 /*! 00619 Adds the URL to a XSLT stylesheet to the document. 00620 00621 \param $url A vaild URL or array of URLs 00622 */ 00623 function setStylesheet( $url ) 00624 { 00625 if ( is_array( $url ) ) 00626 $this->stylesheet = $url; 00627 if ( $url ) 00628 $this->stylesheet = array( $url ); 00629 } 00630 00631 /*! 00632 Adds the URL to a DTD to the document. 00633 00634 \param $url A vaild URL 00635 \param $alias An alias representing the document, for example 00636 \param "-//My Company//DTD XMLEXPORT V 1.0//EN" 00637 \param $explict Declare if DTD must be used. 00638 */ 00639 function setDocTypeDefinition( $url = false, $alias = false, $explict = false ) 00640 { 00641 if ( $url or $alias ) 00642 { 00643 $this->dtd['url'] = $url; 00644 $this->dtd['alias'] = $alias; 00645 $this->dtd['explict'] = $explict; 00646 } 00647 } 00648 00649 /*! 00650 Returns a XML string representation of the DOM document. 00651 00652 \param $charset The name of the output charset or \c false to use UTF-8 (default in XML) 00653 \param $charsetConversion Controls whether the resulting text is converted to the specified 00654 charset or not. 00655 00656 The \a $charsetConversion parameter can be useful when you know the inserted texts are 00657 in the correct charset, turning conversion off can speed things up. 00658 00659 The XML creation is done by calling the eZDOMNode::toString() function on the root node 00660 and let that handle the rest. 00661 00662 \note The charset conversion is smart enough to only do conversion when required 00663 \note Using charset conversion will require the ezi18n library being installed 00664 */ 00665 function toString( $charset = true, $charsetConversion = true, $convertSpecialChars = true ) 00666 { 00667 $charsetText = ''; 00668 if ( $charset === true ) 00669 $charset = 'UTF-8'; 00670 if ( $charset !== false ) 00671 $charsetText = " encoding=\"$charset\""; 00672 $text = "<?xml version=\"1.0\"$charsetText?>\n"; 00673 00674 if ( $this->Root instanceof eZDOMNode ) 00675 { 00676 if ( isset( $this->dtd ) ) 00677 { 00678 $text .= '<!DOCTYPE ' . $this->Root->name(); 00679 if ( $explict ) 00680 $text .= ' SYSTEM '; 00681 else 00682 $text .= ' PUBLIC '; 00683 if ( $this->dtd['alias'] ) 00684 $text .= '"' . $this->dtd['alias'] . '" "' . $this->dtd['url'] . '"'; 00685 else 00686 $text .= '"' . $this->dtd['url'] . '"'; 00687 $text .= ">\n"; 00688 } 00689 00690 if ( isset( $this->stylesheet ) && count( $this->stylesheet ) ) 00691 { 00692 foreach ( $this->stylesheet as $stylesheet ) 00693 { 00694 $text .= '<?xml-stylesheet type="text/xsl" href="' . $stylesheet . '"?>' . "\n"; 00695 } 00696 } 00697 $text .= $this->Root->toString( 0, $charset, $convertSpecialChars ); 00698 } 00699 00700 if ( $charsetConversion ) 00701 { 00702 //include_once( 'lib/ezi18n/classes/eztextcodec.php' ); 00703 $codec = eZTextCodec::instance( false, $charset, false ); 00704 if ( $codec ) 00705 { 00706 $text = $codec->convertString( $text ); 00707 } 00708 } 00709 00710 return $text; 00711 } 00712 00713 /*! 00714 Alias for libxml compatibility 00715 */ 00716 function dump_mem( $charset = true, $conversion = true ) 00717 { 00718 return $this->toString( $charset, $conversion ); 00719 } 00720 00721 /*! 00722 Registers the node element \a $node in the DOM document. 00723 This involves extracting the name of the node and add it to the 00724 name lookup table which elementsByName() uses, then adding it 00725 to the namespace lookup table which elementsByNameNS() uses. 00726 00727 \note This will not insert the node into the node tree. 00728 */ 00729 function registerElement( &$node ) 00730 { 00731 $this->NamedNodes[$node->name()][] =& $node; 00732 00733 if ( $node->namespaceURI() != "" ) 00734 { 00735 $this->NamedNodesNS[$node->name()][$node->namespaceURI()][] =& $node; 00736 } 00737 } 00738 00739 /*! 00740 Register the namespace alias \a $alias to point to the namespace \a $namespace. 00741 00742 The namespace can then later on be fetched with namespaceByAlias(). 00743 */ 00744 function registerNamespaceAlias( $alias, $namespace ) 00745 { 00746 $this->Namespaces[$alias] =& $namespace; 00747 } 00748 00749 00750 /* 00751 W3C DOM compatibility functions 00752 00753 */ 00754 00755 function &createElement( $name ) 00756 { 00757 $node = new eZDOMNode(); 00758 $node->setName( $name ); 00759 $node->setType( 1 ); 00760 00761 $this->registerElement( $node ); 00762 00763 return $node; 00764 } 00765 00766 // \note W3C DOM function 00767 00768 static function createElementNS( $namespaceURI, $qualifiedName ) 00769 { 00770 list( $prefix, $name ) = explode( ':', $qualifiedName ); 00771 00772 $node = new eZDOMNode(); 00773 $node->setName( $name ); 00774 $node->setPrefix( $prefix ); 00775 $node->setNamespaceURI( $namespaceURI ); 00776 $node->setType( 1 ); 00777 return node; 00778 } 00779 00780 // \note W3C DOM function 00781 00782 static function createAttributeNS( $namespaceURI, $qualifiedName ) 00783 { 00784 list( $prefix, $name ) = explode( ':', $qualifiedName ); 00785 00786 $attr = new eZDOMNode(); 00787 $attr->setName( $name ); 00788 $attr->setPrefix( $prefix ); 00789 $attr->setNamespaceURI( $namespaceURI ); 00790 $attr->setType( 2 ); 00791 return $attr; 00792 } 00793 00794 // \note W3C DOM function 00795 00796 static function createAttribute( $name ) 00797 { 00798 $attr = new eZDOMNode(); 00799 $attr->setName( $name ); 00800 $attr->setType( 2 ); 00801 return $attr; 00802 } 00803 00804 /// \privatesection 00805 00806 /// Document name 00807 public $Name; 00808 00809 /// XML version 00810 public $Version; 00811 00812 /// Contains an array of reference to the named nodes 00813 public $NamedNodes = array(); 00814 00815 /// Contains an array of references to the named nodes with namespace 00816 public $NamedNodesNS = array(); 00817 00818 /// Contains an array of the registered namespaces and their aliases 00819 public $Namespaces = array(); 00820 00821 /// Reference to the first child of the DOM document 00822 public $Root; 00823 00824 /// If false eZDOMNode::parentNode will be not set. 00825 // This can is used to prevent memory cleanup problems when using mutual references in php. 00826 public $setParentNode = false; 00827 } 00828 00829 ?>