NAME
HTML::Object::XPath::Function - HTML Object XPath Functions
SYNOPSIS
use HTML::Object::XPath::Function;
my $func = HTML::Object::XPath::Function->new ||
die( HTML::Object::XPath::Function->error, "\n" );
VERSION
v0.2.0
DESCRIPTION
This module implements various XPath functions described below.
CONSTRUCTOR
Provided with a XPath object, a function name
and function parameters
and this will instantiate a new HTML::Object::Function object and return it.
METHODS
as_string
Returns a string representation of this function object.
as_xml
Returns a xml representation of this function object.
boolean
Provided with a node object and a list of parameters and this will return the first parameter as a boolean object. It will raise an exception if there are more than one arguments provided.
ceiling
Provided with a node object and an optional parameter, and this will return the ceiling of the string value of the node or that of the parameter provided, if any.
It returns its value as a new number object. It will raise an exception if more than one parameter was provided.
concat
Provided with a node object and a list of 2 parameters or more and this will return a new literal object from the concatenation of each parameter string value.
contains
Provided with a node object and a list of exactly 2 parameters and this will return true if the first parameter match the second one as a regular expression, or returns false otherwise.
count
Provided with a node object and a node set and this will return the size of the node set as a number
evaluate
Provided with a node object and this will evaluate the node using each parameter set during object instantiation and add the result for each in a new array.
It will then return the execution of the function name on the node passing it the list of previously collected results.
false
Returns false and it will raise an exception if any arguments was provided.
floor
Provided with a node object and an optional parameter, and this will return the floor of the string value of the node or that of the parameter provided, if any.
It returns its value as a new number object. It will raise an exception if more than one parameter was provided.
id
Provided with a node object and 1 parameter, and this will return a new node set of element object who match the id found in the node provided.
lang
Provided with a node object and 1 parameter, and this will return true if the node lang, if any at all, match the one provide as a parameter, otherwise it returns false.
last
This takes no argument and returns the size, as a number of the nodes in the context set in XPath.
local_name
Provided with a node object and optionally some parameter and this will return the local name of the node, or that of the first parameter provided, if any, as a literal object
name
Provided with a node object and optionally some parameter and this will return the name of the node, or that of the first parameter provided, if any, as a literal object
namespace_uri
This is an unsupported function and it will raise an exception when called.
new_literal
Returns a new literal object passing it whatever arguments was provided.
new_nodeset
Returns a new node set object passing it whatever arguments was provided.
new_number
Returns a new number object passing it whatever arguments was provided.
normalize_space
Provided with a node object and optionally some parameter and this will take the string value of the node, or that of the first parameter, if any at al, and remove any leading or trailing spaces as well as replacing multiple spaces by just one space, and return the new string as a literal object
not
Provided with a node object and one parameter and this will return true if the value of the first parameter is not true, or false otherwise.
number
Provided with a node object and optionally one parameter and this will return the node string value, or that of the parameter provided, if any, as a new number object
position
Returns th context position as a number. It will raise an exception if any parameter was provided.
round
starts_with
Provided with a node object and two parameters and this will return true if the string value of the second parameter is at the beginning of the first parameter, or false otherwise.
string
Provided with a node object and one parameter and this returns the parameter string value as a new literal object
It will raise an exception if more than one parameter was provided.
string_length
Provided with a node object and optionally one parameter and this will return the size, as a number, of the string value of the node or that of the parameter if any was provided.
substring
Provided with a node object and two or three parameters and this returns the substring of of the first parameter as a value, at offset specified by the second parameter, and optionally for a length defined by a third parameter, if any. If no third parameter is provided, then it will be until the end of the string.
It returns the substring as a new literal object. It will raise an exception if less than 2 or more than 3 parameters were provided.
substring_after
Provided with a node object and two parameters and this will return the string that follows the string value of the second parameter in the first one up to its end.
It returns the substring as a new literal object. It will raise an exception if less or more than 2 parameters were provided.
substring_before
Provided with a node object and two parameters and this will return the string that precede the string value of the second parameter in the first one up to its start.
It returns the substring as a new literal object. It will raise an exception if less or more than 2 parameters were provided.
sum
Provided with a node object and a parameters that must be a node set and this will return the cumulative string value of each node as a number.
It returns the resulting total as a new number object|HTML::Object::XPath::Number>. It will raise an exception if the parameter provided is not a HTML::Object::XPath::NodeSet object.
translate
Provided with a node object and three parameters, and this will search in the first parameter for any occurrence of characters found in the second parameter and replace them with their alternative at the exact same position in string in the third parameter.
It returns the substring as a new literal object. It will raise an exception if less or more than 3 parameters were provided.
true
Returns true and it will raise an exception if any arguments was provided.
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
HTML::Object::XPath, HTML::Object::XPath::Boolean, HTML::Object::XPath::Expr, HTML::Object::XPath::Function, HTML::Object::XPath::Literal, HTML::Object::XPath::LocationPath, HTML::Object::XPath::NodeSet, HTML::Object::XPath::Number, HTML::Object::XPath::Root, HTML::Object::XPath::Step, HTML::Object::XPath::Variable
COPYRIGHT & LICENSE
Copyright(c) 2021 DEGUEST Pte. Ltd.
All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.