[jdom-interest] possible bug with nested namespaces -resolved
but not fixed
philip.nelson at omniresources.com
philip.nelson at omniresources.com
Tue Aug 21 22:53:15 PDT 2001
OK here is the problem but I am out of time and don't have an immediate
solution.
public void endElement(String namespaceURI, String localName,
String qName) throws SAXException {
if (suppress) return;
Element element = (Element)stack.pop();
if (stack.empty()) {
atRoot = true;
}
// Remove the namespaces that this element makes available
List addl = element.getAdditionalNamespaces();
if (addl.size() > 0) {
availableNamespaces.removeAll(addl);
}
}
Because in element wipeout the xlink namespace is declared again, endElement
removes the namespace from the list of available namespaces that SAXBuilder
keeps. Later, looking up the prefix xlink in the availableNamespaces fails
because it was removed.
I think the solution will be to walk up the parents (in the stack), get the
namespaces they declare and remove them from add1.
In the short term, unless you want to code this patch yourself, just get rid
of that pesky redundant declaration, aye ;-)
> -----Original Message-----
> From: John Caron [mailto:caron at unidata.ucar.edu]
> Sent: Tuesday, August 21, 2001 11:43 AM
> To: philip.nelson at omniresources.com
> Cc: jdom-interest at jdom.org
> Subject: Re: [jdom-interest] possible bug with nested namespaces
>
>
> same problem, output is
>
> <?xml version="1.0" encoding="UTF-8"?>
> <test xmlns:blob="http://www.w3.org/1999/blob">
> <e1 blob:href="#htn_sst_decloud" />
> <wipeout>
> <server type="DODS" ID="this"
> blob:href="html://thredds.unidata.ucar.edu:8080/dodsC/" />
> </wipeout>
> <e1 href="#htn_sst_decloud2" />
> </test>
>
>
> philip.nelson at omniresources.com wrote:
>
> > Yep, that is a problem. I'll see if I can find a few spare
> moments to
> > reproduce it. Could you do me a favor and rerun it
> changing the xlink
> > prefix to something else? I seem to remember some special
> casing for xlink
> > (but could be wrong on that).
> >
> >
> >>Original:
> >>
> >><test xmlns:xlink="http://www.w3.org/1999/xlink">
> >> <e1 xlink:href="#htn_sst_decloud"/>
> >> <wipeout xmlns:xlink="http://www.w3.org/1999/xlink">
> >> <server type="DODS" ID="this"
> >>xlink:href="html://thredds.unidata.ucar.edu:8080/dodsC/"/>
> >> </wipeout>
> >> <e1 xlink:href="#htn_sst_decloud2"/> <!-- NOTE xlink
> namespace -->
> >></test>
> >>
> >>After parsing:
> >>
> >><?xml version="1.0" encoding="UTF-8"?>
> >><test xmlns:xlink="http://www.w3.org/1999/xlink">
> >> <e1 xlink:href="#htn_sst_decloud" />
> >> <wipeout>
> >> <server type="DODS" ID="this"
> >>xlink:href="html://thredds.unidata.ucar.edu:8080/dodsC/" />
> >> </wipeout>
> >> <e1 href="#htn_sst_decloud2" /> <!-- HERES THE PROBLEM -
> the xlink
> >>namespace removed !! -->
> >></test>
> >>
> >>Yes, I see what you are saying, that the namespace
> >>declaration has been
> >>removed from the <wipeout> elemnt.
> >>
> >>But the problem is on the second <e1> element, where the
> >>xlink: prefix
> >>has been removed from the href attribute. This makes the 2 docs not
> >>equivalent.
> >>
> >>I retested with xerces 1.4.3 with same result.
> >>
> >>
> >>
> >>philip.nelson at omniresources.com wrote:
> >>
> >>
> >>>>When nested elements declare the same namespace, it appears
> >>>>that when the
> >>>>inner element is done being processed, the namespace on
> >>>>
> >>other elements
> >>
> >>>>contained in the outer element is lost.
> >>>>
> >>>>
> >>>I think that you may be confusing a namespace and a
> >>>
> >>namespace declaration.
> >>
> >>>You did lose a namespace declaration. However the input and output
> >>>documents are equivalent. JDOM does move namespace
> >>>
> >>declarations up to the
> >>
> >>>outermost necesary element. In fact JDOM doesn't keep
> >>>
> >>track of where
> >>
> >>>declarations occur so the "problem" is that when
> >>>
> >>xmloutputter is used, it
> >>
> >>>has to create the declarations as needed.
> >>>
> >>>
> >>
> >>_______________________________________________
> >>To control your jdom-interest membership:
> >>http://lists.denveronline.net/mailman/options/jdom-interest/yo
> >>
> > uraddr at yourhost.com
> > _______________________________________________
> > To control your jdom-interest membership:
> >
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com
>
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
More information about the jdom-interest
mailing list