Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml to html transform using perl

Status
Not open for further replies.

PerlGerl

Programmer
Joined
Jun 29, 2004
Messages
19
Location
US
I want to use perl to transform xml to html via an xsl. I found this little script which promises to do so. I downloaded both modules but they complain for the latest libxml2 version from I went there, i obtained the files and now im getting into something too big. I need to be able to port this easily, one or two modules is fine, but i cannot port an entire library. Does any one know a simpiler way to get the transform to work without downloading muliple files?

Code:
use XML::LibXSLT;
use XML::LibXML;

# the arguments for this command are stylesheet and source files
my( $style_file, @source_files ) = @ARGV;

# initialize the parser and XSLT processor
my $parser = XML::LibXML->new( );
my $xslt = XML::LibXSLT->new( );
my $stylesheet = $xslt->parse_stylesheet_file( $style_file );

# for each source file: parse, transform, print out result
foreach my $file ( @source_files ) {
  my $source_doc = $parser->parse_file( $source_file );
  my $result = $stylesheet->transform( $source_doc );
  print $stylesheet->output_string( $result );
}
 
Can anyone point me in the right direction?
 
PerlGerl,

You are already pointed in the correct direction. The Perl modules are merely wrappers for libxml2, which is the actual XML/XSLT engine.

Sorry, but TANSTAAFL.

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top