arabica/include/XSLT/impl/xslt_template.hpp

78 lines
2.1 KiB
C++
Raw Normal View History

2007-07-19 19:01:42 +02:00
#ifndef ARABICA_XSLT_TEMPLATE_HPP
#define ARABICA_XSLT_TEMPLATE_HPP
#include "xslt_item.hpp"
#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),
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,
const Precedence& precedence) :
2007-07-19 19:01:42 +02:00
matches_(matches),
name_(name),
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)
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_; }
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_;
const Precedence precedence_;
2007-07-19 19:01:42 +02:00
}; // class Template
} // namespace XSLT
} // namespace Arabica
#endif // ARABICA_XSLT_TEMPLATE_HPP