On Monday 07 October 2002 16:18, Elena Litani wrote:
> Andy Clark wrote:
> > Olle Sundblad wrote:
> > > Since upgrading to Xerces 2_2_0 (from version 1_2_3), I don't receive
> > > any uri in the endElement callback (see bleow) when using the
> > > SAX-parser that is
> >
> > I'm really surprised something like this could happen.
>
> I've just committed the fix. There was a bug in the new scanner (that
> also does namespace binding).
>
> Please, pick up the new code from CVS or the jars from
> http://gump.covalent.net/jars/latest/xml-xerces2/ and verify the fix.
> Thanks!

I just did; I got the two JARs from the URL you indicated, but the following 
Java still returns empty namespace in endElement. Maybe I should get the CVS 
source?

James


[NoEndNamespace.java]
/*
 * NoEndNamespace.java: contains NoEndNamespace class
 *
 * Created on Oct 7, 2002
 */

import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

import javax.xml.parsers.SAXParserFactory;
import java.io.StringReader;

/**
 * Demonstrate missing namespace URI in SAX endElement
 *
 * @author James Bates <[EMAIL PROTECTED]>
 * @version 1
 */
public class NoEndNamespace {

    public static String xml = "<?xml version=\"1.0\"?>\n"
               + "<h:hello xmlns:h=\"http://www.james.net/Hello\";>\n"
               + "     Hello, world\n"
               + "</h:hello>\n";

    public static void main(String[] args) throws Exception {

        SAXParserFactory spf = SAXParserFactory.newInstance();
        spf.setNamespaceAware(true);

        XMLReader xr = spf.newSAXParser().getXMLReader();

        xr.setContentHandler( new DefaultHandler() {

            public void startElement(String nsURI, String localName,
                        String qName, Attributes att) throws SAXException {

                System.out.println("start element: ns=" + nsURI
                        + "; local-name=" + localName);
            }

            public void endElement(String nsURI, String localName,
                        String qName) throws SAXException {

                System.out.println("end element: ns=" + nsURI
                        + "; local-name=" + localName);
            }
        });

        xr.parse(new InputSource(new StringReader(xml)));
    }

}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to