.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" 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::Style 3pm" .TH Template::Plugin::XML::Style 3pm "2020-12-20" "perl v5.32.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::Style \- Simple XML stylesheet transfomations .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 9 \& [% USE xmlstyle \& table = { \& attributes = { \& border = 0 \& cellpadding = 4 \& cellspacing = 1 \& } \& } \& %] \& \& [% FILTER xmlstyle %] \& \& \& \& \&
Foo Bar Baz
\& [% END %] .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This plugin defines a filter for performing simple stylesheet based transformations of \s-1XML\s0 text. .PP Named parameters are used to define those \s-1XML\s0 elements which require transformation. These may be specified with the \s-1USE\s0 directive when the plugin is loaded and/or with the \s-1FILTER\s0 directive when the plugin is used. .PP This example shows how the default attributes \f(CW\*(C`border="0"\*(C'\fR and \&\f(CW\*(C`cellpadding="4"\*(C'\fR can be added to elements. .PP .Vb 8 \& [% USE xmlstyle \& table = { \& attributes = { \& border = 0 \& cellpadding = 4 \& } \& } \& %] \& \& [% FILTER xmlstyle %] \&
\& ... \&
\& [% END %] .Ve .PP This produces the output: .PP .Vb 3 \& \& ... \&
.Ve .PP Parameters specified within the \s-1USE\s0 directive are applied automatically each time the \f(CW\*(C`xmlstyle\*(C'\fR \s-1FILTER\s0 is used. Additional parameters passed to the \s-1FILTER\s0 directive apply for only that block. .PP .Vb 8 \& [% USE xmlstyle \& table = { \& attributes = { \& border = 0 \& cellpadding = 4 \& } \& } \& %] \& \& [% FILTER xmlstyle \& tr = { \& attributes = { \& valign="top" \& } \& } \& %] \& \& \& ... \& \&
\& [% END %] .Ve .PP Of course, you may prefer to define your stylesheet structures once and simply reference them by name. Passing a hash reference of named parameters is just the same as specifying the named parameters as far as the Template Toolkit is concerned. .PP .Vb 10 \& [% style_one = { \& table = { ... } \& tr = { ... } \& } \& style_two = { \& table = { ... } \& td = { ... } \& } \& style_three = { \& th = { ... } \& tv = { ... } \& } \& %] \& \& [% USE xmlstyle style_one %] \& \& [% FILTER xmlstyle style_two %] \& # style_one and style_two applied here \& [% END %] \& \& [% FILTER xmlstyle style_three %] \& # style_one and style_three applied here \& [% END %] .Ve .PP Any attributes defined within the source tags will override those specified in the style sheet. .PP .Vb 3 \& [% USE xmlstyle \& div = { attributes = { align = \*(Aqleft\*(Aq } } \& %] \& \& \& [% FILTER xmlstyle %] \&
foo
\&
bar
\& [% END %] .Ve .PP The output produced is: .PP .Vb 2 \&
foo
\&
bar
.Ve .PP The filter can also be used to change the element from one type to another. .PP .Vb 10 \& [% FILTER xmlstyle \& th = { \& element = \*(Aqtd\*(Aq \& attributes = { bgcolor=\*(Aqred\*(Aq } \& } \& %] \& \& Heading \& \& \& Value \& \& [% END %] .Ve .PP The output here is as follows. Notice how the end tag \&\f(CW\*(C`\*(C'\fR is changed to \f(CW\*(C`\*(C'\fR as well as the start tag. .PP .Vb 6 \& \& Heading \& \& \& Value \& .Ve .PP You can also define text to be added immediately before or after the start or end tags. For example: .PP .Vb 10 \& [% FILTER xmlstyle \& table = { \& pre_start = \*(Aq
\*(Aq \& post_end = \*(Aq
\*(Aq \& } \& th = { \& element = \*(Aqtd\*(Aq \& attributes = { bgcolor=\*(Aqred\*(Aq } \& post_start = \*(Aq\*(Aq \& pre_end = \*(Aq\*(Aq \& } \& %] \& \& \& \& \& \& \& \&
Heading
Value
\& [% END %] .Ve .PP The output produced is: .PP .Vb 10 \&
\& \& \& \& \& \& \& \&
Heading
Value
\&
.Ve .SH "AUTHOR" .IX Header "AUTHOR" Andy Wardley .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2001\-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