use of org.apache.xpath.patterns.StepPattern in project j2objc by google.
the class Compiler method matchPattern.
/**
* Compile an entire match pattern expression.
*
* @param opPos The current position in the m_opMap array.
*
* @return reference to {@link org.apache.xpath.patterns.UnionPattern} instance.
*
* @throws TransformerException if a error occurs creating the Expression.
*/
protected Expression matchPattern(int opPos) throws TransformerException {
locPathDepth++;
try {
// First, count...
int nextOpPos = opPos;
int i;
for (i = 0; getOp(nextOpPos) == OpCodes.OP_LOCATIONPATHPATTERN; i++) {
nextOpPos = getNextOpPos(nextOpPos);
}
if (i == 1)
return compile(opPos);
UnionPattern up = new UnionPattern();
StepPattern[] patterns = new StepPattern[i];
for (i = 0; getOp(opPos) == OpCodes.OP_LOCATIONPATHPATTERN; i++) {
nextOpPos = getNextOpPos(opPos);
patterns[i] = (StepPattern) compile(opPos);
opPos = nextOpPos;
}
up.setPatterns(patterns);
return up;
} finally {
locPathDepth--;
}
}
use of org.apache.xpath.patterns.StepPattern in project j2objc by google.
the class TemplateList method setTemplate.
/**
* Add a template to the table of named templates and/or the table of templates
* with match patterns. This routine should
* be called in decreasing order of precedence but it checks nonetheless.
*
* @param template
*/
public void setTemplate(ElemTemplate template) {
XPath matchXPath = template.getMatch();
if (null == template.getName() && null == matchXPath) {
template.error(XSLTErrorResources.ER_NEED_NAME_OR_MATCH_ATTRIB, new Object[] { "xsl:template" });
}
if (null != template.getName()) {
ElemTemplate existingTemplate = (ElemTemplate) m_namedTemplates.get(template.getName());
if (null == existingTemplate) {
m_namedTemplates.put(template.getName(), template);
} else {
int existingPrecedence = existingTemplate.getStylesheetComposed().getImportCountComposed();
int newPrecedence = template.getStylesheetComposed().getImportCountComposed();
if (newPrecedence > existingPrecedence) {
// This should never happen
m_namedTemplates.put(template.getName(), template);
} else if (newPrecedence == existingPrecedence)
template.error(XSLTErrorResources.ER_DUPLICATE_NAMED_TEMPLATE, new Object[] { template.getName() });
}
}
if (null != matchXPath) {
Expression matchExpr = matchXPath.getExpression();
if (matchExpr instanceof StepPattern) {
insertPatternInTable((StepPattern) matchExpr, template);
} else if (matchExpr instanceof UnionPattern) {
UnionPattern upat = (UnionPattern) matchExpr;
StepPattern[] pats = upat.getPatterns();
int n = pats.length;
for (int i = 0; i < n; i++) {
insertPatternInTable(pats[i], template);
}
} else {
// TODO: assert error
}
}
}
Aggregations