2007-07-19 19:01:42 +02:00
|
|
|
#ifndef ARABICA_XSLT_TEMPLATE_HPP
|
|
|
|
#define ARABICA_XSLT_TEMPLATE_HPP
|
|
|
|
|
|
|
|
#include "xslt_item.hpp"
|
2008-11-05 03:57:18 +01:00
|
|
|
#include "xslt_precedence.hpp"
|
2007-07-19 19:01:42 +02:00
|
|
|
|
|
|
|
namespace Arabica
|
|
|
|
{
|
|
|
|
namespace XSLT
|
|
|
|
{
|
|
|
|
|
2012-11-06 08:50:57 +01:00
|
|
|
template<class stringT, class adaptorT>
|
2012-11-08 17:18:49 +01:00
|
|
|
class Template : public ItemContainer<stringT, adaptorT>
|
2007-07-19 19:01:42 +02:00
|
|
|
{
|
|
|
|
public:
|
2012-11-06 08:50:57 +01:00
|
|
|
typedef stringT string_type;
|
|
|
|
typedef adaptorT string_adaptor;
|
2012-11-04 23:34:40 +01:00
|
|
|
|
2012-11-06 08:50:57 +01:00
|
|
|
typedef Arabica::XPath::MatchExpr<string_type, string_adaptor> MatchExpr;
|
|
|
|
typedef std::vector<MatchExpr> MatchExprList;
|
|
|
|
|
|
|
|
Template(const string_type& name,
|
|
|
|
const string_type& mode,
|
|
|
|
const string_type& /* priority */,
|
2010-01-11 10:02:17 +01:00
|
|
|
const Precedence& precedence) :
|
2007-07-19 19:01:42 +02:00
|
|
|
matches_(),
|
|
|
|
name_(name),
|
2008-11-19 18:26:07 +01:00
|
|
|
mode_(mode),
|
|
|
|
precedence_(precedence)
|
2007-07-19 19:01:42 +02:00
|
|
|
{
|
|
|
|
} // Template
|
|
|
|
|
2012-11-06 08:50:57 +01:00
|
|
|
Template(const MatchExprList& matches,
|
|
|
|
const string_type& name,
|
|
|
|
const string_type& mode,
|
|
|
|
const string_type& priority,
|
2008-11-19 18:26:07 +01:00
|
|
|
const Precedence& precedence) :
|
2007-07-19 19:01:42 +02:00
|
|
|
matches_(matches),
|
|
|
|
name_(name),
|
2008-11-19 18:26:07 +01:00
|
|
|
mode_(mode),
|
|
|
|
precedence_(precedence)
|
2007-07-19 19:01:42 +02:00
|
|
|
{
|
2012-11-21 07:59:40 +01:00
|
|
|
if(!string_adaptor::empty(priority))
|
2007-07-19 19:01:42 +02:00
|
|
|
{
|
2012-11-06 08:50:57 +01:00
|
|
|
double p = boost::lexical_cast<double>(Arabica::text::normalize_whitespace<string_type, string_adaptor>(priority));
|
2012-11-06 08:53:00 +01:00
|
|
|
for(typename MatchExprList::iterator m = matches_.begin(), me = matches_.end(); m != me; ++m)
|
2007-10-14 22:06:27 +02:00
|
|
|
m->override_priority(p);
|
2007-07-19 19:01:42 +02:00
|
|
|
} // if ...
|
|
|
|
} // Template
|
|
|
|
|
|
|
|
virtual ~Template()
|
|
|
|
{
|
|
|
|
} // ~Template
|
|
|
|
|
2012-11-08 18:13:33 +01:00
|
|
|
virtual void execute(const DOM::Node<string_type, string_adaptor>& node, ExecutionContext<string_type, string_adaptor>& context) const
|
2007-07-19 19:01:42 +02:00
|
|
|
{
|
2013-01-05 22:26:35 +01:00
|
|
|
this->execute_children(node, context);
|
2007-07-19 19:01:42 +02:00
|
|
|
} // execute
|
|
|
|
|
2012-11-06 08:50:57 +01:00
|
|
|
const MatchExprList& compiled_matches() const { return matches_; }
|
2012-11-21 07:59:40 +01:00
|
|
|
bool has_name() const { return !string_adaptor::empty(name_); }
|
2012-11-06 08:50:57 +01:00
|
|
|
const string_type& name() const { return name_; }
|
|
|
|
const string_type& mode() const { return mode_; }
|
2008-11-19 18:26:07 +01:00
|
|
|
const Precedence& precedence() const { return precedence_; }
|
2007-07-19 19:01:42 +02:00
|
|
|
|
|
|
|
private:
|
2012-11-06 08:50:57 +01:00
|
|
|
MatchExprList matches_;
|
|
|
|
string_type name_;
|
|
|
|
string_type mode_;
|
2008-11-19 18:26:07 +01:00
|
|
|
const Precedence precedence_;
|
2007-07-19 19:01:42 +02:00
|
|
|
}; // class Template
|
|
|
|
|
|
|
|
} // namespace XSLT
|
|
|
|
} // namespace Arabica
|
|
|
|
|
|
|
|
#endif // ARABICA_XSLT_TEMPLATE_HPP
|
|
|
|
|