public void startElement( String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { try { staxWriter.writeStartElement( getPrefix(qName), localName, namespaceURI); String uri, prefix; while (prefixBindings.size() != 0) { uri = (String)prefixBindings.pop(); prefix = (String)prefixBindings.pop(); if (prefix.length() == 0) { staxWriter.setDefaultNamespace(uri); } else { staxWriter.setPrefix(prefix, uri); } // this method handles "", null, and "xmlns" prefixes properly staxWriter.writeNamespace(prefix, uri); } writeAttributes(atts); } catch (XMLStreamException e) { throw new SAXException(e); } }