Processors in Caparse.pm
Caparse
Webber processor, version 1.69.
This progran must run inside Webber.
Parses source files in HTML/XML and extracts from them values for Webber
variables. It modifies any Webber variable, as defined below.
Caparse should be used as (one of) the first pre-processor(s).
Caparse uses the following Webber variables:
#caparse.source: Defines a list of sources to be parsed for extracting
variable values. The format of a source specification is:
CLASS:NAME
Where CLASS can be either "var" (the source is a Webber
variable) or "file" (the source is a file), and NAME
identifies the source.
If this variable does not exist, the file identified by
#wbbSource is parsed.
#caparse.spec: Specifies how the results of parsing source files should be
assigned to Webber variables.
The value of #caparse.spec is composed of a series of <var> tags, each one
of them containing a list of variable names. According to the attributes of
the <var> tag, the values of these variables are assigned by Caparse.
The attributes recognized for the <var> tag are:
element -> Identifies the element of the source file(s) to be used when
building the variable values. The special element "comment"
may be used for comment processing.
mode -> Defines how the values extracted from elements are composed to
build the variable values. This attribute may have one of
the following values:
first -> Use only the first value found when parsing the
source file(s).
last -> Use only the last value found when parsing the
source file(s).
compose -> Compose all the values found, using the string
defined by the attribute "separator". If this
attribute is not used, the string " " is used by
default.
array -> Compose all the values found, building a string
that can be later used for a Perl list assignment
using an 'eval' statement.
assign -> Defines how the extracted value must be assigned to the
Webber variable. This attribute may have one of the following
values:
overwrite -> The value overwrites the previous value (if any)
of the variable (just like `=' in Webber source
files). This is the default.
append -> The value is appended to the previous value (if
any) of the variable (just like `+' in Webber
source files).
prepend -> The value is prepended to the previous value (if
any) of the variable (just like `*' in Webber
source files).
separator -> Defines the string to be used for composing values.
attr -> If this attribute is used, variable extraction is performed
for the attributes of the element, and not for its content.
The value of this attribute is a comma-separated list of
element attribute names to be read.
attseparator -> If the attribute "attr" is used, this attribute specifies
the string to be used for composing an individual value from
the values of the element attributes. It defaults to " ".
For example, assume we want to assign to #wbbIn the contents of all the body
elements in file "src.hsr" and in variable #caparseSrc, keeping their image
names and sources into a list that can be built using the contents of variable
#imgList.
The corresponding definitions for Caparse should be:
#caparse.source= file:src.hsr var:caparseSrc
#caparse.spec=
<var element="body" mode="compose" separator="<p>">
wbbIn
</var>
<var element="img" attr="name,src" attseparator=": " mode="array">
imgList
</var>