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

56 lines
2.1 KiB
C++
Raw Normal View History

2007-07-19 19:01:42 +02:00
#ifndef ARABICA_XSLT_ELEMENT_HANDLER_HPP
#define ARABICA_XSLT_ELEMENT_HANDLER_HPP
#include "../xslt_element.hpp"
#include "xslt_item_container_handler.hpp"
namespace Arabica
{
namespace XSLT
{
2012-11-04 09:38:48 +01:00
template<class string_type, class string_adaptor>
class ElementHandler : public ItemContainerHandler<Element<string_type, string_adaptor> >
2007-07-19 19:01:42 +02:00
{
2012-11-04 09:38:48 +01:00
typedef ItemContainerHandler<Element<string_type, string_adaptor> > baseT;
2007-07-19 19:01:42 +02:00
public:
2012-11-04 09:38:48 +01:00
ElementHandler(CompilationContext<string_type, string_adaptor>& context) :
ItemContainerHandler<Element<string_type, string_adaptor> >(context)
2007-07-19 19:01:42 +02:00
{
} // ElementHandler
protected:
2012-11-04 09:38:48 +01:00
virtual Element<string_type, string_adaptor>* createContainer(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
{
2010-01-10 22:25:35 +01:00
static const ValueRule rules[] = { { "name", true, 0, 0 },
{ "namespace", false, "", 0 },
2010-01-10 22:25:35 +01:00
{ "use-attribute-sets", false, 0, 0 },
{ 0, false, 0, 0 } };
2007-07-19 19:01:42 +02:00
2012-11-04 09:38:48 +01:00
std::map<string_type, string_type> attrs = gatherAttributes(qName, atts, rules);
2007-07-19 19:01:42 +02:00
2012-11-04 09:38:48 +01:00
Arabica::XPath::XPathExpressionPtr<string_type, string_adaptor> name = baseT::context().xpath_attribute_value_template(attrs["name"]);
2007-07-19 19:01:42 +02:00
if(attrs["use-attribute-sets"] != "")
throw SAX::SAXException("don't understand use-attribute-sets yet");
if(attrs["namespace"] == "")
2012-11-04 09:38:48 +01:00
return new Element<string_type, string_adaptor>(name,
baseT::context().inScopeNamespaces(),
2007-07-19 19:01:42 +02:00
attrs["use-attribute-sets"]);
2012-11-04 09:38:48 +01:00
return new Element<string_type, string_adaptor>(name,
baseT::context().xpath_attribute_value_template(attrs["namespace"]),
2007-07-19 19:01:42 +02:00
attrs["use-attribute-sets"]);
} // createContainer
}; // class ElementHandler
} // namespace XSLT
} // namespace Arabica
#endif