[MOBY-guts] biomoby commit
Eddie Kawas
kawas at dev.open-bio.org
Wed Nov 28 23:33:22 UTC 2007
kawas
Wed Nov 28 18:33:22 EST 2007
Update of /home/repository/moby/moby-live/Perl/MOBY/RDF
In directory dev.open-bio.org:/tmp/cvs-serv28803/RDF
Modified Files:
Utils.pm
Log Message:
If libXSLT isnt installed, then the style sheet wont be apply, otherwise it is.
moby-live/Perl/MOBY/RDF Utils.pm,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/RDF/Utils.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Perl/MOBY/RDF/Utils.pm 2007/07/06 15:02:18 1.2
+++ /home/repository/moby/moby-live/Perl/MOBY/RDF/Utils.pm 2007/11/28 23:33:22 1.3
@@ -9,7 +9,6 @@
package MOBY::RDF::Utils;
use XML::LibXML;
-#use XML::LibXSLT;
use strict;
@@ -96,15 +95,24 @@
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"></rdf:RDF>
END
}
- my $parser = XML::LibXML->new();
-# my $xslt = XML::LibXSLT->new();
- my $source = $parser->parse_string($xml);
-# my $style_doc = $parser->parse_string( $self->{xslt} );
-# my $stylesheet = $xslt->parse_stylesheet($style_doc);
-# my $results = $stylesheet->transform($source);
-# $xml = $stylesheet->output_string($results);
- $xml = $source->toString(0);
- return $xml;
+
+ eval "require XML::LibXSLT";
+ if ($@) {
+ my $parser = XML::LibXML->new();
+ my $source = $parser->parse_string($xml);
+ $xml = $source->toString(0);
+ return $xml;
+ } else {
+ use XML::LibXSLT;
+ my $parser = XML::LibXML->new();
+ my $xslt = XML::LibXSLT->new();
+ my $source = $parser->parse_string($xml);
+ my $style_doc = $parser->parse_string( $self->{xslt} );
+ my $stylesheet = $xslt->parse_stylesheet($style_doc);
+ my $results = $stylesheet->transform($source);
+ $xml = $stylesheet->output_string($results);
+ return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>". $xml;
+ }
}
1;
More information about the MOBY-guts
mailing list