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