xbis-devs Mailing List for XBIS - XML Binary Infoset
Brought to you by:
dsosnoski
You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|
|
From: Epifanio S. XA (AT/LMI)
<epi...@er...> - 2004-07-20 16:04:33
|
Hi, I'm trying to encode/decode using Xbis, I haven't have any issues until I started to send xml files with namespaces. If I try to encode the following xml file: ... <root> <n1:ele1 xmlns:n1="http://n1.org"> <ele2 xmlns:n1="http://n1.org"> test_1 </ele2> </n1:ele1> </root> the following exception arise : (don't pay attention to the line number I have added some print.out and they can differ from the original, btw I'm using Xbis - version 0.9.5 Exception in thread "main" java.lang.IllegalStateException: Namespaces must be deactivated in reverse order at org.xbis.XBISWriter.deactivateNamespace(XBISWriter.java:743) at org.xbis.XBISWriter.closeNamespaces(XBISWriter.java:1008) at org.xbis.XBISEventWriter.writeElementEnd(XBISEventWriter.java:359) at org.xbis.SAXToXBISAdapter.endElement(SAXToXBISAdapter.java:198) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at test.RoundTrip.runRoundTrip(RoundTrip.java:133) at test.RoundTrip.main(RoundTrip.java:167) As far as I've could see the problem is in "m_activeNamespaces" it's an array that holds the active name spaces within element scope. if you look inside the method "org.xbis.XBISWriter.activateNamespace( OutputNamespace ns ) { .... m_activeNamespaces [m_activeCount] = ns; ns.setActiveHandle(m_activeCount++); } it means that if "ns" is already within m_activeNamespace , the method ns.setActiveHandle will set the new value in all the references withing m_activeNamespace so, deactivateNamespace(....){ .... int index = --m_activeCount; if (ns == m_activeNamespaces[index] && ns.getActiveHandle() == index) { m_activeNamespaces[index] = null; ns.setActiveHandle(-1); } else { throw new IllegalStateException ("Namespaces must be deactivated in reverse order"); } ... } as we can see above, if there is a repeated namespace inside m_activeNamespaces it will fail and will throw and exception the second time it tries to deactivate it. I have fix this may be wrong behaviour by creating a new namespace and adding it to the m_activeNamespace array, but now in the output I don't have any references to the namespace that's how the output lookslike (rountripping) <?xml version="1.0" encoding="UTF-8"?> <root> <n1:ele1 xmlns:n1="http://n1.org"> <ele2 xmlns:xml="http://www.w3.org/XML/1998/namespace"> test_1 </ele2> </n1:ele1> </root> so, that's mean that it may be another issues I cannot find yet.... Any idea, help woul be welcomed Thanks epi |