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

79 lines
2.4 KiB
C++
Raw Normal View History

2007-07-19 19:01:42 +02:00
#ifndef ARABICA_XSLT_CALL_TEMPLATE_HANDLER_HPP
#define ARABICA_XSLT_CALL_TEMPLATE_HANDLER_HPP
#include "../xslt_call_template.hpp"
#include "xslt_with_param_handler.hpp"
namespace Arabica
{
namespace XSLT
{
2012-11-04 23:34:40 +01:00
template<class stringT, class adaptorT>
class CallTemplateHandler : public SAX::DefaultHandler<stringT, adaptorT>
2007-07-19 19:01:42 +02:00
{
public:
2012-11-04 23:34:40 +01:00
typedef stringT string_type;
typedef adaptorT string_adaptor;
2012-11-02 23:52:42 +01:00
CallTemplateHandler(CompilationContext<string_type, string_adaptor>& context) :
2007-07-19 19:01:42 +02:00
context_(context),
callTemplate_(0)
{
} // CallTemplateHandler
2012-11-02 23:52:42 +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)
2007-07-19 19:01:42 +02:00
{
if(callTemplate_ == 0)
{
2010-01-10 22:25:35 +01:00
static const ValueRule rules[] = { { "name", true, 0, 0 },
{ 0, false, 0, 0 } };
2007-10-26 14:28:48 +02:00
2012-11-02 23:52:42 +01:00
std::map<string_type, string_type> attrs = gatherAttributes(qName, atts, rules);
2007-10-26 14:28:48 +02:00
2012-11-02 23:52:42 +01:00
string_type name = context_.processInternalQName(attrs["name"]).clarkName();
2007-07-19 19:01:42 +02:00
2012-11-02 23:52:42 +01:00
callTemplate_ = new CallTemplate<string_type, string_adaptor>(name);
2007-07-19 19:01:42 +02:00
return;
} // if(callTemplate_ == 0)
if((namespaceURI == StylesheetConstant::NamespaceURI()) && (localName == "with-param"))
{
context_.push(0,
2012-11-06 09:11:27 +01:00
new WithParamHandler<string_type, string_adaptor>(context_, *callTemplate_),
2007-07-19 19:01:42 +02:00
namespaceURI,
localName,
qName,
2007-07-19 19:01:42 +02:00
atts);
return;
} // if(localName == "with-param")
2010-05-19 21:22:22 +02:00
throw SAX::SAXException("xsl:call-template can only contain xsl:sort and xsl:with-param elements.");
2007-07-19 19:01:42 +02:00
} // startElement
2012-11-02 23:52:42 +01:00
virtual void endElement(const string_type& /* namespaceURI */,
const string_type& /* localName */,
const string_type& /* qName */)
2007-07-19 19:01:42 +02:00
{
context_.parentContainer().add_item(callTemplate_);
context_.pop();
} // endElement
2012-11-02 23:52:42 +01:00
virtual void characters(const string_type& /* ch */)
2007-07-19 19:01:42 +02:00
{
} // characters
private:
2012-11-02 23:52:42 +01:00
CompilationContext<string_type, string_adaptor>& context_;
CallTemplate<string_type, string_adaptor>* callTemplate_;
2007-07-19 19:01:42 +02:00
}; // class CallTemplateHandler
} // namespace XSLT
} // namespace Arabica
#endif // ARABICA_XSLT_CALL_TEMPLATE_HANDLER_HPP