Apache::XPP::PreParse - XPP TAG Parser


 use Apache::XPP::PreParse;
 $preparsers    = Apache::XPP::PreParse->parsers;
 foreach (@{ $preparsers }) {
        $preparsers->( \$text );






Apache::XPP::PreParse handles pre parsing of an xpp page to convert 'tags' into valid XPML. Tags are meant as a shortcut for code that might otherwise be burdensome or confusing for and xpml author, such as ref checking before calling a method: <xpp method="cities_popup_menu" obj="$app"> might be converted to: <?xpp if (ref($app)) { print $app->cities_popup_menu; } ?>.


parsers ( )

Returns a new parser object

add_parser ( \&parser )

Adds a parser to the list of registered pre-parsers.

parse_tag ( $tag )

Given an xpp TAG $tag, will return an array with two elements. The first element is an array reference of the order of keys in the tag. The second element is a hash reference to the key-value pairs.

dtag ( \$text, $tag, $subref )

This is for processing tags with a start tag and seperate end tag. All the data in between is sent to $subref->( $params, $data) where $params is a hashref containing all the key value pairs in the start tag and $data is the data contained in between the opening and closing tag.


Called by stag to parse the matched tag with the supplied rules.

stag ( \$text, $match, \@replace_rules )

Given a string to match, uses the replace rules to replace tags that contain the $match with it's equivalent. See examples below for syntax of replace rules.


Used to comment out blocks of xpml code.

Ex: <XPPCOMMENT> <title><?= $obj->title() ?></title> </XPPCOMMENT>


Cache a block of code using a specific expire/store module. Pass the caches name, group, expire, and store. See xppcachetut.pod for more information.

Ex: <XPPCACHE name="mycache" group="cachegroup" store="File" expire="Duration, 10s"> .... </XPPCACHE>


Assign or print an object method. Ref checks the object before using it. Assigns the result to the value of the as tag parameter. If this param isn't present the result is printed.

Ex: <XPP app app="$obj" attr="bleh" as="$var"> <XPP app app="$obj" attr="bleh">


Prints the result of an object method.

Ex: <XPP print obj="$obj" attr="bleh">


Calls xinclude with the passed filename and options.

Ex: <XPP xinclude filename="include.xmi" options="$obj1, $obj2">


Places the included block within a foreach loop. Assigning each element of the array to 'as.' If 'as' is not present it uses $_.

Ex: <XPPFOREACH array="@ary" as="$val"> <XPPFOREACH array="@ary">


Places the included block within a while block, looping on the condition specified in 'condition'. If the option 'counter' is specified, the number of loops performed will be assigned to that scalar.

Ex: <XPPWHILE condition="my $bar = shift @foo" counter="$count"> Shifted off <?= $bar ?>.<BR> </XPPWHILE> I looped <?= $count ?> times.


Shifts one value off the given array (@_ if none is specified) and assigns the value to the specified scalar, scoped lexically (using my()).

Ex: <XPPSHIFT array="@ary" as="$val">


$Log:,v $ Revision 1.19 2002/01/16 21:06:01 kasei Updated VERSION variables to 2.01

Revision 1.18 2000/09/28 20:10:59 zhobson - Added parser_xppwhile and the <XPPWHILE> tag - Added parser_xppshift and the <XPPSHIFT> tag

Revision 1.17 2000/09/14 23:01:30 dougw Fixed stag pod.

Revision 1.16 2000/09/13 00:32:04 dougw Pod for tag methods.

Revision 1.15 2000/09/11 20:15:33 david Sent AUTOLOAD to Apache::XPP::AUTOLOAD.

Revision 1.14 2000/09/07 19:03:19 dougw over fix

Revision 1.13 2000/09/07 18:48:36 dougw Took out some use vars

Revision 1.12 2000/09/07 18:45:42 dougw Version Update.

Revision 1.11 2000/09/07 00:05:38 dougw POD fixes.


perl(1). tagtut






 Copyright (c) 2000, Cnation Inc. All Rights Reserved. This module is free
 software. It may be used, redistributed and/or modified under the terms
 of the GNU Lesser General Public License as published by the Free Software

 You should have received a copy of the GNU Lesser General Public License
 along with this library; if not, write to the Free Software 
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


Greg Williams <> Doug Weimer <>