XML::XSS::StyleAttribute - Style attribute for XML::XSS stylesheet rule
version 0.3.5
use XML::XSS; my $xss = XML::XSS->new; my $attribute = $xss->get('chapter')->pre; $attribute->set_value( '<div class="chapter">' );
The XML::XSS::StyleAttribute objects are the building blocks of the document transformation. They can be assigned a string, which is inserted verbatim in the rendered document
XML::XSS::StyleAttribute
$xss->get('chapter')->set_pre( '<div class="chapter">' );
or a sub reference, which return value is inserted in the rendered document
$xss->get('clock')->set_pre( sub { return "date and time are: " . localtime } );
Upon execution, the sub references will be passed three parameters: the invoking rule, the XML::LibXML::Node object currently rendered and the arguments ref given to render().
render()
$xss->set( 'div' => { intro => sub { my ( $self, $node, $args ) = @_; my @para = $node->findnodes( '@para' ); return "<p>node has " . @para . " para child nodes.</p>"; } } );
Assigns the right value to the attribue.
$xss.'chapter'.'pre' *= "<div class='chapter'>";
is equivalent to
$xss->set( chapter => { pre => "<div class='chapter'>" } );
Similar to '*=', but considers the right side as a template and converts it via xsst.
xsst
$xss.'chapter'.'pre' x= q{ <div class="chapter"> <% $r->stylesheet->stash{chapter_nbr}++ %> };
$xss->set( 'chapter' => { pre => xsst( <<'END_TEMPLATE' ) } ); <div class="chapter"> <% $r->stylesheet->stash{chapter_nbr}++ %> END_TEMPLATE
The string or sub reference used by the style attribute.
# long way $xss->get('chapter')->pre->set_value( '<div class="chapter">' ); # short way $xss->set( chapter => { pre => '<div class="chapter">' } ); # shortest way $xss.'chapter'.'pre' *= '<div class="chapter">';
Yanick Champoux <yanick@cpan.org>
This software is copyright (c) 2017, 2013, 2011, 2010 by Yanick Champoux.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install XML::XSS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::XSS
CPAN shell
perl -MCPAN -e shell install XML::XSS
For more information on module installation, please visit the detailed CPAN module installation guide.