The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
[%#
  # IMPORTANT NOTE
  #   This documentation is generated automatically from source
  #   templates.  Any changes you make here may be lost.
  # 
  #   The 'docsrc' documentation source bundle is available for download
  #   from http://www.template-toolkit.org/docs.html and contains all
  #   the source templates, XML files, scripts, etc., from which the
  #   documentation for the Template Toolkit is built.
-%]
[% META book = 'Modules'
        page = 'Plugin_XML_Style'
%]
[%  WRAPPER toc;
	PROCESS tocitem 
	        title ="SYNOPSIS"
                subs  = [];
	PROCESS tocitem 
	        title ="DESCRIPTION"
                subs  = [];
	PROCESS tocitem 
	        title ="AUTHOR"
                subs  = [];
	PROCESS tocitem 
	        title ="VERSION"
                subs  = [];
	PROCESS tocitem 
	        title ="COPYRIGHT"
                subs  = [];
	PROCESS tocitem 
	        title ="SEE ALSO"
                subs  = [];
    END
%]
<!-- Pod to HTML conversion by the Template Toolkit version 2 -->
[% WRAPPER section
    title="SYNOPSIS"
-%]<pre>    [% tt_start_tag %] USE xmlstyle 
           table = { 
               attributes = { 
                   border      = 0
                   cellpadding = 4
                   cellspacing = 1
               }
           }
    [% tt_end_tag %]</pre>
<pre>    [% tt_start_tag %] FILTER xmlstyle [% tt_end_tag %]
    &lt;table&gt;
    &lt;tr&gt;
      &lt;td&gt;Foo&lt;/td&gt; &lt;td&gt;Bar&lt;/td&gt; &lt;td&gt;Baz&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
    [% tt_start_tag %] END [% tt_end_tag %]</pre>
[%- END %]
[% WRAPPER section
    title="DESCRIPTION"
-%]<p>
This plugin defines a filter for performing simple stylesheet based 
transformations of XML text.  
</p>
<p>
Named parameters are used to define those XML elements which require
transformation.  These may be specified with the USE directive when
the plugin is loaded and/or with the FILTER directive when the plugin
is used.
</p>
<p>
This example shows how the default attributes <code>'border=&quot;0&quot;'</code> and
<code>'cellpadding=&quot;4&quot;'</code> can be added to &lt;table&gt; elements.
</p>
<pre>    [% tt_start_tag %] USE xmlstyle 
           table = { 
               attributes = { 
                   border      = 0
                   cellpadding = 4
               }
           }
    [% tt_end_tag %]</pre>
<pre>    [% tt_start_tag %] FILTER xmlstyle [% tt_end_tag %]
    &lt;table&gt;
       ...
    &lt;/table&gt;
    [% tt_start_tag %] END [% tt_end_tag %]</pre>
<p>
This produces the output:
</p>
<pre>    &lt;table border=&quot;0&quot; cellpadding=&quot;4&quot;&gt;
       ...
    &lt;/table&gt;</pre>
<p>
Parameters specified within the USE directive are applied automatically each
time the <code>'xmlstyle'</code> FILTER is used.  Additional parameters passed to the 
FILTER directive apply for only that block.
</p>
<pre>    [% tt_start_tag %] USE xmlstyle 
           table = { 
               attributes = { 
                   border      = 0
                   cellpadding = 4
               }
           }
    [% tt_end_tag %]</pre>
<pre>    [% tt_start_tag %] FILTER xmlstyle
           tr = {
               attributes = {
                   valign=&quot;top&quot;
               }
           }
    [% tt_end_tag %]
    &lt;table&gt;
       &lt;tr&gt;
         ...
       &lt;/tr&gt;
    &lt;/table&gt;
    [% tt_start_tag %] END [% tt_end_tag %]</pre>
<p>
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.
</p>
<pre>    [% tt_start_tag %] style_one = {
          table = { ... }
          tr    = { ... }
       }
       style_two = {
          table = { ... }
          td    = { ... }
       }
       style_three = {
          th = { ... }
          tv = { ... }
       }
    [% tt_end_tag %]</pre>
