SAXSerializer does not transmit namespace declarations as attributes

Wednesday, 19 November 2014 · 2 messages
EK
Erdal Karaca19 Nov 2014 21:29 #
Hi all, I am using the SAXSerializer to generate SAX events from an org.basex.query.value.item.Item instance. The Item instance represents the database doc's root in this specific case:
<r:root xmlns:r="r" xmlns:x="x" x:attr="test">
</r:root>
It seems that when the following method is called: org.xml.sax.ContentHandler.startElement(String, String, String, Attributes) the attributes map is missing namespace declarations (I would expect the ns declarations to be mapped to attributes). I.e. the above r:root element will be provided with just the x:attr in the attributes map, but not the xmlns:x as attribute. Do you have any solutions for this issue? How do I get the namespaces when startElement() is executed? Thanks!
CG
Christian Grün19 Nov 2014 21:34 #
Hi Erdal, I remember that the SAXSerializer class was written by one of our users [1]. Maybe you are interested in having a closer look at the code? Christian [1] https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/io/serial/SAXSerializer.java
Quoted text · Erdal Karaca · 24 lines
On Wed, Nov 19, 2014 at 9:29 PM, Erdal Karaca <erdal.karaca.de at gmail.com> wrote: > Hi all, > I am using the SAXSerializer to generate SAX events from an > org.basex.query.value.item.Item instance. > > The Item instance represents the database doc's root in this specific case: > > <r:root xmlns:r="r" xmlns:x="x" x:attr="test"> > </r:root> > > It seems that when the following method is called: > > org.xml.sax.ContentHandler.startElement(String, String, String, Attributes) > > the attributes map is missing namespace declarations (I would expect the ns > declarations to be mapped to attributes). > > I.e. the above r:root element will be provided with just the x:attr in the > attributes map, but not the xmlns:x as attribute. > > Do you have any solutions for this issue? How do I get the namespaces when > startElement() is executed? > > Thanks!

⚡Generated with XQuery