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
|
|
|
|
{
|
|
|
|
|
2012-11-03 00:07:17 +01:00
|
|
|
template<class string_type, class string_adaptor>
|
|
|
|
class ValueOfHandler : public SAX::DefaultHandler<string_type, string_adaptor>
|
2007-07-19 19:01:42 +02:00
|
|
|
{
|
|
|
|
public:
|
2012-11-03 00:07:17 +01:00
|
|
|
ValueOfHandler(CompilationContext<string_type, string_adaptor>& context) :
|
2007-07-19 19:01:42 +02:00
|
|
|
context_(context),
|
|
|
|
valueOf_(0)
|
|
|
|
{
|
|
|
|
} // ValueOfHandler
|
|
|
|
|
2012-11-03 00:07:17 +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(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
|
|
|
|
2012-11-03 00:07:17 +01:00
|
|
|
std::map<string_type, string_type> attrs = gatherAttributes(qName, atts, rules);
|
|
|
|
valueOf_ = new ValueOf<string_type, string_adaptor>(context_.xpath_expression(attrs["select"]),
|
|
|
|
attrs["disable-output-escaping"] == Yes);
|
2007-07-19 19:01:42 +02:00
|
|
|
return;
|
|
|
|
} // if(valueOf_ == 0)
|
|
|
|
|
|
|
|
throw SAX::SAXException(qName + " can not contain elements");
|
|
|
|
} // startElement
|
|
|
|
|
2012-11-03 00:07:17 +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(valueOf_);
|
|
|
|
context_.pop();
|
|
|
|
} // endElement
|
|
|
|
|
2012-11-03 00:07:17 +01:00
|
|
|
virtual void characters(const string_type& ch)
|
2007-07-19 19:01:42 +02:00
|
|
|
{
|
2012-11-02 22:01:15 +01:00
|
|
|
verifyNoCharacterData(ch, "xsl:value-of");
|
2007-07-19 19:01:42 +02:00
|
|
|
} // characters
|
|
|
|
|
|
|
|
private:
|
2012-11-03 00:07:17 +01:00
|
|
|
CompilationContext<string_type, string_adaptor>& context_;
|
|
|
|
ValueOf<string_type, string_adaptor>* valueOf_;
|
2007-07-19 19:01:42 +02:00
|
|
|
}; // class ValueOfHandler
|
|
|
|
|
|
|
|
} //namespace XSLT
|
|
|
|
} //namespace Arabica
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|