#ifndef ARABICA_XSLT_INLINE_ELEMENT_HANDLER_HPP #define ARABICA_XSLT_INLINE_ELEMENT_HANDLER_HPP #include "../xslt_inline_element.hpp" #include "xslt_item_container_handler.hpp" #include "xslt_constants.hpp" namespace Arabica { namespace XSLT { template class InlineElementHandler : public ItemContainerHandler > { typedef ItemContainerHandler > baseT; public: InlineElementHandler(CompilationContext& context) : baseT(context) { } // InlineElementHandler protected: virtual InlineElement* createContainer(const string_type& namespaceURI, const string_type& localName, const string_type& qName, const SAX::Attributes& atts) { std::vector > inlineAtts; for(int i = 0; i != atts.getLength(); ++i) { if(atts.getQName(i).find("xmlns:") == 0) continue; if(atts.getURI(i) == StylesheetConstant::NamespaceURI()) continue; if(!baseT::context().isRemapped(atts.getURI(i))) inlineAtts.push_back(InlineAttribute(atts.getQName(i), atts.getURI(i), baseT::context().xpath_attribute_value_template(atts.getValue(i)))); else { std::pair remap = baseT::context().remappedNamespace(atts.getURI(i)); if(remap.first.empty() && !remap.second.empty()) remap.first = baseT::context().autoNamespacePrefix(); string_type name = remap.first + ":" + atts.getLocalName(i); inlineAtts.push_back(InlineAttribute(name, remap.second, baseT::context().xpath_attribute_value_template(atts.getValue(i)))); } // if ... } // for ... if(!baseT::context().isRemapped(namespaceURI)) return new InlineElement(qName, namespaceURI, inlineAtts); const std::pair& remap = baseT::context().remappedNamespace(namespaceURI); string_type name = remap.first + ":" + localName; return new InlineElement(name, remap.second, inlineAtts); } // createContainer }; // class InlineElementHandler template class LREStylesheetHandler : public InlineElementHandler { typedef InlineElementHandler baseT; public: LREStylesheetHandler(CompilationContext& context, Template* lreStylesheet) : baseT(context), lreStylesheet_(lreStylesheet) { } // LREStylesheetHandler virtual void endElement(const string_type& namespaceURI, const string_type& localName, const string_type& qName) { baseT::context().stylesheet().add_template(lreStylesheet_); baseT::endElement(namespaceURI, localName, qName); } // endElement private: Template* lreStylesheet_; }; // class LREStylesheetHandler } // namespace XSLT } // namespace Arabica #endif