diff --git a/include/XSLT/impl/xslt_param.hpp b/include/XSLT/impl/xslt_param.hpp index 4ad8c756..a367bb3a 100644 --- a/include/XSLT/impl/xslt_param.hpp +++ b/include/XSLT/impl/xslt_param.hpp @@ -27,6 +27,26 @@ protected: } // declare }; // Param + +class GlobalParam : public Variable_impl +{ +public: + GlobalParam(const std::string& name, + const Arabica::XPath::XPathExpressionPtr& select, + const Precedence& precedence) : + Variable_impl(name, select, precedence) + { + } // GlobalParam + + virtual ~GlobalParam() { } + +protected: + virtual void execute(const DOM::Node& node, ExecutionContext& context) const + { + context.declareParam(node, *this); + } // declare +}; // GlobalParam + } // namespace XSLT } // namespace Arabica #endif diff --git a/include/XSLT/impl/xslt_stylesheet_compiler.hpp b/include/XSLT/impl/xslt_stylesheet_compiler.hpp index 3b2b56fd..9b047bff 100755 --- a/include/XSLT/impl/xslt_stylesheet_compiler.hpp +++ b/include/XSLT/impl/xslt_stylesheet_compiler.hpp @@ -196,11 +196,11 @@ const ChildElement StylesheetHandler::allowedChildren[] = { "key", CreateHandler}, { "namespace-alias", CreateHandler}, { "output", CreateHandler}, - { "param", CreateHandler >}, + { "param", CreateHandler >}, { "preserve-space", CreateHandler}, { "strip-space", CreateHandler}, { "template", CreateHandler }, - { "variable", CreateHandler > }, + { "variable", CreateHandler > }, { 0, 0 } }; // StylesheetHandler::allowedChildren diff --git a/include/XSLT/impl/xslt_variable.hpp b/include/XSLT/impl/xslt_variable.hpp index 133022e6..672b7e1f 100644 --- a/include/XSLT/impl/xslt_variable.hpp +++ b/include/XSLT/impl/xslt_variable.hpp @@ -26,6 +26,24 @@ public: } // declare }; // Variable +class GlobalVariable : public Variable_impl +{ +public: + GlobalVariable(const std::string& name, + const Arabica::XPath::XPathExpressionPtr& select, + const Precedence precedence) : + Variable_impl(name, select, precedence) + { + } // Variable + + virtual ~GlobalVariable() { } + + virtual void execute(const DOM::Node& node, ExecutionContext& context) const + { + context.declareVariable(node, *this); + } // declare +}; // class GlobalVariable + } // namespace XSLT } // namespace Arabica #endif diff --git a/include/XSLT/impl/xslt_variable_stack.hpp b/include/XSLT/impl/xslt_variable_stack.hpp index 9b5b2ba6..cca1a118 100755 --- a/include/XSLT/impl/xslt_variable_stack.hpp +++ b/include/XSLT/impl/xslt_variable_stack.hpp @@ -12,7 +12,7 @@ namespace XSLT { class Variable_instance; -typedef boost::shared_ptr Variable_instance_ptr; +typedef Variable_instance* Variable_instance_ptr; typedef std::map Scope; class Variable_instance diff --git a/tests/XSLT/TO-DO b/tests/XSLT/TO-DO index b12d1162..99537c67 100644 --- a/tests/XSLT/TO-DO +++ b/tests/XSLT/TO-DO @@ -1,3 +1,12 @@ +Introduce GlobalVariable and GlobalParam. +Rename Variable_instance to DeclaredVariable. +Get rid of Variable_declaration. Variables should implement Variable_instance. +Normal variables don't bother with injectGlobalScope, GlobalVariables do. +Variables become their own closures. Forget all the ref counting nonsense, it is not necessary. +Normal variables resolve immediately and push themselves on the stack. +GlobalVariables resolve on demand. + +==================================================== Elements test suite Errors test suite