| XML-CompareML documentation | Contained in the XML-CompareML distribution. |
Do the actual processing using the XSLT stylesheet.
XML::CompareML::HTML - convert CompareML to XHTML
See XML::CompareXML.
Generates a list of li's with links to the systems, not unlike:
Shlomi Fish, http://www.shlomifish.org/.
Copyright 2004, Shlomi Fish. All rights reserved.
You can use, modify and distribute this module under the terms of the MIT X11 license. ( http://www.opensource.org/licenses/mit-license.php ).
| XML-CompareML documentation | Contained in the XML-CompareML distribution. |
package XML::CompareML::HTML; use strict; use warnings; use Carp; use File::Spec; use CGI (); use XML::LibXSLT; use XML::CompareML::ConfigData; use base 'XML::CompareML::Base'; __PACKAGE__->mk_accessors(qw( _data_dir _xml_parser _stylesheet )); sub _initialize { my $self = shift; $self->SUPER::_initialize(@_); my (%args) = (@_); my $data_dir = $args{'data_dir'} || XML::CompareML::ConfigData->config('extradata_install_path')->[0]; $self->_data_dir($data_dir); $self->_xml_parser(XML::LibXML->new()); my $xslt = XML::LibXSLT->new(); my $style_doc = $self->_xml_parser()->parse_file( File::Spec->catfile( $self->_data_dir(), "compare-ml.xslt" ), ); $self->_stylesheet($xslt->parse_stylesheet($style_doc)); return 0; }
sub process { my ($self, $args) = @_;
my $stylesheet = $self->_stylesheet();
my $results = $stylesheet->transform($self->dom());
print {*{$self->{o}}} $stylesheet->output_string($results);
return 0;
}
sub gen_systems_list { my ($self, %args) = @_; my $fh = $args{output_handle}; my @implementations = $self->_findnodes("/comparison/meta/implementations/impl"); foreach my $impl (@implementations) { my $name = $self->_impl_get_tag_text($impl, "name"); my $url = $self->_impl_get_tag_text($impl, "url"); my $fullname = $self->_impl_get_tag_text($impl, "fullname"); my $vendor = $self->_impl_get_tag_text($impl, "vendor"); if (!defined($url)) { die "URL not specified for implementation $name."; } print {$fh} qq{<li><a href="} . CGI::escapeHTML($url) . qq{">} . CGI::escapeHTML(defined($fullname) ? $fullname : $name) . qq{</a>} . (defined($vendor) ? " by $vendor" : "") . qq{</li>\n} ; } }
1;