<pre>    [% tt_start_tag %] USE xmlstyle style_one [% tt_end_tag %]</pre>
<pre>    [% tt_start_tag %] FILTER xmlstyle style_two [% tt_end_tag %]
       # style_one and style_two applied here 
    [% tt_start_tag %] END [% tt_end_tag %]
      
    [% tt_start_tag %] FILTER xmlstyle style_three [% tt_end_tag %]
       # style_one and style_three applied here 
    [% tt_start_tag %] END [% tt_end_tag %]</pre>
<p>
Any attributes defined within the source tags will override those specified
in the style sheet.
</p>
<pre>    [% tt_start_tag %] USE xmlstyle 
           div = { attributes = { align = 'left' } } 
    [% tt_end_tag %]</pre>
<pre>    [% tt_start_tag %] FILTER xmlstyle [% tt_end_tag %]
    &lt;div&gt;foo&lt;/div&gt;
    &lt;div align=&quot;right&quot;&gt;bar&lt;/div&gt;
    [% tt_start_tag %] END [% tt_end_tag %]</pre>
<p>
The output produced is:
</p>
<pre>    &lt;div align=&quot;left&quot;&gt;foo&lt;/div&gt;
    &lt;div align=&quot;right&quot;&gt;bar&lt;/div&gt;</pre>
<p>
The filter can also be used to change the element from one type to another.
</p>
<pre>    [% tt_start_tag %] FILTER xmlstyle 
              th = { 
                  element = 'td'
                  attributes = { bgcolor='red' }
              }
    [% tt_end_tag %]
    &lt;tr&gt;
      &lt;th&gt;Heading&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Value&lt;/td&gt;
    &lt;/tr&gt;
    [% tt_start_tag %] END [% tt_end_tag %]</pre>
<p>
The output here is as follows.  Notice how the end tag <code>'&lt;/th&gt;'</code> is
changed to <code>'&lt;/td&gt;'</code> as well as the start tag.
</p>
<pre>    &lt;tr&gt;
      &lt;td bgcolor=&quot;red&quot;&gt;Heading&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Value&lt;/td&gt;
    &lt;/tr&gt;</pre>
<p>
You can also define text to be added immediately before or after the 
start or end tags.  For example:
</p>
<pre>    [% tt_start_tag %] FILTER xmlstyle 
              table = {
                  pre_start = '&lt;div align=&quot;center&quot;&gt;'
                  post_end  = '&lt;/div&gt;'
              }
              th = { 
                  element    = 'td'
                  attributes = { bgcolor='red' }
                  post_start = '&lt;b&gt;'
                  pre_end    = '&lt;/b&gt;'
              }
    [% tt_end_tag %]
    &lt;table&gt;
    &lt;tr&gt;
      &lt;th&gt;Heading&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Value&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
    [% tt_start_tag %] END [% tt_end_tag %]</pre>
<p>
The output produced is:
</p>
<pre>    &lt;div align=&quot;center&quot;&gt;
    &lt;table&gt;
    &lt;tr&gt;
      &lt;td bgcolor=&quot;red&quot;&gt;&lt;b&gt;Heading&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Value&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
    &lt;/div&gt;</pre>
[%- END %]
[% WRAPPER section
    title="AUTHOR"
-%]<p>
Andy Wardley &lt;abw@andywardley.com&gt;
</p>
<p>
[% ttlink('http://www.andywardley.com/', 'http://www.andywardley.com/') -%]
</p>
[%- END %]
[% WRAPPER section
    title="VERSION"
-%]<p>
2.22, distributed as part of the
Template Toolkit version 2.08, released on 30 July 2002.
</p>
[%- END %]
[% WRAPPER section
    title="COPYRIGHT"
-%]<pre>  Copyright (C) 1996-2002 Andy Wardley.  All Rights Reserved.
  Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.</pre>
<p>
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
</p>
[%- END %]
[% WRAPPER section
    title="SEE ALSO"
-%]<p>
[% ttlink('Template::Plugin', 'Template::Plugin') -%]
</p>
[%- END %]