diff --git a/include/XSLT/impl/handler/xslt_inline_element_handler.hpp b/include/XSLT/impl/handler/xslt_inline_element_handler.hpp index 750b761b..4ccaf5b9 100644 --- a/include/XSLT/impl/handler/xslt_inline_element_handler.hpp +++ b/include/XSLT/impl/handler/xslt_inline_element_handler.hpp @@ -10,21 +10,22 @@ namespace Arabica namespace XSLT { -class InlineElementHandler : public ItemContainerHandler +template +class InlineElementHandler : public ItemContainerHandler > { public: - InlineElementHandler(CompilationContext& context) : - ItemContainerHandler(context) + InlineElementHandler(CompilationContext& context) : + ItemContainerHandler >(context) { } // InlineElementHandler protected: - virtual InlineElement* createContainer(const std::string& namespaceURI, - const std::string& localName, - const std::string& qName, - const SAX::Attributes& atts) + virtual InlineElement* createContainer(const string_type& namespaceURI, + const string_type& localName, + const string_type& qName, + const SAX::Attributes& atts) { - std::vector inlineAtts; + std::vector > inlineAtts; for(int i = 0; i != atts.getLength(); ++i) { if(atts.getQName(i).find("xmlns:") == 0) @@ -32,45 +33,48 @@ protected: if(atts.getURI(i) == StylesheetConstant::NamespaceURI()) continue; if(!context().isRemapped(atts.getURI(i))) - inlineAtts.push_back(InlineAttribute(atts.getQName(i), + inlineAtts.push_back(InlineAttribute(atts.getQName(i), atts.getURI(i), context().xpath_attribute_value_template(atts.getValue(i)))); else { - std::pair remap = context().remappedNamespace(atts.getURI(i)); + std::pair remap = context().remappedNamespace(atts.getURI(i)); if(remap.first.empty() && !remap.second.empty()) remap.first = context().autoNamespacePrefix(); - std::string name = remap.first + ":" + atts.getLocalName(i); - inlineAtts.push_back(InlineAttribute(name, + string_type name = remap.first + ":" + atts.getLocalName(i); + inlineAtts.push_back(InlineAttribute(name, remap.second, context().xpath_attribute_value_template(atts.getValue(i)))); } // if ... } // for ... if(!context().isRemapped(namespaceURI)) - return new InlineElement(qName, namespaceURI, inlineAtts); + return new InlineElement(qName, namespaceURI, inlineAtts); - const std::pair& remap = context().remappedNamespace(namespaceURI); - std::string name = remap.first + ":" + localName; - return new InlineElement(name, remap.second, inlineAtts); + const std::pair& remap = context().remappedNamespace(namespaceURI); + string_type name = remap.first + ":" + localName; + return new InlineElement(name, remap.second, inlineAtts); } // createContainer }; // class InlineElementHandler -class LREStylesheetHandler : public InlineElementHandler + +template +class LREStylesheetHandler : public InlineElementHandler { + typedef InlineElementHandler baseT; public: - LREStylesheetHandler(CompilationContext& context, Template* lreStylesheet) : - InlineElementHandler(context), + LREStylesheetHandler(CompilationContext& context, Template* lreStylesheet) : + baseT(context), lreStylesheet_(lreStylesheet) { } // LREStylesheetHandler - virtual void endElement(const std::string& namespaceURI, - const std::string& localName, - const std::string& qName) + virtual void endElement(const string_type& namespaceURI, + const string_type& localName, + const string_type& qName) { - context().stylesheet().add_template(lreStylesheet_); - InlineElementHandler::endElement(namespaceURI, localName, qName); + baseT::context().stylesheet().add_template(lreStylesheet_); + baseT::endElement(namespaceURI, localName, qName); } // endElement private: diff --git a/include/XSLT/impl/handler/xslt_item_container_handler.hpp b/include/XSLT/impl/handler/xslt_item_container_handler.hpp index 402b71a1..231b96ee 100644 --- a/include/XSLT/impl/handler/xslt_item_container_handler.hpp +++ b/include/XSLT/impl/handler/xslt_item_container_handler.hpp @@ -163,7 +163,7 @@ const ChildElement* AllowedChildren() SAX::DefaultHandler* createInlineElementHandler(CompilationContext& context) { - return new InlineElementHandler(context); + return new InlineElementHandler >(context); } // InlineElementHandler diff --git a/include/XSLT/impl/xslt_inline_element.hpp b/include/XSLT/impl/xslt_inline_element.hpp index e792b196..e98e8aeb 100644 --- a/include/XSLT/impl/xslt_inline_element.hpp +++ b/include/XSLT/impl/xslt_inline_element.hpp @@ -9,12 +9,13 @@ namespace Arabica namespace XSLT { +template class InlineAttribute { public: - InlineAttribute(const std::string& name, - const std::string& name_space, - Arabica::XPath::XPathExpressionPtr value) : + InlineAttribute(const string_type& name, + const string_type& name_space, + Arabica::XPath::XPathExpressionPtr value) : name_(name), namespace_(name_space), value_(value) @@ -36,7 +37,7 @@ public: return *this; } // operator== - void execute(const DOM::Node& node, ExecutionContext& context) const + void execute(const DOM::Node& node, ExecutionContext& context) const { context.sink().start_attribute(name_, namespace_); context.sink().characters(value_->evaluateAsString(node, context.xpathContext())); @@ -44,17 +45,18 @@ public: } // execute private: - std::string name_; - std::string namespace_; - Arabica::XPath::XPathExpressionPtr value_; + string_type name_; + string_type namespace_; + Arabica::XPath::XPathExpressionPtr value_; }; // class InlineAttribute +template class InlineElement : public ItemContainer { public: - InlineElement(const std::string& name, - const std::string& name_space, - const std::vector& attrs) : + InlineElement(const string_type& name, + const string_type& name_space, + const std::vector >& attrs) : name_(name), namespace_(name_space), attrs_(attrs) @@ -63,11 +65,11 @@ public: virtual ~InlineElement() { } - virtual void execute(const DOM::Node& node, ExecutionContext& context) const + virtual void execute(const DOM::Node& node, ExecutionContext& context) const { if(context.sink().start_element(name_, namespace_)) { - for(std::vector::const_iterator a = attrs_.begin(), ae = attrs_.end(); a != ae; ++a) + for(typename std::vector >::const_iterator a = attrs_.begin(), ae = attrs_.end(); a != ae; ++a) a->execute(node, context); ChainStackFrame frame(context); @@ -77,9 +79,9 @@ public: } // execute private: - std::string name_; - std::string namespace_; - std::vector attrs_; + string_type name_; + string_type namespace_; + std::vector > attrs_; }; // class InlineElement } // namespace XSLT diff --git a/include/XSLT/impl/xslt_stylesheet_compiler.hpp b/include/XSLT/impl/xslt_stylesheet_compiler.hpp index 76646e39..95e20992 100644 --- a/include/XSLT/impl/xslt_stylesheet_compiler.hpp +++ b/include/XSLT/impl/xslt_stylesheet_compiler.hpp @@ -126,7 +126,7 @@ private: Template* lreStylesheet = new Template(context_.xpath_match("/"), "", "", "", context_.precedence()); context_.push(lreStylesheet, - new LREStylesheetHandler(context_, lreStylesheet), + new LREStylesheetHandler(context_, lreStylesheet), namespaceURI, localName, qName,