2007-07-19 19:01:42 +02:00
|
|
|
#ifndef ARABICA_XSLT_VARIABLE_IMPL_HPP
|
|
|
|
#define ARABICA_XSLT_VARIABLE_IMPL_HPP
|
|
|
|
|
|
|
|
#include <XPath/XPath.hpp>
|
|
|
|
#include <memory>
|
|
|
|
#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& namespace_uri,
|
|
|
|
const std::string& name,
|
2008-11-19 18:26:07 +01:00
|
|
|
Arabica::XPath::XPathExpressionPtr<std::string> select,
|
|
|
|
const Precedence& precedence) :
|
2007-07-19 19:01:42 +02:00
|
|
|
namespace_uri_(namespace_uri),
|
|
|
|
name_(name),
|
2008-11-19 18:26:07 +01:00
|
|
|
select_(select),
|
|
|
|
precedence_(precedence)
|
2007-07-19 19:01:42 +02:00
|
|
|
{
|
|
|
|
} // Variable_impl
|
|
|
|
|
|
|
|
virtual ~Variable_impl() { }
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual const std::string& namespace_uri() const { return namespace_uri_; }
|
|
|
|
virtual const std::string& name() const { return name_; }
|
|
|
|
|
2007-10-22 19:42:50 +02:00
|
|
|
virtual Arabica::XPath::XPathValue<std::string> value(const DOM::Node<std::string>& node,
|
|
|
|
ExecutionContext& context,
|
|
|
|
DOMSink& sink) const
|
2007-07-19 19:01:42 +02:00
|
|
|
{
|
|
|
|
if(select_)
|
|
|
|
return select_->evaluate(node, context.xpathContext());
|
|
|
|
|
|
|
|
execute_children(node, context);
|
|
|
|
|
|
|
|
if(sink.node() == 0)
|
|
|
|
return Arabica::XPath::StringValue<std::string, Arabica::default_string_adaptor<std::string> >::createValue("");
|
|
|
|
|
|
|
|
Arabica::XPath::NodeSet<std::string> nodeset;
|
|
|
|
for(DOM::Node<std::string> n = sink.node().getFirstChild(); n != 0; n = n.getNextSibling())
|
|
|
|
nodeset.push_back(n);
|
|
|
|
|
|
|
|
return Arabica::XPath::NodeSetValue<std::string, Arabica::default_string_adaptor<std::string> >::createValue(nodeset);
|
|
|
|
} // value
|
|
|
|
|
2008-11-19 18:26:07 +01:00
|
|
|
virtual const Precedence& precedence() const { return precedence_; }
|
|
|
|
|
2007-07-19 19:01:42 +02:00
|
|
|
private:
|
|
|
|
std::string namespace_uri_;
|
|
|
|
std::string name_;
|
|
|
|
Arabica::XPath::XPathExpressionPtr<std::string> select_;
|
2008-11-19 18:26:07 +01:00
|
|
|
Precedence precedence_;
|
2007-07-19 19:01:42 +02:00
|
|
|
}; // Variable_impl
|
|
|
|
|
|
|
|
} // namespace XSLT
|
|
|
|
} // namespace Arabica
|
|
|
|
#endif // ARABICA_XSLT_VARIABLE_IMPL_HPP
|
|
|
|
|