mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-30 08:38:15 +01:00
improved validation on template priority value
This commit is contained in:
parent
bd49423c2d
commit
c7a3f9be3f
2 changed files with 8 additions and 4 deletions
|
@ -60,6 +60,10 @@ protected:
|
||||||
throw SAX::SAXException("xsl:template may not have a mode without a match");
|
throw SAX::SAXException("xsl:template may not have a mode without a match");
|
||||||
} // ...
|
} // ...
|
||||||
|
|
||||||
|
const std::string& priority = attributes["priority"];
|
||||||
|
if((atts.getIndex("priority") != -1) && (priority == ""))
|
||||||
|
throw SAX::SAXException("xsl:template priority cannot be empty");
|
||||||
|
|
||||||
std::pair<std::string, std::string> name;
|
std::pair<std::string, std::string> name;
|
||||||
if(attributes["name"] != "")
|
if(attributes["name"] != "")
|
||||||
name = context().processInternalQName(attributes["name"]);
|
name = context().processInternalQName(attributes["name"]);
|
||||||
|
@ -71,13 +75,13 @@ protected:
|
||||||
if(match == "")
|
if(match == "")
|
||||||
return new Template(name,
|
return new Template(name,
|
||||||
mode,
|
mode,
|
||||||
attributes["priority"],
|
priority,
|
||||||
context().precedence());
|
context().precedence());
|
||||||
|
|
||||||
return new Template(context().xpath_match(match),
|
return new Template(context().xpath_match(match),
|
||||||
name,
|
name,
|
||||||
mode,
|
mode,
|
||||||
atts.getValue("priority"),
|
priority,
|
||||||
context().precedence());
|
context().precedence());
|
||||||
} // createContainer
|
} // createContainer
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ public:
|
||||||
Template(const std::pair<std::string, std::string>& name,
|
Template(const std::pair<std::string, std::string>& name,
|
||||||
const std::pair<std::string, std::string>& mode,
|
const std::pair<std::string, std::string>& mode,
|
||||||
const std::string& priority,
|
const std::string& priority,
|
||||||
const Precedence& precedence) :
|
const Precedence& precedence) :
|
||||||
matches_(),
|
matches_(),
|
||||||
name_(name),
|
name_(name),
|
||||||
mode_(mode),
|
mode_(mode),
|
||||||
|
@ -35,7 +35,7 @@ public:
|
||||||
{
|
{
|
||||||
if(!priority.empty())
|
if(!priority.empty())
|
||||||
{
|
{
|
||||||
float p = boost::lexical_cast<float>(priority);
|
double p = boost::lexical_cast<double>(Arabica::text::normalize_whitespace<std::string, Arabica::default_string_adaptor<std::string> >(priority));
|
||||||
for(std::vector<Arabica::XPath::MatchExpr<std::string> >::iterator m = matches_.begin(), me = matches_.end(); m != me; ++m)
|
for(std::vector<Arabica::XPath::MatchExpr<std::string> >::iterator m = matches_.begin(), me = matches_.end(); m != me; ++m)
|
||||||
m->override_priority(p);
|
m->override_priority(p);
|
||||||
} // if ...
|
} // if ...
|
||||||
|
|
Loading…
Add table
Reference in a new issue