Update of /cvsroot/net-script/netscript2/src/perl/XML/DOM2 In directory usw-pr-cvs1:/tmp/cvs-serv1033 Modified Files: DOMImplementation.pm DOMWriter.pm Document.pm Element.pm NamedNodeMap.pm Node.pm NodeList.pm notes.txt Log Message: * bugfixes * improved documentation * reworked some functions to coply to the standard Index: DOMImplementation.pm =================================================================== RCS file: /cvsroot/net-script/netscript2/src/perl/XML/DOM2/DOMImplementation.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DOMImplementation.pm 17 Mar 2002 19:26:14 -0000 1.4 --- DOMImplementation.pm 26 Apr 2002 10:50:52 -0000 1.5 *************** *** 50,55 **** # # @param a hash holding the following key-value-pairs: ! # feature - the name of the feature which is requested. ! # version - the version of the feature. # @return undef if the feature is not supported, a defined # value, if it is supported. --- 50,55 ---- # # @param a hash holding the following key-value-pairs: ! # <ul><li>feature - the name of the feature which is requested.</li> ! # <li>version - the version of the feature.</li></ul> # @return undef if the feature is not supported, a defined # value, if it is supported. *************** *** 67,73 **** # # @param a hash reference containing the following key-value-pairs ! # qualifiedName - the qualified name of the document type to be created. ! # publicId - the external subset public identifier. ! # systemId - the external subset system identifier. # @return an instance of XML::DOM2::DocumentType #*/ --- 67,73 ---- # # @param a hash reference containing the following key-value-pairs ! # <ul><li>qualifiedName - the qualified name of the document type to be created.</li> ! # <li>publicId - the external subset public identifier.</li> ! # <li>systemId - the external subset system identifier.</li></ul> # @return an instance of XML::DOM2::DocumentType #*/ *************** *** 87,94 **** # Creates an an XML Document object. # @param a hash reference containing the following key-value-pairs ! # namespaceURI - the namespace URI of the document element to create. ! # qualifiedName - the qualified name of the document element ! # to be created ! # doctype - the type of document to be created or undef. # @return an instance of XML::DOM2::Document #*/ --- 87,94 ---- # Creates an an XML Document object. # @param a hash reference containing the following key-value-pairs ! # <ul><li>namespaceURI - the namespace URI of the document element to create.</li> ! # <li>qualifiedName - the qualified name of the document element ! # to be created</li> ! # <li>doctype - the type of document to be created or undef.</li></ul> # @return an instance of XML::DOM2::Document #*/ Index: DOMWriter.pm =================================================================== RCS file: /cvsroot/net-script/netscript2/src/perl/XML/DOM2/DOMWriter.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DOMWriter.pm 17 Mar 2002 19:26:14 -0000 1.1 --- DOMWriter.pm 26 Apr 2002 10:50:52 -0000 1.2 *************** *** 43,48 **** # Writes the given DOM to a string, using the given DOMWriterStyle # @param a hash reference containing the following key-value-pairs: ! # document - instance of XML::DOM2::Document ! # style - an instance of XML::DOM2::DOMWriterStyle or a subclass of it # @return the document as a string represenation. #*/ --- 43,48 ---- # Writes the given DOM to a string, using the given DOMWriterStyle # @param a hash reference containing the following key-value-pairs: ! # <ul><li>document - instance of XML::DOM2::Document</li> ! # <li>style - an instance of XML::DOM2::DOMWriterStyle or a subclass of it</li></ul> # @return the document as a string represenation. #*/ *************** *** 51,55 **** my $document = $paramRef -> { document }; my $style = $paramRef -> { style }; ! my @childrenList = ( $document -> documentElement() ); my @elements = (); my $child = shift(@childrenList); --- 51,55 ---- my $document = $paramRef -> { document }; my $style = $paramRef -> { style }; ! my @childrenList = ( $document ); my @elements = (); my $child = shift(@childrenList); Index: Document.pm =================================================================== RCS file: /cvsroot/net-script/netscript2/src/perl/XML/DOM2/Document.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Document.pm 8 Apr 2002 21:30:53 -0000 1.5 --- Document.pm 26 Apr 2002 10:50:52 -0000 1.6 *************** *** 71,75 **** sub documentElement { my ($this) = @_; ! $this -> firstChild(); } --- 71,75 ---- sub documentElement { my ($this) = @_; ! $this -> { m_documentElement }; } *************** *** 294,298 **** # @public # ! # FIXME: this is somewhat buggy ,since i don't # understand the spec fully in this case. Do not use # at this time. --- 294,298 ---- # @public # ! # @fixme this is somewhat buggy ,since i don't # understand the spec fully in this case. Do not use # at this time. *************** *** 447,452 **** --- 447,510 ---- } } + + + sub appendChild { + my ( $this, $paramsRef ) = @_; + my %params = %{$paramsRef}; + my $newNode = $params{ newChild }; + if ( $newNode -> nodeType() == XML::DOM2::Node -> ELEMENT_NODE() ) { + if ( $this -> documentElement() ) { + my $exception = XML::DOM2::DOMException -> new( + { ErrCode => XML::DOM2::DOMException -> HIERARCHY_REQUEST_ERR(), + ErrDesc => "This document already has a document element. You can only add one ". + "Element to a document.Cannot append." + } + ); + $exception -> raise(); + return; + } + $this -> { m_documentElement } = $newNode; + } + $this -> SUPER::appendChild( $paramsRef ); + } + + + sub removeChild { + my ( $this, $paramsRef ) = @_; + my %params = %{$paramsRef}; + my $oldChild = $params{ oldChild }; + if ( $oldChild == $this -> documentElement() ) { + $this -> { m_documentElement } = undef; + } + $this -> SUPER::removeChild( $paramsRef ); + } + + sub insertBefore { + my ( $this, $paramsRef ) = @_; + my %params = %{$paramsRef}; + my $newNode = $params{ newChild }; + if ( $newNode -> nodeType() == XML::DOM2::Node -> ELEMENT_NODE() ) { + if ( $this -> documentElement() ) { + my $exception = XML::DOM2::DOMException -> new( + { ErrCode => XML::DOM2::DOMException -> HIERARCHY_REQUEST_ERR(), + ErrDesc => "This document already has a document element. You can only add one ". + "Element to a document.Cannot insert." + } + ); + $exception -> raise(); + return; + } + $this -> { m_documentElement } = $newNode; + } + $this -> SUPER::insertBefore( $paramsRef ); + } + + + #/** + # Returns DOCUMENT_NODE + # @public + #*/ sub nodeType { my ($this) = @_; Index: Element.pm =================================================================== RCS file: /cvsroot/net-script/netscript2/src/perl/XML/DOM2/Element.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Element.pm 17 Mar 2002 19:26:14 -0000 1.5 --- Element.pm 26 Apr 2002 10:50:52 -0000 1.6 *************** *** 77,81 **** # Retrieves an attribute value by name. # @param a hash reference containing the following key-value-pairs ! # name - the name of the attribute to retrieve. # @return a scalar holding the attr value, or an empty string # if the attribute has no specified or default value. --- 77,81 ---- # Retrieves an attribute value by name. # @param a hash reference containing the following key-value-pairs ! # <ul><li>name - the name of the attribute to retrieve.</li></ul> # @return a scalar holding the attr value, or an empty string # if the attribute has no specified or default value. *************** *** 98,103 **** # Returns the attribute value by local name and namespace URI. # @param a hash reference containing the following key-value-pairs. ! # namespaceURI - the namespace URI of the attribute to retrieve ! # localName - the local name of the attribute to retrieve. # @return the attr value as string or the empty string of that attribute # does not have a specified or default value. --- 98,103 ---- # Returns the attribute value by local name and namespace URI. # @param a hash reference containing the following key-value-pairs. ! # <ul><li>namespaceURI - the namespace URI of the attribute to retrieve</li> ! # <li>localName - the local name of the attribute to retrieve.</li></ul> # @return the attr value as string or the empty string of that attribute # does not have a specified or default value. *************** *** 378,382 **** my $namespaceURI = $paramRef -> { "namespaceURI" }; my $qualifiedName = $paramRef -> { "qualifiedName" }; - my ($prefix, $localname) = split(/:/, $qualifiedName); --- 378,381 ---- *************** *** 415,419 **** } ! my $attribute = $this -> getAttributeNodeNS( $paramRef ); if ( defined( $attribute ) ) { $attribute -> value( $paramRef ); --- 414,422 ---- } ! my $attribute = $this -> getAttributeNodeNS( { ! namespaceURI => $namespaceURI, ! localName => $localname ! }); ! if ( defined( $attribute ) ) { $attribute -> value( $paramRef ); *************** *** 468,472 **** # namespace URI is present, it will be replaced. # @param a hash that contains the following key-value-pairs: ! # newAttr - the node to add (XML::DOM2::Attr) # @return the replaced attribute. # @public --- 471,475 ---- # namespace URI is present, it will be replaced. # @param a hash that contains the following key-value-pairs: ! # <ul><li>newAttr - the node to add (XML::DOM2::Attr)</li></ul> # @return the replaced attribute. # @public Index: NamedNodeMap.pm =================================================================== RCS file: /cvsroot/net-script/netscript2/src/perl/XML/DOM2/NamedNodeMap.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** NamedNodeMap.pm 17 Mar 2002 19:26:14 -0000 1.7 --- NamedNodeMap.pm 26 Apr 2002 10:50:52 -0000 1.8 *************** *** 29,32 **** --- 29,33 ---- # The constructor. Constructs a NamedNodeMap # @return an instance of XML::DOM2:NamedNodeMap + # @public #*/ sub new { *************** *** 48,51 **** --- 49,53 ---- # Returns the number of nodes in this map. # @return a scalar holding the number of nodes in this map. + # @public #*/ sub length { *************** *** 59,63 **** # # @param a hash reference containing the following key-value-pairs ! # name - the nodeName of a node to retrieve. # @return a reference to an XML::DOM2::Node object or undef # if the node can't be identified in this map. --- 61,65 ---- # # @param a hash reference containing the following key-value-pairs ! # <ul><li>name - the nodeName of a node to retrieve.</li></ul> # @return a reference to an XML::DOM2::Node object or undef # if the node can't be identified in this map. *************** *** 74,81 **** # # @param a hash reference containing the following key-value-pairs: ! # namespaceURI - the namespace URI of the node to retrieve. ! # localName - the local name of the node to retrieve. # @return a reference to an XML::DOM2::Node object or undef if # the Node can't be identified int this map. #*/ sub getNamedItemNS { --- 76,84 ---- # # @param a hash reference containing the following key-value-pairs: ! # <ul><li>namespaceURI - the namespace URI of the node to retrieve.</li> ! # <li>localName - the local name of the node to retrieve.</li></ul> # @return a reference to an XML::DOM2::Node object or undef if # the Node can't be identified int this map. + # @public #*/ sub getNamedItemNS { *************** *** 83,87 **** my $namespaceURI = $paramsRef -> { namespaceURI }; my $localName = $paramsRef -> { localName }; - $this -> { m_nodeMap } -> { $namespaceURI.$localName }; } --- 86,89 ---- *************** *** 92,98 **** # # @param a hash reference containing the following key-value-pairs: ! # index - a scalar holding the index to retrieve. # @return a reference to an XML::DOM2::Node object or undef # if the index is not valid. #*/ sub item { --- 94,101 ---- # # @param a hash reference containing the following key-value-pairs: ! # <ul><li>index - a scalar holding the index to retrieve.</li></ul> # @return a reference to an XML::DOM2::Node object or undef # if the index is not valid. + # @public #*/ sub item { *************** *** 108,115 **** # # @param a hash reference containing the following key-value-pairs: ! # name - the nodeName of the node to remove. # @return the removed Node, if such a node exists, else undef. # ! # @FIXME: Default attributes are not automatically inserted if # they are deleted. This must be done in compliance with # the specification. --- 111,118 ---- # # @param a hash reference containing the following key-value-pairs: ! # <ul><li>name - the nodeName of the node to remove.</li></ul> # @return the removed Node, if such a node exists, else undef. # ! # @fixme Default attributes are not automatically inserted if # they are deleted. This must be done in compliance with # the specification. *************** *** 125,129 **** # Removes the given node from the map. # @param a hash reference containing the following key-value-pairs: ! # node - the node to delete. # @return the deleted node if the node could be removed or # undef, if the node was not found in this NamedNodeMap. --- 128,132 ---- # Removes the given node from the map. # @param a hash reference containing the following key-value-pairs: ! # <ul><li>node - the node to delete.</li></ul> # @return the deleted node if the node could be removed or # undef, if the node was not found in this NamedNodeMap. *************** *** 152,162 **** # # @param a hash reference containing the following key-value-pairs: ! # namespaceURI - the namespaceURI of the node to remove. ! # localName - the local name of the node to remove. # @return the removed Node, if such a node exists, else undef. # ! # @FIXME: Default attributes are not automatically inserted if # they are deleted. This must be done in compliance with # the specification. #*/ sub removeNamedItemNS { --- 155,166 ---- # # @param a hash reference containing the following key-value-pairs: ! # <ul><li>namespaceURI - the namespaceURI of the node to remove.</li> ! # <li>localName - the local name of the node to remove</li></ul>. # @return the removed Node, if such a node exists, else undef. # ! # @fixme Default attributes are not automatically inserted if # they are deleted. This must be done in compliance with # the specification. + # @public #*/ sub removeNamedItemNS { *************** *** 173,176 **** --- 177,181 ---- # @param a hash reference containing the following key-value-pairs: # node - an instance of XML::DOM2::Node + # @public #*/ sub setNamedItem { *************** *** 184,188 **** # # @param a hash reference containing the following key-value-pairs: ! # node - an instance of XML::DOM2::Node #*/ sub setNamedItemNS { --- 189,194 ---- # # @param a hash reference containing the following key-value-pairs: ! # <ul><li>node - an instance of XML::DOM2::Node</li></ul> ! # @public #*/ sub setNamedItemNS { Index: Node.pm =================================================================== RCS file: /cvsroot/net-script/netscript2/src/perl/XML/DOM2/Node.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Node.pm 8 Apr 2002 21:42:18 -0000 1.14 --- Node.pm 26 Apr 2002 10:50:52 -0000 1.15 *************** *** 12,16 **** # This class implements a DOM Node. Its the base class of most DOM # Interfaces. ! # @author <a href="mailto:ko...@in...">Jan Thomä</a> #*/ use strict; --- 12,16 ---- # This class implements a DOM Node. Its the base class of most DOM # Interfaces. ! # @author Jan Thomä #*/ use strict; *************** *** 222,228 **** # setting it has no effect. Returns the value of this node. # ! # @param a hash reference containing the following key-value-pairs ! # value - a scalar holding the new value of this node. ! # May be undef. # # @return a scalar holding the value of this node. --- 222,228 ---- # setting it has no effect. Returns the value of this node. # ! # @optional a hash reference containing the following key-value-pairs ! # <ul><li> value - a scalar holding the new value of this node. ! # </li></ul> # # @return a scalar holding the value of this node. *************** *** 278,287 **** # Document interface, this is always undef. # ! # @param a hash reference containing the following key-value-pairs ! # prefix - the new namespace prefix for this node # @return a scalar holding the namespace prefix of this node or # undef # @public ! # FIXME: Should be implemented in Attr and Element... #*/ sub prefix { --- 278,288 ---- # Document interface, this is always undef. # ! # @optional a hash reference containing the following key-value-pairs ! # <ul><li>prefix - the new namespace prefix for this node</li></ul> # @return a scalar holding the namespace prefix of this node or # undef # @public ! # @fixme Implement check for invalid characters ! # @fixme Implement check for malformed prefix #*/ sub prefix { *************** *** 295,300 **** my $prefix = $params{ prefix }; - # FIXME: Implement check for invalid characters - # FIXME: Implement check for malformed prefix my $namespaceURI = $this -> namespaceURI(); if ( ! defined( $namespaceURI ) ) { --- 296,299 ---- *************** *** 345,349 **** # # @param a hash reference containing the following key-value-pairs: ! # newChild - an instance of XML::DOM2::Node, the new child. # @return an instance of XML::DOM2::Node, the node added. # @public --- 344,348 ---- # # @param a hash reference containing the following key-value-pairs: ! # <ul><li>newChild - an instance of XML::DOM2::Node, the new child.</li></ul> # @return an instance of XML::DOM2::Node, the node added. # @public *************** *** 425,432 **** # # @param a hash reference containing the following key-value pair ! # deep - if non-zero recursively clones the subtree under the ! # specified node, else just clones the node itself # @public ! # @note: implemented in subclasses # @return the cloned node #*/ --- 424,431 ---- # # @param a hash reference containing the following key-value pair ! # <ul><li>deep - if non-zero recursively clones the subtree under the ! # specified node, else just clones the node itself</li></ul> # @public ! # @note implemented in subclasses # @return the cloned node #*/ *************** *** 473,478 **** # # @param a hash reference containing the following key-value-pairs ! # newChild - instance of XML::DOM2::Node which should be inserted. ! # refChild - the node before which the new node should be inserted. # @return the node being inserted. # @public --- 472,477 ---- # # @param a hash reference containing the following key-value-pairs ! # <ul><li>newChild - instance of XML::DOM2::Node which should be inserted.</li> ! # <li>refChild - the node before which the new node should be inserted.</li></ul> # @return the node being inserted. # @public *************** *** 562,568 **** # # @param a hash reference containing the following key-value-pairs: ! # feature - the name of a feature to test. ! # version - the version of the feature to test. # @public #*/ sub isSupported { --- 561,569 ---- # # @param a hash reference containing the following key-value-pairs: ! # <ul><li>feature - the name of a feature to test. </li> ! # </li>version - the version of the feature to test.</li></ul> # @public + # @note this is somewhat weird in the specification so it might be + # that i missed the point of what this function should do #*/ sub isSupported { *************** *** 606,610 **** # # @param a hash reference containing the following key-value-pairs: ! # oldChild - the child node to remove # @return instance of XML::DOM2::Node - the removed child. # @public --- 607,611 ---- # # @param a hash reference containing the following key-value-pairs: ! # <ul><li> oldChild - the child node to remove</li></ul> # @return instance of XML::DOM2::Node - the removed child. # @public *************** *** 629,633 **** } ! $this -> childNodes() -> remove( $index ); $oldChild -> { m_parentNode } = undef; --- 630,634 ---- } ! $this -> childNodes() -> remove( { index => $index } ); $oldChild -> { m_parentNode } = undef; *************** *** 643,647 **** } ! #/* # Replaces the child node oldChild with newChild in the list of children, # and returns the oldChild node. If newChild is a DocumentFragment object, --- 644,648 ---- } ! #/** # Replaces the child node oldChild with newChild in the list of children, # and returns the oldChild node. If newChild is a DocumentFragment object, *************** *** 651,656 **** # # @param a hash reference containing the following key-value-pairs: ! # oldChild - the child to be removed ! # newChild - the child to be added #*/ sub replaceChild { --- 652,658 ---- # # @param a hash reference containing the following key-value-pairs: ! # <ul><li>oldChild - the child to be removed</li> ! # <li>newChild - the child to be added</li></ul> ! # @public #*/ sub replaceChild { *************** *** 736,740 **** # @not-standard # @param a hash reference containing the following key-value-pairs: ! # aNode - an instance of XML::DOM2::Node # @return boolean - true, if the given node is an ancestor of # this node. --- 738,742 ---- # @not-standard # @param a hash reference containing the following key-value-pairs: ! # <ul><li>aNode - an instance of XML::DOM2::Node</li></ul> # @return boolean - true, if the given node is an ancestor of # this node. Index: NodeList.pm =================================================================== RCS file: /cvsroot/net-script/netscript2/src/perl/XML/DOM2/NodeList.pm,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NodeList.pm 17 Mar 2002 19:26:15 -0000 1.9 --- NodeList.pm 26 Apr 2002 10:50:52 -0000 1.10 *************** *** 50,54 **** # Returns the item with the given index from the node list. # @param a hash reference containing the following key-value-pairs ! # index - index into the collection # @returns an instance of XML::DOM2::Node or undef if # the index is not valid --- 50,54 ---- # Returns the item with the given index from the node list. # @param a hash reference containing the following key-value-pairs ! # <ul><li>index - index into the collection</li></ul> # @returns an instance of XML::DOM2::Node or undef if # the index is not valid *************** *** 89,93 **** # @not-standard # @param a hash reference containing the following key-value-pairs ! # node - a reference to an XML::DOM2::Node object # @public #*/ --- 89,93 ---- # @not-standard # @param a hash reference containing the following key-value-pairs ! # <ul><li>node - a reference to an XML::DOM2::Node object</li></ul> # @public #*/ *************** *** 103,107 **** # @not-standard # @param a hash reference containing the following key-value-pairs ! # index - the index at which the node should be removed # @return the removed node ( XML::DOM2::Node ) # @public --- 103,107 ---- # @not-standard # @param a hash reference containing the following key-value-pairs ! # <ul><li>index - the index at which the node should be removed</li></ul> # @return the removed node ( XML::DOM2::Node ) # @public *************** *** 122,126 **** } ! my $node = @{ $this -> { m_nodeList } }[ $index ]; splice( @{ $this -> { m_nodeList } }, $index, 1 ); return $node; --- 122,126 ---- } ! my $node = $this -> item({ index => $index }); splice( @{ $this -> { m_nodeList } }, $index, 1 ); return $node; *************** *** 134,139 **** # @not-standard # @param a hash reference containing the following key-value-pairs ! # index - index to insert the node at ( 0 <= index < lenght ) ! # node - a reference to XML::DOM2::Node # @public #*/ --- 134,139 ---- # @not-standard # @param a hash reference containing the following key-value-pairs ! # <ul><li>index - index to insert the node at ( 0 <= index < lenght )</li> ! # </li>node - a reference to XML::DOM2::Node</li></ul> # @public #*/ *************** *** 163,173 **** # @not-standard # @param a hash reference containing the following key-value-pairs. ! # node - a reference to the XML::DOM2::Node whose index ! # should be determined. ! # index - [optional] the start index to search from. ! # if not given, 0 is assumed. # @return the index of the given node or -1 if the node is not # contained in this list # @public #*/ sub indexOf { --- 163,175 ---- # @not-standard # @param a hash reference containing the following key-value-pairs. ! # <ul><li>node - a reference to the XML::DOM2::Node whose index ! # should be determined.</li> ! # <li>index - [optional] the start index to search from. ! # if not given, 0 is assumed.</li></ul> # @return the index of the given node or -1 if the node is not # contained in this list # @public + # @note since this method is not standard, you should not use it from + # outside. It is just used by the implementation. #*/ sub indexOf { *************** *** 175,184 **** my $startIndex = defined( $paramsRef -> { 'index' } ) ? $paramsRef -> { "index" } : 0; my $node = $paramsRef -> { node }; ! my @list = @{ $this -> { m_nodeList } }; ! ! for ( [$startIndex .. $this -> length() - 1] ) { ! if ( $list[ $_ ] == $node ) { ! return $_; } } return -1; --- 177,187 ---- my $startIndex = defined( $paramsRef -> { 'index' } ) ? $paramsRef -> { "index" } : 0; my $node = $paramsRef -> { node }; ! my @list = @{$this -> { m_nodeList }}; ! my $index = 0; ! for ( @list ) { ! if ( $_ == $node ) { ! return $index; } + $index++; } return -1; Index: notes.txt =================================================================== RCS file: /cvsroot/net-script/netscript2/src/perl/XML/DOM2/notes.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** notes.txt 17 Mar 2002 19:26:15 -0000 1.5 --- notes.txt 26 Apr 2002 10:50:52 -0000 1.6 *************** *** 1,2 **** --- 1,3 ---- + <pre> #-------------------------------------------------------- # DOM Level 2 Implementation for Perl *************** *** 81,83 **** normalize - (I) Node isSupported - (I) Node ! --- 82,84 ---- normalize - (I) Node isSupported - (I) Node ! </pre> |