// schema node.
for (int iChild = 0; iChild < schemaNode.children().size(); iChild++) {
SchemaNode childSchema = schemaNode.children().get(iChild);
if ((childSchema.label().equals(nodeIdentifier)) && (childSchema.isAttribute())) {
// Make sure that there is only one child
DatabaseElementList nodes = node.find(childSchema.path().substring(node.schema().path().length() + 1));
if (nodes.size() > 1) {
throw new WikiDataException(WikiDataException.UnknownResource, url.toString());
} else if (nodes.size() == 1) {
if (pathIndex == (url.size() - 1)) {
return nodes.get(0).identifier();
} else {
return this.decode(database, (DatabaseGroupNode)nodes.get(0), versionParameter, url, pathIndex + 1);
}
} else {
throw new WikiDataException(WikiDataException.UnknownResource, url.toString());
}
}
}
// This part of the code is only reached if the nodeIdentifier does not point
// to an attribute node. There should only be one schema node child with a rule defined
// for that node.
for (int iChild = 0; iChild < schemaNode.children().size(); iChild++) {
URLDecodingRule childRule = this.get(schemaNode.children().get(iChild));
if (childRule != null) {
if (rule == null) {
rule = childRule;
} else {
throw new WikiDataException(WikiDataException.UnknownResource, url.toString());
}
}
}
}
if (rule != null) {
DatabaseElementList nodes = node.find(rule.node().path().substring(node.schema().path().length() + 1));
DatabaseGroupNode nextNode = null;
for (int iNode = 0; iNode < nodes.size(); iNode++) {
DatabaseGroupNode childNode = (DatabaseGroupNode)nodes.get(iNode);
if (versionParameter.matches(childNode)) {
int matches = 0;
DatabaseElementList valueNodes = childNode.find(rule.value().path().substring(childNode.schema().path().length() + 1));
for (int iValueNode = 0; iValueNode < valueNodes.size(); iValueNode++) {
DatabaseAttributeNode attributeNode = (DatabaseAttributeNode)valueNodes.get(iValueNode);
for (int iAttrValue = 0; iAttrValue < attributeNode.value().size(); iAttrValue++) {
DatabaseTextNode textNode = attributeNode.value().get(iAttrValue);
if ((versionParameter.matches(textNode)) && (textNode.value().equals(keyValue))) {
matches++;
break;