Update of /cvsroot/net-script/netscript2/src/perl/XML/DAL
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1957
Modified Files:
LibXMLDAL.pm
Log Message:
* fixed bug in the LibXMLDAL, which caused attributes to disappear
Index: LibXMLDAL.pm
===================================================================
RCS file: /cvsroot/net-script/netscript2/src/perl/XML/DAL/LibXMLDAL.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** LibXMLDAL.pm 2 Jun 2003 21:49:16 -0000 1.4
--- LibXMLDAL.pm 22 Mar 2004 00:27:29 -0000 1.5
***************
*** 21,24 ****
--- 21,27 ----
my ( $this, $file ) = @_;
my $parser = XML::LibXML -> new();
+ eval {
+ $parser -> line_numbers(1);
+ };
return $parser -> parse_file( $file );
}
***************
*** 28,31 ****
--- 31,37 ----
my ( $this, $string ) = @_;
my $parser = XML::LibXML -> new();
+ eval {
+ $parser -> line_numbers(1);
+ };
return $parser -> parse_string( $string );
}
***************
*** 57,60 ****
--- 63,75 ----
}
+ sub getLine {
+ my ( $this, $node ) = @_;
+ my $result = "[Parser doesn't support line numbers!]";
+ eval {
+ $result = $node -> line_number();
+ };
+ $result;
+ }
+
# ---------------- Node Type Checking --------------------
***************
*** 205,210 ****
sub getAttributes {
my ( $this, $node ) = @_;
! my @attributes = $node -> attributes;
! \@attributes;
}
--- 220,230 ----
sub getAttributes {
my ( $this, $node ) = @_;
! my @attributes = $node -> attributes();
! # filter namespaces, no frickin idea why libxml
! # treats them as attributes...
! my @result = grep {
! ! UNIVERSAL::isa( $_, "XML::LibXML::Namespace" )
! } @attributes;
! \@result;
}
***************
*** 394,402 ****
sub importNode {
my ( $this, $document, $node, $deep ) = @_;
! unless ($deep) {
! $node = $node -> cloneNode( $deep ); #make a shallow copy
}
!
! return $document -> importNode( $node );
}
--- 414,431 ----
sub importNode {
my ( $this, $document, $node, $deep ) = @_;
! my $copiedNode = $node;
! unless ( $deep ) { #not deep, make a shallow copy
! $copiedNode = $node -> cloneNode( 1 );
! $copiedNode -> removeChildNodes();
! # since LibXML doesnt copy the attributes when doing shallow
! # copies we gotta do this ourselves...
! # my $attrs = $this -> getAttributes( $node );
! # my $length = $this -> getLength( $attrs ) -1;
! # for( 0..$length ) {
! # my $attr = $this -> getItemAt( $attrs, $_ );
! # $this -> setAttribute( $this -> getNodeName( $attr ), $this -> getAttrValue( $attr ) );
! # }
}
! $document -> importNode( $copiedNode );
}
|