arabica/include/XSLT/impl/xslt_template.hpp

71 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
{
class Template : public ItemContainer
{
public:
2007-10-26 14:28:48 +02:00
Template(const std::pair<std::string, std::string>& name,
const std::pair<std::string, std::string>& mode,
const std::string& priority,
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
Template(const std::vector<Arabica::XPath::MatchExpr<std::string> >& matches,
2007-10-26 14:28:48 +02:00
const std::pair<std::string, std::string>& name,
2007-10-26 21:12:27 +02:00
const std::pair<std::string, std::string>& mode,
const std::string& 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
{
if(!priority.empty())
{
double p = boost::lexical_cast<double>(Arabica::text::normalize_whitespace<std::string, Arabica::default_string_adaptor<std::string> >(priority));
2007-07-19 19:01:42 +02:00
for(std::vector<Arabica::XPath::MatchExpr<std::string> >::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
virtual void execute(const DOM::Node<std::string>& node, ExecutionContext& context) const
{
execute_children(node, context);
} // execute
const std::vector<Arabica::XPath::MatchExpr<std::string> >& compiled_matches() const { return matches_; }
2007-10-26 14:28:48 +02:00
bool has_name() const { return !name_.second.empty(); }
const std::pair<std::string, std::string>& name() const { return name_; }
2007-10-26 21:12:27 +02:00
const std::pair<std::string, std::string>& mode() const { return mode_; }
const Precedence& precedence() const { return precedence_; }
2007-07-19 19:01:42 +02:00
private:
std::vector<Arabica::XPath::MatchExpr<std::string> > matches_;
2007-10-26 14:28:48 +02:00
std::pair<std::string, std::string> name_;
2007-10-26 21:12:27 +02:00
std::pair<std::string, std::string> mode_;
const Precedence precedence_;
2007-07-19 19:01:42 +02:00
}; // class Template
} // namespace XSLT
} // namespace Arabica
#endif // ARABICA_XSLT_TEMPLATE_HPP