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

64 lines
1.8 KiB
C++
Raw Normal View History

2007-07-19 19:01:42 +02:00
#ifndef ARABICA_XSLT_VALUE_OF_HANDLER_HPP
#define ARABICA_XSLT_VALUE_OF_HANDLER_HPP
2007-09-05 00:55:47 +02:00
#include <XML/XMLCharacterClasses.hpp>
2007-07-19 19:01:42 +02:00
#include "../xslt_value_of.hpp"
namespace Arabica
{
namespace XSLT
{
class ValueOfHandler : public SAX::DefaultHandler<std::string>
2007-07-19 19:01:42 +02:00
{
public:
ValueOfHandler(CompilationContext<std::string>& context) :
2007-07-19 19:01:42 +02:00
context_(context),
valueOf_(0)
{
} // ValueOfHandler
2010-01-11 10:02:17 +01:00
virtual void startElement(const std::string& /* namespaceURI */,
const std::string& /* localName */,
2007-07-19 19:01:42 +02:00
const std::string& qName,
const SAX::Attributes<std::string>& atts)
2007-07-19 19:01:42 +02:00
{
if(valueOf_ == 0)
{
2010-01-11 10:02:17 +01:00
static const ValueRule rules[] = { { "select", true, 0, 0 },
2007-07-19 19:01:42 +02:00
{ "disable-output-escaping", false, No, AllowedYesNo },
2010-01-11 10:02:17 +01:00
{ 0, false, 0, 0 } };
2007-07-19 19:01:42 +02:00
std::map<std::string, std::string> attrs = gatherAttributes(qName, atts, rules);
valueOf_ = new ValueOf(context_.xpath_expression(attrs["select"]),
2007-07-19 19:01:42 +02:00
attrs["disable-output-escaping"] == Yes);
return;
} // if(valueOf_ == 0)
throw SAX::SAXException(qName + " can not contain elements");
} // startElement
2010-01-11 10:02:17 +01:00
virtual void endElement(const std::string& /* namespaceURI */,
const std::string& /* localName */,
const std::string& /* qName */)
2007-07-19 19:01:42 +02:00
{
context_.parentContainer().add_item(valueOf_);
context_.pop();
} // endElement
virtual void characters(const std::string& ch)
{
verifyNoCharacterData(ch, "xsl:value-of");
2007-07-19 19:01:42 +02:00
} // characters
private:
CompilationContext<std::string>& context_;
2007-07-19 19:01:42 +02:00
ValueOf* valueOf_;
}; // class ValueOfHandler
} //namespace XSLT
} //namespace Arabica
#endif