#ifndef ARABICA_XSLT_VARIABLE_IMPL_HPP #define ARABICA_XSLT_VARIABLE_IMPL_HPP #include #include #include "xslt_item.hpp" #include "xslt_execution_context.hpp" namespace Arabica { namespace XSLT { class Variable_impl : public ItemContainer, public Variable_declaration { protected: Variable_impl(const std::string& name, const Arabica::XPath::XPathExpressionPtr& select, const Precedence& precedence) : name_(name), select_(select), precedence_(precedence) { } // Variable_impl virtual ~Variable_impl() { } public: virtual const std::string& name() const { return name_; } virtual Arabica::XPath::XPathValue value(const DOM::Node& node, ExecutionContext& context, DOMSink& sink) const { if(select_) return select_->evaluate(node, context.xpathContext()); execute_children(node, context); if(sink.node() == 0) return Arabica::XPath::StringValue >::createValue(""); Arabica::XPath::NodeSet nodeset; for(DOM::Node n = sink.node().getFirstChild(); n != 0; n = n.getNextSibling()) nodeset.push_back(n); return Arabica::XPath::NodeSetValue >::createValue(nodeset); } // value virtual const Precedence& precedence() const { return precedence_; } private: std::string name_; Arabica::XPath::XPathExpressionPtr select_; Precedence precedence_; }; // Variable_impl } // namespace XSLT } // namespace Arabica #endif // ARABICA_XSLT_VARIABLE_IMPL_HPP