mirror of
https://github.com/jezhiggins/arabica
synced 2025-02-11 08:48:06 +01:00
Updated template handler to use the attribute validator
This commit is contained in:
parent
2f4848bedc
commit
d3f42542ad
1 changed files with 19 additions and 12 deletions
|
@ -39,14 +39,21 @@ protected:
|
||||||
const std::string& qName,
|
const std::string& qName,
|
||||||
const SAX::Attributes<std::string>& atts)
|
const SAX::Attributes<std::string>& atts)
|
||||||
{
|
{
|
||||||
const std::string& match = atts.getValue("match");
|
static const ValueRule rules[] = { { "match", false, 0 },
|
||||||
if((match == "") && (atts.getValue("name") == ""))
|
{ "mode", false, 0 },
|
||||||
|
{ "name", false, 0 },
|
||||||
|
{ "priority", false, 0 },
|
||||||
|
{ 0, false, 0} };
|
||||||
|
std::map<std::string, std::string> attributes = gatherAttributes(qName, atts, rules);
|
||||||
|
|
||||||
|
const std::string& match = attributes["match"];
|
||||||
|
if((match == "") && (attributes["name"] == ""))
|
||||||
throw SAX::SAXException("xsl:template must have a match and/or a name attribute");
|
throw SAX::SAXException("xsl:template must have a match and/or a name attribute");
|
||||||
|
|
||||||
int index = atts.getIndex("mode");
|
int index = atts.getIndex("mode");
|
||||||
if(index != -1)
|
if(index != -1)
|
||||||
{
|
{
|
||||||
const std::string& mode = atts.getValue(index);
|
const std::string& mode = attributes["mode"];
|
||||||
if(mode == "")
|
if(mode == "")
|
||||||
throw SAX::SAXException("xsl:template mode cannot be empty");
|
throw SAX::SAXException("xsl:template mode cannot be empty");
|
||||||
if(match == "")
|
if(match == "")
|
||||||
|
@ -54,17 +61,17 @@ protected:
|
||||||
} // ...
|
} // ...
|
||||||
|
|
||||||
std::pair<std::string, std::string> name;
|
std::pair<std::string, std::string> name;
|
||||||
if(atts.getValue("name") != "")
|
if(attributes["name"] != "")
|
||||||
name = context().processInternalQName(atts.getValue("name"));
|
name = context().processInternalQName(attributes["name"]);
|
||||||
|
|
||||||
std::pair<std::string, std::string> mode;
|
std::pair<std::string, std::string> mode;
|
||||||
if(atts.getValue("mode") != "")
|
if(attributes["mode"] != "")
|
||||||
mode = context().processInternalQName(atts.getValue("mode"));
|
mode = context().processInternalQName(attributes["mode"]);
|
||||||
|
|
||||||
if(match == "")
|
if(match == "")
|
||||||
return new Template(name,
|
return new Template(name,
|
||||||
mode,
|
mode,
|
||||||
atts.getValue("priority"));
|
attributes["priority"]);
|
||||||
|
|
||||||
return new Template(context().xpath_match(match),
|
return new Template(context().xpath_match(match),
|
||||||
name,
|
name,
|
||||||
|
|
Loading…
Add table
Reference in a new issue