.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Template::Plugin::XML::XPath 3pm" .TH Template::Plugin::XML::XPath 3pm "2022-07-04" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Template::Plugin::XML::XPath \- Plugin interface to XML::XPath .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& # load plugin and specify XML file to parse \& [% USE xpath = XML.XPath(xmlfile) %] \& [% USE xpath = XML.XPath(file => xmlfile) %] \& [% USE xpath = XML.XPath(filename => xmlfile) %] \& \& # load plugin and specify XML text to parse \& [% USE xpath = XML.XPath(xmltext) %] \& [% USE xpath = XML.XPath(xml => xmltext) %] \& [% USE xpath = XML.XPath(text => xmltext) %] \& \& # then call any XPath methods (see XML::XPath docs) \& [% FOREACH page = xpath.findnodes(\*(Aq/html/body/page\*(Aq) %] \& [% page.getAttribute(\*(Aqtitle\*(Aq) %] \& [% END %] \& \& # define VIEW to present node(s) \& [% VIEW repview notfound=\*(Aqxmlstring\*(Aq %] \& # handler block for a ... element \& [% BLOCK report %] \& [% item.content(view) %] \& [% END %] \& \& # handler block for a
...
element \& [% BLOCK section %] \&

[% item.getAttribute(\*(Aqtitle\*(Aq) | html %]

\& [% item.content(view) %] \& [% END %] \& \& # default template block passes tags through and renders \& # out the children recursivly \& [% BLOCK xmlstring; \& item.starttag; item.content(view); item.endtag; \& END %] \& \& # block to generate simple text \& [% BLOCK text; item | html; END %] \& [% END %] \& \& # now present node (and children) via view \& [% repview.print(page) %] \& \& # or print node content via view \& [% page.content(repview) %] .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is a Template Toolkit plugin interfacing to the XML::XPath module. .PP All methods implemented by the XML::XPath modules are available. In addition, the XML::XPath::Node::Element module implements present($view) and content($view) methods method for seamless integration with Template Toolkit VIEWs. The XML::XPath::Node::Text module is also adorned with a present($view) method which presents itself via the view using the 'text' template. .PP To aid the reconstruction of \s-1XML,\s0 methods starttag and endtag are added to XML::XPath::Node::Element which return the start and end tag for that element. This means that you can easily do: .PP .Vb 1 \& [% item.starttag %][% item.content(view) %][% item.endtag %] .Ve .PP To render out the start tag, followed by the content rendered in the view \*(L"view\*(R", followed by the end tag. .SH "AUTHORS" .IX Header "AUTHORS" This plugin module was written by Andy Wardley. .PP The XML::XPath module is by Matt Sergeant. .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 1996\-2006 Andy Wardley. All Rights Reserved. .PP This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "SEE ALSO" .IX Header "SEE ALSO" Template::Plugin, XML::XPath, XML::Parser