You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ja...@apache.org on 2001/06/14 07:35:14 UTC
cvs commit: xml-xerces/perl postModule.pl
jasons 01/06/13 22:35:14
Modified: perl postModule.pl
Log:
* postModule.pl (Repository):
Added to_hash() for AttributeList and DOM_Entity
Added code in NamedNodeMap::to_hash() to handle DOM_Entity's
Revision Changes Path
1.13 +27 -2 xml-xerces/perl/postModule.pl
Index: postModule.pl
===================================================================
RCS file: /home/cvs/xml-xerces/perl/postModule.pl,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- postModule.pl 2001/05/05 23:56:13 1.12
+++ postModule.pl 2001/06/14 05:35:13 1.13
@@ -381,6 +381,27 @@
return @list;
}
+package XML::Xerces::DOM_Entity;
+sub to_hash {
+ my $self = shift;
+ if ($self->hasChildNodes) {
+ return ($self->getNodeName(),
+ $self->getFirstChild->getNodeValue());
+ } else {
+ return ($self->getNodeName(), '');
+ }
+}
+
+package XML::Xerces::AttributeList;
+sub to_hash {
+ my $self = shift;
+ my %hash;
+ for (my $i=0;$i<$self->getLength();$i++) {
+ $hash{$self->getName($i)} = $self->getValue($i)
+ }
+ return %hash;
+}
+
package XML::Xerces::DOM_NamedNodeMap;
# convert the NamedNodeMap to a perl hash
sub to_hash {
@@ -388,8 +409,12 @@
my @list;
for (my $i=0;$i<$self->getLength();$i++) {
my $node = $self->item($i);
- push(@list, $node->getNodeName());
- push(@list,$node->getNodeValue());
+ if ($node->getNodeType == $XML::Xerces::DOM_Node::ENTITY_NODE) {
+ push(@list, $node->to_hash());
+ } else {
+ push(@list, $node->getNodeName());
+ push(@list,$node->getNodeValue());
+ }
}
return @list;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org