WWW-Meta-XML-Browser
view release on metacpan or search on metacpan
=head4 DEFINING A REQUEST WITH CONTENT
The request-element has an optional child element, which can be used to specify the content of a request. The element is called content and is used as a child of the request element as follows (remember that & has to be written as & in XML):
<request url="http://www.google.de/search" method="get">
<content>q=42&ie=ISO-8859-1&hl=de&meta=</content>
</request>
This example shows that the content will be sent using the specified method (get in this case) to the url of the request (http://www.google.de/search).
=head4 EMBEDDED REQUESTS
Embedded request can be used to fetch pages from a result page. They can be created in the XSL stylesheet to dynamically parse a tree of pages.
As soon as a www-meta-xml-browser-request-element is created in the XSL stylesheet it is processed like a normal request-element and the result is inserted.
If the result consists of multiple pages the container-attribute has to be specified and is used as the new root for the merged (optionally transformed) pages.
=head3 REPLACEMENT EXPRESSIONS IN A SESSION DESCRIPTION FILE
There are some cases in which static urls and a static content don't fit the requirements of what has to be done.
my $XPATH_REGEXP = '\#(escape)*\{(\d+?):(.*?):(.+?)\}';
my $ARGS_REGEXP = '\#(escape)*\{args:(.*?)\}';
my $URL_ATTRIBUTE = 'url';
my $METHOD_ATTRIBUTE = 'method';
my $RESULT_CALLBACK_ATTRIBUTE = 'result-callback';
my $STYLESHEET_ATTRIBUTE = 'stylesheet';
my $CALLBACK_NAME_ATTRIBUTE = 'name';
my $EMBEDDED_REQUEST_CONTAINER_ATTRIBUTE = 'container';
my $XML_VERSION = '1.0';
my $USER_AGENT = "WWW::Meta::XML::Browser ".$VERSION;
my $TIMEOUT = 30;
=head1 METHODS
The following methods are available:
return &{$this->{result_doc_callback}}($doc);
}
=item $xml_string = process_embedded_request($embedded_request_node);
Processes an embedded request node, by processing it as a normal node (using L<process_request_node()>).
If the embedded request node returns only one XML document it is transformed to a string and returned.
If the embedded request node returns more than one XML documents they are merged unded the name specified by the C<$EMBEDDED_REQUEST_CONTAINER_ATTRIBUTE>-attribute of the embedded requst node.
=cut
sub process_embedded_request {
my $this = shift;
my ($er_node) = @_;
my $subrequest_result = $this->process_request_node($er_node);
if (scalar(@{$subrequest_result}) > 1) {
my $doc = $this->merge_xml_array($subrequest_result, $er_node->getAttribute($EMBEDDED_REQUEST_CONTAINER_ATTRIBUTE));
return $doc->documentElement()->toString();
}
else {
return ${$subrequest_result}[0]->documentElement()->toString();
}
}
=item $result = get_request_result($request_index, $subrequest_index);
( run in 1.052 second using v1.01-cache-2.11-cpan-2c0d6866c4f )