mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-29 08:36:45 +01:00
if
This commit is contained in:
parent
d68a9240ce
commit
0d3a91876a
3 changed files with 15 additions and 12 deletions
|
@ -9,24 +9,25 @@ namespace Arabica
|
|||
namespace XSLT
|
||||
{
|
||||
|
||||
class IfHandler : public ItemContainerHandler<If>
|
||||
template<class string_type, class string_adaptor>
|
||||
class IfHandler : public ItemContainerHandler<If<string_type, string_adaptor> >
|
||||
{
|
||||
public:
|
||||
IfHandler(CompilationContext<std::string>& context) :
|
||||
ItemContainerHandler<If>(context)
|
||||
IfHandler(CompilationContext<string_type, string_adaptor>& context) :
|
||||
ItemContainerHandler<If<string_type, string_adaptor> >(context)
|
||||
{
|
||||
} // IfHandler
|
||||
|
||||
virtual If* createContainer(const std::string& /* namespaceURI */,
|
||||
const std::string& /* localName */,
|
||||
const std::string& qName,
|
||||
const SAX::Attributes<std::string>& atts)
|
||||
virtual If<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)
|
||||
{
|
||||
static const ValueRule rules[] = { { "test", true, 0, 0 },
|
||||
{ 0, false, 0, 0 } };
|
||||
std::string test = gatherAttributes(qName, atts, rules)["test"];
|
||||
|
||||
return new If(ItemContainerHandler<If>::context().xpath_expression(test));
|
||||
return new If<string_type, string_adaptor>(ItemContainerHandler<If<string_type, string_adaptor> >::context().xpath_expression(test));
|
||||
} // startElement
|
||||
}; // class IfHandler
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ const ChildElement* AllowedChildren()
|
|||
{ "element", CreateHandler<ElementHandler> },
|
||||
{ "fallback", CreateHandler<NotImplementedYetHandler>},
|
||||
{ "for-each", CreateHandler<ForEachHandler> },
|
||||
{ "if", CreateHandler<IfHandler> },
|
||||
{ "if", CreateHandler<IfHandler<std::string, Arabica::default_string_adaptor<std::string> > > },
|
||||
{ "message", CreateHandler<MessageHandler>},
|
||||
{ "number", CreateHandler<NotImplementedYetHandler>},
|
||||
{ "processing-instruction", CreateHandler<ProcessingInstructionHandler> },
|
||||
|
|
|
@ -8,17 +8,19 @@ namespace Arabica
|
|||
namespace XSLT
|
||||
{
|
||||
|
||||
template<class string_type, class string_adaptor>
|
||||
class If : public ItemContainer
|
||||
{
|
||||
public:
|
||||
If(Arabica::XPath::XPathExpressionPtr<std::string> test) :
|
||||
If(Arabica::XPath::XPathExpressionPtr<string_type, string_adaptor> test) :
|
||||
test_(test)
|
||||
{
|
||||
} // If
|
||||
|
||||
virtual ~If() { }
|
||||
|
||||
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
|
||||
{
|
||||
ChainStackFrame frame(context);
|
||||
if(test_->evaluateAsBool(node, context.xpathContext()))
|
||||
|
@ -26,7 +28,7 @@ public:
|
|||
} // execute
|
||||
|
||||
private:
|
||||
Arabica::XPath::XPathExpressionPtr<std::string> test_;
|
||||
Arabica::XPath::XPathExpressionPtr<string_type, string_adaptor> test_;
|
||||
}; // class If
|
||||
|
||||
} // namespace XSLT
|
||||
|
|
Loading…
Add table
Reference in a new issue