if (_elements.search(node) >= 0) return;
else _elements.push(node);
if (node.getNodeType() == AnyNode.ELEMENT) {
//the first sibling node of the current one
AnyNode siblingNode = node.getNextSibling();
String name = node.getLocalName();
//-- retrieve the attributes and handle them
AttributeListImpl atts = new AttributeListImpl();
AnyNode tempNode = node.getFirstAttribute();
String xmlName = null;
String value = null;
while (tempNode != null) {
xmlName = tempNode.getLocalName();
value = tempNode.getStringValue();
atts.addAttribute(xmlName, null, value);
tempNode = tempNode.getNextSibling();
}//attributes
//-- namespace management
_context = _context.createNamespaces();
String nsPrefix = node.getNamespacePrefix();
String nsURI = node.getNamespaceURI();
//-- retrieve the namespaces declaration and handle them
tempNode = node.getFirstNamespace();
String prefix = null;
while (tempNode != null) {
prefix = tempNode.getNamespacePrefix();
value = tempNode.getNamespaceURI();
if (value != null && value.length() >0)
_context.addNamespace(prefix, value);
tempNode = tempNode.getNextSibling();
}//namespaceNode
String qName = null;
//maybe the namespace is already bound to a prefix in the
//namespace context
if (nsURI != null && nsURI.length() > 0) {
String tempPrefix = _context.getNamespacePrefix(nsURI);
if (tempPrefix != null)
nsPrefix = tempPrefix;
else {
_context.addNamespace(nsPrefix, nsURI);
}
}
if (nsPrefix != null) {
int len = nsPrefix.length();
if (len > 0) {
StringBuffer sb = new StringBuffer(len+name.length()+1);
sb.append(nsPrefix);
sb.append(':');
sb.append(name);
qName = sb.toString();
} else qName = name;
} else {
qName = name;
}
try {
_context.declareAsAttributes(atts,true);
handler.startElement(qName, atts);
} catch (SAXException sx) {
throw new SAXException(sx);
}
//-- handle child&daughter elements
tempNode = node.getFirstChild();
while (tempNode != null) {
processAnyNode(tempNode, handler);
tempNode = tempNode.getNextSibling();
}
//-- finish element
try {
handler.endElement(qName);