扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:刘彦青编译 来源:yesky 2007年11月17日
关键字: 软件
eval { $context->{domtree} = $self->compare_as_dom( $file1, $file2 ); }; if ( $@ ) { $error = $@; } } else { $error = 'You must select two XML files to compare and wait for them to finish uploading'; } if ( $error ) { $context->{domtree} = $self->dom_from_data( { error => $error } ); } |
unless ( defined( $context->{domtree} )) { my $msg = "Files are semantically identical."; $context->{domtree} = $self->dom_from_data( { message => $msg } ); } } |
sub compare { my $self = shift; my ( $xmlstring1, $xmlstring2 ) = @_; my $diff = XML::SemanticDiff->new( keeplinenums => 1 ); my @results = $diff->compare( $xmlstring1, $xmlstring2 ); return \@results; } |
sub dom_from_data { my ( $self, $ref ) = @_; my $builder = XML::LibXML::SAX::Builder->new(); my $generator = XML::Generator::PerlData->new( Handler => $builder ); my $dom = $generator->parse( $ref ); return $dom; } |
sub compare_as_dom { my $self = shift; my $diff_messages = $self->compare( @_ ); return undef unless scalar( @{$diff_messages} ) > 0; return $self->dom_from_data( { difference => $diff_messages } ); } 1; |
#!/usr/bin/perl -w use strict; use SOAP::Transport::HTTP; use WebSemDiff; if ( defined( $ENV{'HTTP_SOAPACTION'} )) { SOAP::Transport::HTTP::CGI -> dispatch_to('WebSemDiff') -> handle; } else { my $app = WebSemDiff->new(); $app->run(); } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者