Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

pdf file using perl latex template.

by veerubiji (Sexton)
on Oct 24, 2011 at 16:05 UTC ( #933428=perlquestion: print w/ replies, xml ) Need Help??
veerubiji has asked for the wisdom of the Perl Monks concerning the following question:

Hi I have xml file from that using XML::LiBXML I extracted and stored in a hash. after that using template I am generating pdf file. I written script like this

#!/usr/bin/perl use warnings; use strict; use Data::Dumper; use Template; use XML::LibXML::Reader; my $file; open( $file, 'DTC_Specification_transformed.xml'); my $reader = XML::LibXML::Reader->new( IO => $file ) or die ("unab +le to open file"); my %nums; my $num=0; while ($reader->nextElement( 'DATA' ) ) { $num=$num+1; $reader->nextElement( 'Test' ); my $information = $reader->readOuterXml(); $reader->nextElement( 'testinfo' ); my $testnumber = $reader->readOuterXml(); $nums{$infortion}= $testnumber; } print %nums; close($file); my $template = Template->new(); my $filename = 'output.tex'; $template->process(\*DATA, %nums, $filename) || die "Template process failed: ", $template->error(), "\n"; system( "pdflatex $filename" ); __DATA__ \documentclass{article} \title{testinformation of each data} \author{michel\\ \begin{document} \maketitle [% FOREACH st IN test %] DTC number:[% st.test %] \\ test information[% st.testinfo.temperature%] [%st.testinfo.humidity %] [% END %] \end{document}
but it generating pdf file without any information.I tried to print hash %nums it printing like this
$var1={ <test>1<test>'=>'<testinfo> <temperature="23"/> <humidity="80"/> </testinfo> <test>2<test>'=>'<testinfo> <temperature="27"/> <humidity="75"/> </testinfo>........so many tests }
I need to print like this in pdf
testnumber= 1, testinfo: temperature= "23", humidity="80" testnumber= 2, testinfo: temperature= "27", humidity="75"
but it not printing like that, it generating empty pdf . how to print pdf like this.

Comment on pdf file using perl latex template.
Select or Download Code
Re: pdf file using perl latex template.
by Corion (Pope) on Oct 24, 2011 at 16:17 UTC
Re: pdf file using perl latex template.
by keszler (Priest) on Oct 24, 2011 at 16:30 UTC
Re: pdf file using perl latex template.
by CountZero (Bishop) on Oct 24, 2011 at 18:15 UTC
    You have no key "test" in your hash %nums, so the foreach-loop in your template gets skipped.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      can you suggest me how to print from my hash.
        I'm sorry to say, but your are not making any sense. What do you want to print from your hash? In what way does printing from your hash have any relevance with your original posting?

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://933428]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-12-29 17:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (194 votes), past polls