if (node.getNodeType() == AnyNode.ELEMENT) {
// -- node local name
String name = node.getLocalName();
// -- retrieve the namespaces declaration and handle them
AnyNode tempNode = node.getFirstNamespace();
String prefix = null;
while (tempNode != null) {
prefix = tempNode.getNamespacePrefix();
if (prefix == null) {
prefix = "";
}
String value = tempNode.getNamespaceURI();
if (value == null) {
value = "";
}
handler.startPrefixMapping(prefix, value);
if (value != null && value.length() > 0) {
_context.addNamespace(prefix, value);
}
tempNode = tempNode.getNextSibling();
}// namespaceNode
// -- retrieve the attributes and handle them
AttributesImpl atts = new AttributesImpl();
tempNode = node.getFirstAttribute();
String xmlName = null;
String value = null;
String attUri = null;
String attPrefix = null;
while (tempNode != null) {
xmlName = tempNode.getLocalName();
String localName = xmlName;
// --retrieve a prefix?
attUri = tempNode.getNamespaceURI();
if (attUri != null) {
attPrefix = _context.getNamespacePrefix(attUri);
} else {
attUri = "";
}
if (attPrefix != null && attPrefix.length() > 0) {
xmlName = attPrefix + ':' + xmlName;
}
value = tempNode.getStringValue();
atts.addAttribute(attUri, localName, xmlName, "CDATA", value);
tempNode = tempNode.getNextSibling();
}// attributes
// -- namespace management
// _context = _context.createNamespaces();
String nsPrefix = node.getNamespacePrefix();
String nsURI = node.getNamespaceURI();
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);
}
} else {
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(nsURI, name, qName, atts);
} catch (SAXException sx) {
throw new SAXException(sx);
}
// -- handle child&daughter elements
tempNode = node.getFirstChild();
while (tempNode != null) {
_context = _context.createNamespaces();
processAnyNode(tempNode, handler);
tempNode = tempNode.getNextSibling();
}
// -- finish element
try {
handler.endElement(nsURI, name, qName);
_context = _context.getParent();
// -- retrieve the namespaces declaration and handle them
tempNode = node.getFirstNamespace();
while (tempNode != null) {
prefix = tempNode.getNamespacePrefix();
if (prefix == null) {
prefix = "";
}
handler.endPrefixMapping(prefix);
tempNode = tempNode.getNextSibling();
} // namespaceNode
} catch (org.xml.sax.SAXException sx) {
throw new SAXException(sx);
}
} else {