arabica/include/XSLT/impl/handler/xslt_apply_imports_handler.hpp

67 lines
1.8 KiB
C++
Raw Normal View History

#ifndef ARABICA_XSLT_APPLY_IMPORTS_HANDLER_HPP
#define ARABICA_XSLT_APPLY_IMPORTS_HANDLER_HPP
#include "../xslt_apply_imports.hpp"
namespace Arabica
{
namespace XSLT
{
2012-11-04 23:34:40 +01:00
template<class stringT, class adaptorT>
class ApplyImportsHandler : public SAX::DefaultHandler<stringT, adaptorT>
{
public:
2012-11-04 23:34:40 +01:00
typedef stringT string_type;
typedef adaptorT string_adaptor;
2012-11-03 00:16:43 +01:00
ApplyImportsHandler(CompilationContext<string_type, string_adaptor>& context):
context_(context),
applyImports_(0)
{
} // ApplyImportsHandler
~ApplyImportsHandler()
{
} // ~ApplyImportsHandler
2012-11-03 00:16:43 +01:00
virtual void startElement(const string_type& /* namespaceURI */,
const string_type& /* localName */,
const string_type& /* qName */,
const SAX::Attributes<string_type, string_adaptor>& atts)
{
if(applyImports_ == 0)
{
if(atts.getLength() != 0)
2012-11-03 00:16:43 +01:00
throw SAX::SAXException("xsl:apply-imports element does not have any attributes");
applyImports_ = new ApplyImports<string_type, string_adaptor>();
return;
} // if(applyImports_ == 0)
throw SAX::SAXException("xsl:apply-imports element must be empty");
} // startElement
2012-11-03 00:16:43 +01:00
virtual void endElement(const string_type& /* namespaceURI */,
const string_type& /* localName */,
const string_type& /* qName */)
{
context_.parentContainer().add_item(applyImports_);
context_.pop();
} // endElement
2012-11-03 00:16:43 +01:00
virtual void characters(const string_type& ch)
{
verifyNoCharacterData(ch, "xsl:apply-imports");
} // characters
private:
2012-11-03 00:16:43 +01:00
CompilationContext<string_type, string_adaptor>& context_;
ApplyImports<string_type, string_adaptor>* applyImports_;
}; // class ApplyImportsHandler
} // namespace XSLT
} // namespace Arabica
#endif