#ifndef ARABICA_XSLT_COPY_HANDLER_HPP #define ARABICA_XSLT_COPY_HANDLER_HPP #include "../xslt_copy.hpp" namespace Arabica { namespace XSLT { template class CopyHandler : public ItemContainerHandler > { typedef StylesheetConstant SC; typedef AttributeValidators AV; public: CopyHandler(CompilationContext& context) : ItemContainerHandler >(context) { } // CopyHandler virtual Copy* createContainer(const string_type& /* namespaceURI */, const string_type& /* localName */, const string_type& qName, const SAX::Attributes& atts) { static const AV rules = AV::rule(SC::use_attribute_sets, false); string_type sets = rules.gather(qName, atts)[SC::use_attribute_sets]; return new Copy(sets); } // createContainer }; // class WhenHandler template class CopyOfHandler : public SAX::DefaultHandler { typedef StylesheetConstant SC; typedef AttributeValidators AV; public: CopyOfHandler(CompilationContext& context) : context_(context), copyOf_(0) { } // CopyOfHandler virtual void startElement(const string_type& /* namespaceURI */, const string_type& /* localName */, const string_type& qName, const SAX::Attributes& atts) { if(copyOf_ == 0) { static const AV rules = AV::rule(SC::select, true); string_type select = rules.gather(qName, atts)[SC::select]; copyOf_ = new CopyOf(context_.xpath_expression(select)); return; } // if(copyOf_ == 0) throw SAX::SAXException(string_adaptor::asStdString(qName) + " can not contain elements"); } // startElement virtual void endElement(const string_type& /* namespaceURI */, const string_type& /* localName */, const string_type& /* qName */) { context_.parentContainer().add_item(copyOf_); context_.pop(); } // endElement virtual void characters(const string_type& ch) { verifyNoCharacterData(ch, SC::copy_of); } // characters private: CompilationContext& context_; CopyOf* copyOf_; }; // class CopyOfHandler } // namespace XSLT } // namespace Arabica #endif