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

50 lines
1.8 KiB
C++
Raw Normal View History

2007-07-19 19:01:42 +02:00
#ifndef ARABICA_XSLT_ATTRIBUTE_HANDLER_HPP
#define ARABICA_XSLT_ATTRIBUTE_HANDLER_HPP
#include "../xslt_attribute.hpp"
#include "xslt_item_container_handler.hpp"
namespace Arabica
{
namespace XSLT
{
2012-11-02 23:52:42 +01:00
template<class string_type, class string_adaptor>
class AttributeHandler : public ItemContainerHandler<Attribute<string_type, string_adaptor> >
2007-07-19 19:01:42 +02:00
{
2012-11-03 00:33:41 +01:00
typedef ItemContainerHandler<Attribute<string_type, string_adaptor> > baseT;
typedef StylesheetConstant<string_type, string_adaptor> SC;
2012-11-15 23:03:42 +01:00
typedef AttributeValidators<string_type, string_adaptor> AV;
2007-07-19 19:01:42 +02:00
public:
2012-11-02 23:52:42 +01:00
AttributeHandler(CompilationContext<string_type, string_adaptor>& context) :
2012-11-03 00:33:41 +01:00
baseT(context)
2007-07-19 19:01:42 +02:00
{
} // AttributeHandler
protected:
2012-11-02 23:52:42 +01:00
virtual Attribute<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
{
2012-11-15 23:03:42 +01:00
static const AV rules = AV::rule(SC::name, true)
.rule(SC::namespace_, false, string_adaptor::empty_string());
2007-07-19 19:01:42 +02:00
2012-11-15 23:03:42 +01:00
std::map<string_type, string_type> attrs = rules.gather(qName, atts);
2007-07-19 19:01:42 +02:00
Arabica::XPath::XPathExpressionPtr<string_type, string_adaptor> name =
baseT::context().xpath_attribute_value_template(attrs[SC::name]);
2007-07-19 19:01:42 +02:00
if(attrs[SC::namespace_] == string_adaptor::empty_string())
2012-11-03 00:33:41 +01:00
return new Attribute<string_type, string_adaptor>(name, baseT::context().inScopeNamespaces());
2007-07-19 19:01:42 +02:00
return new Attribute<string_type, string_adaptor>(name, baseT::context().xpath_attribute_value_template(attrs[SC::namespace_]));
2007-07-19 19:01:42 +02:00
} // createContainer
}; // class AttributeHandler
} // namespace XSLT
} // namespace Arabica
#endif