}
private TagNode tag() throws IOException, TemplateParsingException {
OpenTagToken token = (OpenTagToken) currentToken;
Cambridge bindings = Cambridge.getInstance();
TagNode node = null;
if (token.getNameSpace() != null) {
String namespaceUri = getNamespaceUri(token.getNameSpace());
if (namespaceUri != null) {
node = bindings.getDynamicTag(new DynamicAttributeKey(namespaceUri, token.getNameSpace(), token.getTagName()));
}
}
boolean dynamicTag = true;
if (node == null) {
node = new TagNode();
dynamicTag = false;
}
node.setBeginLine(token.getLineNo());
node.setBeginColumn(token.getColumn());
node.setTagName(token.getTagName());
node.setNameSpace(token.getNameSpace());
node.setTagNameString(token.value);
// Match the open tag
while (peek(1).getType() != TokenType.EOF) {
nextToken();
switch (currentToken.getType()) {
case WS:
case EOL:
TextTagPart e = new TextTagPart(currentToken.getActualValue(), currentToken.getLineNo(), currentToken.getColumn());
e.whitespace = true;
node.addText(e);
break;
case TAG_STRING:
case ASSIGN:
node.addText(new TextTagPart(currentToken.getActualValue(), currentToken.getLineNo(), currentToken.getColumn()));
break;
case ATTRIBUTE_NAME:
AttributeNameToken tok = (AttributeNameToken) currentToken;
if (dynamicTag && tok.getNameSpace() == null) {
tok.setNameSpace(node.getNameSpace());
}
Attribute element = null;
StringBuilder textContent = new StringBuilder();
textContent.append(tok.getActualValue());
boolean dynamic = false;
boolean staticAttribute = false;
String namespaceUri = getNamespaceUri(tok.getNameSpace());
if (namespaceUri != null && bindings.isRegisteredNamespace(namespaceUri)) {
dynamic = true;
if (bindings.isStaticAttribute(namespaceUri, tok.getAttributeName())) {
staticAttribute = true;
element = new StaticAttribute(namespaceUri, tok.getLineNo(), tok.getColumn());
} else {
element = new DynamicAttribute(namespaceUri, tok.getLineNo(), tok.getColumn());
}