mirror of
https://github.com/jezhiggins/arabica
synced 2025-02-05 20:45:56 +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
|
namespace XSLT
|
||||||
{
|
{
|
||||||
|
|
||||||
class IfHandler : public ItemContainerHandler<If>
|
template<class string_type, class string_adaptor>
|
||||||
|
class IfHandler : public ItemContainerHandler<If<string_type, string_adaptor> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IfHandler(CompilationContext<std::string>& context) :
|
IfHandler(CompilationContext<string_type, string_adaptor>& context) :
|
||||||
ItemContainerHandler<If>(context)
|
ItemContainerHandler<If<string_type, string_adaptor> >(context)
|
||||||
{
|
{
|
||||||
} // IfHandler
|
} // IfHandler
|
||||||
|
|
||||||
virtual If* createContainer(const std::string& /* namespaceURI */,
|
virtual If<string_type, string_adaptor>* createContainer(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)
|
||||||
{
|
{
|
||||||
static const ValueRule rules[] = { { "test", true, 0, 0 },
|
static const ValueRule rules[] = { { "test", true, 0, 0 },
|
||||||
{ 0, false, 0, 0 } };
|
{ 0, false, 0, 0 } };
|
||||||
std::string test = gatherAttributes(qName, atts, rules)["test"];
|
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
|
} // startElement
|
||||||
}; // class IfHandler
|
}; // class IfHandler
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ const ChildElement* AllowedChildren()
|
||||||
{ "element", CreateHandler<ElementHandler> },
|
{ "element", CreateHandler<ElementHandler> },
|
||||||
{ "fallback", CreateHandler<NotImplementedYetHandler>},
|
{ "fallback", CreateHandler<NotImplementedYetHandler>},
|
||||||
{ "for-each", CreateHandler<ForEachHandler> },
|
{ "for-each", CreateHandler<ForEachHandler> },
|
||||||
{ "if", CreateHandler<IfHandler> },
|
{ "if", CreateHandler<IfHandler<std::string, Arabica::default_string_adaptor<std::string> > > },
|
||||||
{ "message", CreateHandler<MessageHandler>},
|
{ "message", CreateHandler<MessageHandler>},
|
||||||
{ "number", CreateHandler<NotImplementedYetHandler>},
|
{ "number", CreateHandler<NotImplementedYetHandler>},
|
||||||
{ "processing-instruction", CreateHandler<ProcessingInstructionHandler> },
|
{ "processing-instruction", CreateHandler<ProcessingInstructionHandler> },
|
||||||
|
|
|
@ -8,17 +8,19 @@ namespace Arabica
|
||||||
namespace XSLT
|
namespace XSLT
|
||||||
{
|
{
|
||||||
|
|
||||||
|
template<class string_type, class string_adaptor>
|
||||||
class If : public ItemContainer
|
class If : public ItemContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
If(Arabica::XPath::XPathExpressionPtr<std::string> test) :
|
If(Arabica::XPath::XPathExpressionPtr<string_type, string_adaptor> test) :
|
||||||
test_(test)
|
test_(test)
|
||||||
{
|
{
|
||||||
} // If
|
} // If
|
||||||
|
|
||||||
virtual ~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);
|
ChainStackFrame frame(context);
|
||||||
if(test_->evaluateAsBool(node, context.xpathContext()))
|
if(test_->evaluateAsBool(node, context.xpathContext()))
|
||||||
|
@ -26,7 +28,7 @@ public:
|
||||||
} // execute
|
} // execute
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Arabica::XPath::XPathExpressionPtr<std::string> test_;
|
Arabica::XPath::XPathExpressionPtr<string_type, string_adaptor> test_;
|
||||||
}; // class If
|
}; // class If
|
||||||
|
|
||||||
} // namespace XSLT
|
} // namespace XSLT
|
||||||
|
|
Loading…
Add table
Reference in a new issue