mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-30 08:38:15 +01:00
keyhandler
This commit is contained in:
parent
db1f9bac46
commit
ab7e8337a2
2 changed files with 20 additions and 18 deletions
|
@ -9,19 +9,21 @@ namespace Arabica
|
||||||
namespace XSLT
|
namespace XSLT
|
||||||
{
|
{
|
||||||
|
|
||||||
class KeyHandler : public SAX::DefaultHandler<std::string>
|
template<class string_type, class string_adaptor>
|
||||||
|
class KeyHandler : public SAX::DefaultHandler<string_type, string_adaptor>
|
||||||
{
|
{
|
||||||
|
typedef typename Key<string_type, string_adaptor>::MatchExprList MatchExprList;
|
||||||
public:
|
public:
|
||||||
KeyHandler(CompilationContext<std::string>& context) :
|
KeyHandler(CompilationContext<string_type, string_adaptor>& context) :
|
||||||
context_(context),
|
context_(context),
|
||||||
key_(0)
|
key_(0)
|
||||||
{
|
{
|
||||||
} // KeyHandler
|
} // KeyHandler
|
||||||
|
|
||||||
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(key_ != 0)
|
if(key_ != 0)
|
||||||
throw SAX::SAXException(qName + " can not contain elements");
|
throw SAX::SAXException(qName + " can not contain elements");
|
||||||
|
@ -31,14 +33,14 @@ public:
|
||||||
{ "use", true, 0, 0 },
|
{ "use", true, 0, 0 },
|
||||||
{ 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);
|
||||||
name_ = context_.processInternalQName(attrs["name"]).clarkName();
|
name_ = context_.processInternalQName(attrs["name"]).clarkName();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Key<std::string, Arabica::default_string_adaptor<std::string> >::MatchExprList matches = context_.xpath_match_no_variables(attrs["match"]);
|
MatchExprList matches = context_.xpath_match_no_variables(attrs["match"]);
|
||||||
Arabica::XPath::XPathExpression<std::string> use = context_.xpath_expression_no_variables(attrs["use"]);
|
Arabica::XPath::XPathExpression<string_type, string_adaptor> use = context_.xpath_expression_no_variables(attrs["use"]);
|
||||||
|
|
||||||
key_ = new Key<std::string, Arabica::default_string_adaptor<std::string> >(matches, use);
|
key_ = new Key<string_type, string_adaptor>(matches, use);
|
||||||
} // try
|
} // try
|
||||||
catch(const Arabica::XPath::UnboundVariableException&)
|
catch(const Arabica::XPath::UnboundVariableException&)
|
||||||
{
|
{
|
||||||
|
@ -46,23 +48,23 @@ public:
|
||||||
} // catch
|
} // catch
|
||||||
} // 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_.stylesheet().add_key(name_, key_);
|
context_.stylesheet().add_key(name_, key_);
|
||||||
context_.pop();
|
context_.pop();
|
||||||
} // endElement
|
} // endElement
|
||||||
|
|
||||||
virtual void characters(const std::string& ch)
|
virtual void characters(const string_type& ch)
|
||||||
{
|
{
|
||||||
verifyNoCharacterData(ch, "xsl:key");
|
verifyNoCharacterData(ch, "xsl:key");
|
||||||
} // characters
|
} // characters
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CompilationContext<std::string>& context_;
|
CompilationContext<string_type, string_adaptor>& context_;
|
||||||
std::string name_;
|
string_type name_;
|
||||||
Key<std::string, Arabica::default_string_adaptor<std::string> >* key_;
|
Key<string_type, string_adaptor>* key_;
|
||||||
}; // class KeyHandler
|
}; // class KeyHandler
|
||||||
|
|
||||||
} // namespace XSLT
|
} // namespace XSLT
|
||||||
|
|
|
@ -200,7 +200,7 @@ const ChildElement<string_type, string_adaptor> StylesheetHandler<string_type, s
|
||||||
{ "decimal-format", CreateHandler<NotImplementedYetHandler<string_type, string_adaptor> >},
|
{ "decimal-format", CreateHandler<NotImplementedYetHandler<string_type, string_adaptor> >},
|
||||||
//"import"
|
//"import"
|
||||||
//"include"
|
//"include"
|
||||||
{ "key", CreateHandler<KeyHandler>},
|
{ "key", CreateHandler<KeyHandler<string_type, string_adaptor> >},
|
||||||
{ "namespace-alias", CreateHandler<NamespaceAliasHandler>},
|
{ "namespace-alias", CreateHandler<NamespaceAliasHandler>},
|
||||||
{ "output", CreateHandler<OutputHandler>},
|
{ "output", CreateHandler<OutputHandler>},
|
||||||
{ "param", CreateHandler<TopLevelVariableHandler<Param<string_type, string_adaptor> > >},
|
{ "param", CreateHandler<TopLevelVariableHandler<Param<string_type, string_adaptor> > >},
|
||||||
|
|
Loading…
Add table
Reference in a new issue