private void setAttributes(TagNode node, Element element) {
        for (Map.Entry<String, String> entry : node.getAttributes().entrySet()) {
            String attrName = entry.getKey();
            String attrValue = entry.getValue();
            if (escapeXml) {
                attrValue = Utils.escapeXml(attrValue, props, true);
            }
            String attPrefix = Utils.getXmlNSPrefix(attrName);
            Namespace ns = null;
            if (attPrefix != null) {
                attrName = Utils.getXmlName(attrName);
                if (props.isNamespacesAware()) {
                    String nsURI = node.getNamespaceURIOnPath(attPrefix);
                    if (nsURI == null) {
                        nsURI = attPrefix;
                    }
                    if (!attPrefix.startsWith("xml")) {
                        ns = Namespace.getNamespace(attPrefix, nsURI);
                    }
                }
            }
            
            //
            // Don't manually add xmlns attributes as these should be 
            // handled automatically by JDOM through the namespace
            // mechanism
            //
            if (!attrName.equals("xmlns")){
	            if (ns == null) {
	                element.setAttribute(attrName, attrValue);
	            } else {
	                element.setAttribute(attrName, attrValue, ns);
	            }
            }
        }
    }