}
// there was at least one match, so try to generate the values
try {
ArrayList<AttributeValue> list = new ArrayList<AttributeValue>();
AttributeFactory attrFactory = AttributeFactory.getInstance();
for (int i = 0; i < matches.getLength(); i++) {
String text = null;
Node node = matches.item(i);
short nodeType = node.getNodeType();
// see if this is straight text, or a node with data under
// it and then get the values accordingly
AttributeValue attrValue = null;
if ((nodeType == Node.CDATA_SECTION_NODE) || (nodeType == Node.COMMENT_NODE)
|| (nodeType == Node.TEXT_NODE) || (nodeType == Node.ATTRIBUTE_NODE)) {
// there is no child to this node
text = node.getNodeValue();
attrValue = attrFactory.createValue(type, text);
} else if (nodeType == Node.DOCUMENT_NODE || nodeType == Node.ELEMENT_NODE) {
attrValue = attrFactory.createValue(node, type);
} else {
// the data is in a child node
text = node.getFirstChild().getNodeValue();
attrValue = attrFactory.createValue(type, text);
}
list.add(attrValue);
}