0: <!--
1:
2: XML2HTML
3:
4: Author : HolyGrail
5: Version: 0.1
6:
7: This TemplateToolkit template takes the same inputformat as XML2PDF
8: (look there for the DTD...) and outputs HTML that looks just like the
9: PDFfile.
10:
11: I know, it's not spectacular, but now we have a media-independent
12: DTD, with a conversiontool to HTML and to PDF :)
13:
14: Use the following one-liner to process this HTML-Template
15: (and save this file as template.html)
16:
17: perl -MTemplate -e'$t=Template->new({EVAL_PERL => 1});$t->process("template.html") ||die $t->error'
18:
19: -->
20: <html>
21: <body>
22: [% USE xpath = XML.XPath(file => "./filename.xml") %]
23: [% FOREACH section1 = xpath.findnodes('document/section1') %]
24: <h1>[% section1.getAttribute('title') %]</h1>
25: [% FOREACH node = section1.findnodes('*') %]
26: [% IF node.getName() == 'section2' %]
27: <h2>[% node.getAttribute('title') %]</h2>
28: [% FOREACH p = node.findnodes('p') %]
29: [% pvalue = p.string_value %]
30: <p>[% PERL %] <!-- use Perl to convert the \n into <br> -->
31: my $p = $stash->get('pvalue');
32: $p=~s/\n/<br \/>\n/gs;
33: print $p;
34: [% END %]</p>
35: [% END %]
36: [% ELSE %]
37: [% pvalue = node.string_value %]
38: <p>[% PERL %] <!-- use Perl to convert the \n into <br> -->
39: my $p = $stash->get('pvalue');
40: $p=~s/\n/<br \/>\n/gs;
41: print $p;
42: [% END %]</p>
43: [% END %]
44: [% END %]
45: [% END %]
46: </body>
47: </html> | For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |