#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 { template class Variable_impl : public ItemContainer, public Variable_declaration { protected: typedef Arabica::XPath::XPathExpressionPtr XPathExpressionPtr; typedef Arabica::XPath::XPathValue XPathValue; typedef Arabica::XPath::StringValue StringValue; typedef Arabica::XPath::NodeSetValue NodeSetValue; typedef Arabica::XPath::NodeSet NodeSet; typedef DOM::Node DOMNode; Variable_impl(const string_type& name, const XPathExpressionPtr& select, const Precedence& precedence) : name_(name), select_(select), precedence_(precedence) { } // Variable_impl virtual ~Variable_impl() { } public: virtual const string_type& name() const { return name_; } virtual XPathValue value(const DOMNode& node, ExecutionContext& context, DOMSink& sink) const { if(select_) return select_->evaluate(node, context.xpathContext()); execute_children(node, context); if(sink.node() == 0) return StringValue::createValue(""); NodeSet nodeset; for(DOMNode n = sink.node().getFirstChild(); n != 0; n = n.getNextSibling()) nodeset.push_back(n); return NodeSetValue::createValue(nodeset); } // value virtual const Precedence& precedence() const { return precedence_; } private: string_type name_; XPathExpressionPtr select_; Precedence precedence_; }; // Variable_impl } // namespace XSLT } // namespace Arabica #endif // ARABICA_XSLT_VARIABLE_IMPL_HPP