}
b.add(new JBlankLine());
b.add(new JLineComment("Read attributes"));
JExpression attName;
JExpression attNs;
JExpression attValue;
if (forEachAttribute != null) {
b.add(forEachAttribute);
b = forEachAttribute.body();
JVar attributeVar = forEachAttribute.var();
attName = attributeVar.invoke("getLocalName");
attNs = attributeVar.invoke("getNamespace");
attValue = attributeVar.invoke("getValue");
} else {
JForLoop loop = b._for();
JVar var = loop.init(model._ref(int.class), "i", JExpr.lit(0));
loop.test(var.lt(xsrVar.invoke("getAttributeCount")));
loop.update(var.assignPlus(JExpr.lit(1)));
b = loop.body();
attName = b.decl(model._ref(String.class), "attName", xsrVar.invoke("getAttributeLocalName").arg(var));
attNs = b.decl(model._ref(String.class), "attNs", xsrVar.invoke("getAttributeNamespace").arg(var));
attValue = b.decl(model._ref(String.class), "attValue", xsrVar.invoke("getAttributeValue").arg(var));
}
JIfElseBlock attributesBlock = new JIfElseBlock();
b.add(attributesBlock);
for (Map.Entry<QName, ExpectedAttribute> e : attributes.entrySet()) {
QName name = e.getKey();
ExpectedAttribute expectedAttribute = e.getValue();
JExpression qnameCompare = buildQNameCompare(name, attName, attNs);
JBlock block = attributesBlock.addCondition(qnameCompare);
List<JExpression> vars = null;
if (expectedAttribute.getParserBuilder() != null) {
AttributeParserBuilderImpl builder = expectedAttribute.getParserBuilder();