This commit is contained in:
Jez Higgins 2012-11-02 23:07:17 +00:00
parent 3743972b0a
commit 7d76185a44
4 changed files with 23 additions and 22 deletions

View file

@ -154,7 +154,7 @@ const ChildElement* AllowedChildren()
{ "number", CreateHandler<NotImplementedYetHandler>}, { "number", CreateHandler<NotImplementedYetHandler>},
{ "processing-instruction", CreateHandler<ProcessingInstructionHandler> }, { "processing-instruction", CreateHandler<ProcessingInstructionHandler> },
{ "text", CreateHandler<TextHandler<std::string, Arabica::default_string_adaptor<std::string> > > }, { "text", CreateHandler<TextHandler<std::string, Arabica::default_string_adaptor<std::string> > > },
{ "value-of", CreateHandler<ValueOfHandler> }, { "value-of", CreateHandler<ValueOfHandler<std::string, Arabica::default_string_adaptor<std::string> > > },
{ "variable", CreateHandler<VariableHandler<Variable> > }, { "variable", CreateHandler<VariableHandler<Variable> > },
{ 0, 0 } { 0, 0 }
}; };

View file

@ -9,19 +9,20 @@ namespace Arabica
namespace XSLT namespace XSLT
{ {
class ValueOfHandler : public SAX::DefaultHandler<std::string> template<class string_type, class string_adaptor>
class ValueOfHandler : public SAX::DefaultHandler<string_type, string_adaptor>
{ {
public: public:
ValueOfHandler(CompilationContext<std::string>& context) : ValueOfHandler(CompilationContext<string_type, string_adaptor>& context) :
context_(context), context_(context),
valueOf_(0) valueOf_(0)
{ {
} // ValueOfHandler } // ValueOfHandler
virtual void startElement(const std::string& /* namespaceURI */, virtual void startElement(const string_type& /* namespaceURI */,
const std::string& /* localName */, const string_type& /* localName */,
const std::string& qName, const string_type& qName,
const SAX::Attributes<std::string>& atts) const SAX::Attributes<string_type, string_adaptor>& atts)
{ {
if(valueOf_ == 0) if(valueOf_ == 0)
{ {
@ -29,8 +30,8 @@ public:
{ "disable-output-escaping", false, No, AllowedYesNo }, { "disable-output-escaping", false, No, AllowedYesNo },
{ 0, false, 0, 0 } }; { 0, false, 0, 0 } };
std::map<std::string, std::string> attrs = gatherAttributes(qName, atts, rules); std::map<string_type, string_type> attrs = gatherAttributes(qName, atts, rules);
valueOf_ = new ValueOf(context_.xpath_expression(attrs["select"]), valueOf_ = new ValueOf<string_type, string_adaptor>(context_.xpath_expression(attrs["select"]),
attrs["disable-output-escaping"] == Yes); attrs["disable-output-escaping"] == Yes);
return; return;
} // if(valueOf_ == 0) } // if(valueOf_ == 0)
@ -38,22 +39,22 @@ public:
throw SAX::SAXException(qName + " can not contain elements"); throw SAX::SAXException(qName + " can not contain elements");
} // startElement } // startElement
virtual void endElement(const std::string& /* namespaceURI */, virtual void endElement(const string_type& /* namespaceURI */,
const std::string& /* localName */, const string_type& /* localName */,
const std::string& /* qName */) const string_type& /* qName */)
{ {
context_.parentContainer().add_item(valueOf_); context_.parentContainer().add_item(valueOf_);
context_.pop(); context_.pop();
} // endElement } // endElement
virtual void characters(const std::string& ch) virtual void characters(const string_type& ch)
{ {
verifyNoCharacterData(ch, "xsl:value-of"); verifyNoCharacterData(ch, "xsl:value-of");
} // characters } // characters
private: private:
CompilationContext<std::string>& context_; CompilationContext<string_type, string_adaptor>& context_;
ValueOf* valueOf_; ValueOf<string_type, string_adaptor>* valueOf_;
}; // class ValueOfHandler }; // class ValueOfHandler
} //namespace XSLT } //namespace XSLT

View file

@ -15,8 +15,6 @@ template<class string_type, class string_adaptor>
class StylesheetParser class StylesheetParser
{ {
public: public:
typedef string_type string_type;
typedef string_adaptor string_adaptor;
typedef SAX::ContentHandler<string_type, string_adaptor> ContentHandlerT; typedef SAX::ContentHandler<string_type, string_adaptor> ContentHandlerT;
typedef SAX::InputSource<string_type, string_adaptor> InputSourceT; typedef SAX::InputSource<string_type, string_adaptor> InputSourceT;
typedef SAX::XMLReader<string_type, string_adaptor> XMLReaderT; typedef SAX::XMLReader<string_type, string_adaptor> XMLReaderT;

View file

@ -8,17 +8,19 @@ namespace Arabica
namespace XSLT namespace XSLT
{ {
template<class string_type, class string_adaptor>
class ValueOf : public Item class ValueOf : public Item
{ {
public: public:
ValueOf(Arabica::XPath::XPathExpressionPtr<std::string> expr, ValueOf(Arabica::XPath::XPathExpressionPtr<string_type, string_adaptor> expr,
bool disable_output_escaping) : bool disable_output_escaping) :
expr_(expr), expr_(expr),
disable_(disable_output_escaping) disable_(disable_output_escaping)
{ {
} // ValueOf } // ValueOf
virtual void execute(const DOM::Node<std::string>& node, ExecutionContext& context) const virtual void execute(const DOM::Node<string_type, string_adaptor>& node,
ExecutionContext& context) const
{ {
if(disable_) if(disable_)
context.sink().disableOutputEscaping(true); context.sink().disableOutputEscaping(true);
@ -30,8 +32,8 @@ public:
} // execute } // execute
private: private:
Arabica::XPath::XPathExpressionPtr<std::string> expr_; Arabica::XPath::XPathExpressionPtr<string_type, string_adaptor> expr_;
bool disable_; const bool disable_;
}; // class ValueOf }; // class ValueOf
} // namespace XSLT } // namespace XSLT