public void analyze(AnalyzeContextInfo contextInfo) throws XPathException {
super.analyze(contextInfo);
for (Expression expr : steps) {
if (expr instanceof Template) {
Template template = (Template) expr;
if (template.isRootMatch()) {
if (rootTemplate != null) {
if (template.isPrioritySet() || rootTemplate.isPrioritySet()) {
if (template.getPriority() == rootTemplate.getPriority()) {
compileError("double root match");//XXX: put error code
} else if (template.getPriority() > rootTemplate.getPriority()) {
rootTemplate = template;
}
continue;
}
compileError("double root match");//XXX: put error code
}
rootTemplate = template;
if (template.getName() != null)
namedTemplates.put(template.getName(), template);//UNDERSTAND: check doubles?
} else if (template.getName() == null) {
templates.add(template);
} else {
namedTemplates.put(template.getName(), template);//UNDERSTAND: check doubles?
}
} else if (expr instanceof AttributeSet) {
AttributeSet attributeSet = (AttributeSet) expr;
if (attributeSets.containsKey(attributeSet.getName()))
attributeSets.get(attributeSet.getName()).add(attributeSet);