You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Jeffrey Rodriguez <je...@hotmail.com> on 2000/07/11 18:25:04 UTC

RE: BUG: SAXParser endElement reports incorrect local name w/ nam espaces

Hi Nick,
Just got your message and I am looking into it.
Thanks for the information and the testcase.

Jeffrey Rodriguez
IBM Silicon Valley



>From: "Sieger, Nicholas" <ns...@netperceptions.com>
>Reply-To: xerces-j-dev@xml.apache.org
>To: "'xerces-j-dev@xml.apache.org'" <xe...@xml.apache.org>
>Subject: RE: BUG: SAXParser endElement reports incorrect local name w/ nam 
>espaces
>Date: Tue, 11 Jul 2000 11:06:48 -0500
>
>Jeffrey,
>
>I'm the other poster that Kevin was referring to.  If it helps you, here's
>an excerpt from my post a couple weeks back that also included a test case
>that you might try out to reproduce the problem.
>
>Thanks for looking into it,
>
>Nick Sieger
>nsieger@netperceptions.com
>
>--- begin XercesTest.java ---
>
>import java.io.StringReader;
>import org.xml.sax.*;
>import org.xml.sax.helpers.*;
>
>public class XercesTest
>{
>     private static String testNS = "/dev/null";
>     private static String testXML1 =
>         "<?xml version=\"1.0\" standalone=\"yes\"?>"
>         + " <a xmlns=\"" + testNS + "\">\n"
>         + "  <b>\n"
>         + "   <c></c>\n"
>         + "  </b>\n"
>         + " </a>\n";
>     private static String testXML2 =
>         "<?xml version=\"1.0\" standalone=\"yes\"?>"
>         + " <test:a xmlns:test=\"" + testNS + "\">\n"
>         + "  <test:b>\n"
>         + "   <test:c></test:c>\n"
>         + "  </test:b>\n"
>         + " </test:a>\n";
>
>     private int elementAStart;
>     private int elementBStart;
>     private int elementCStart;
>     private int elementAEnd;
>     private int elementBEnd;
>     private int elementCEnd;
>
>     public XercesTest () {
>         elementAStart = 0;
>         elementBStart = 0;
>         elementCStart = 0;
>         elementAEnd   = 0;
>         elementBEnd   = 0;
>         elementCEnd   = 0;
>     }
>
>     public class MyHandler extends DefaultHandler
>     {
>         public void startElement (String namespaceURI, String name,
>                                   String qName, Attributes attrs)
>             throws SAXException {
>
>             if (namespaceURI.equals (testNS)) {
>
>                 if (name.equals ("a")) {
>                     elementAStart++;
>                 }
>                 else if (name.equals ("b")) {
>                     elementBStart++;
>                 }
>                 else if (name.equals ("c")) {
>                     elementCStart++;
>                 }
>             }
>         }
>
>         public void endElement (String namespaceURI, String name,
>                                 String qName)
>             throws SAXException {
>
>             if (namespaceURI.equals (testNS)) {
>
>                 if (name.equals ("a")) {
>                     elementAEnd++;
>                 }
>                 else if (name.equals ("b")) {
>                     elementBEnd++;
>                 }
>                 else if (name.equals ("c")) {
>                     elementCEnd++;
>                 }
>             }
>         }
>     }
>
>     public static class Assert
>     {
>         public static void equals (int a, int b) throws Exception {
>             equals (new Integer (a), new Integer (b));
>         }
>         public static void equals (Object a, Object b) throws Exception {
>             if (a.equals (b))
>                 return;
>             throw new Exception ("assertion failed: expected <" + 
>a.toString
>()
>                                  + "> but was <" + b.toString () + ">");
>         }
>     }
>
>     public static void runTest1 () throws Exception {
>
>         XMLReader reader = XMLReaderFactory.createXMLReader
>             ("org.apache.xerces.parsers.SAXParser");
>
>         reader.setFeature ("http://xml.org/sax/features/namespaces", 
>true);
>
>         XercesTest test = new XercesTest ();
>         reader.setContentHandler (test.new MyHandler ());
>         reader.parse (new InputSource (new StringReader (testXML1)));
>
>         Assert.equals (1, test.elementAStart);
>         Assert.equals (1, test.elementBStart);
>         Assert.equals (1, test.elementCStart);
>         Assert.equals (1, test.elementCEnd);
>         Assert.equals (1, test.elementBEnd);
>         Assert.equals (1, test.elementAEnd);
>     }
>
>     public static void runTest2 () throws Exception {
>
>         XMLReader reader = XMLReaderFactory.createXMLReader
>             ("org.apache.xerces.parsers.SAXParser");
>
>         reader.setFeature ("http://xml.org/sax/features/namespaces", 
>true);
>
>         XercesTest test = new XercesTest ();
>         reader.setContentHandler (test.new MyHandler ());
>         reader.parse (new InputSource (new StringReader (testXML2)));
>
>         Assert.equals (1, test.elementAStart);
>         Assert.equals (1, test.elementBStart);
>         Assert.equals (1, test.elementCStart);
>         Assert.equals (1, test.elementCEnd);
>         Assert.equals (1, test.elementBEnd);
>         Assert.equals (1, test.elementAEnd);
>     }
>
>     public static void main (String[] args) {
>
>         int exitStatus = 0;
>         try {
>             runTest1 ();
>             runTest2 ();
>         }
>         catch (Exception e) {
>             e.printStackTrace ();
>             exitStatus = 1;
>         }
>         System.exit (exitStatus);
>     }
>}
>
>--- end XercesTest.java
>
>-----Original Message-----
>From: Jeffrey Rodriguez [mailto:jeffreyr_97@hotmail.com]
>Sent: Tuesday, July 11, 2000 5:05 AM
>To: xerces-j-dev@xml.apache.org
>Subject: Re: BUG: SAXParser endElement reports incorrect local name w/
>namespaces
>
>
>Hi Kevin,
>Sorry for the delay in answering your report.
>
>I will look at this tomorrow as time permits but I will keep
>you posted in what I find.
>
>Thanks for reporting this,
>
>               Jeffrey Rodriguez
>               IBM Silicon Valley
>
> >From: Kevin Wiggen <kw...@yahoo.com>
> >Reply-To: xerces-j-dev@xml.apache.org
> >To: xerces-j-dev@xml.apache.org, nsieger@netperceptions.com
> >Subject: BUG: SAXParser endElement reports incorrect local name w/
> >namespaces
> >Date: Sun, 9 Jul 2000 20:57:32 -0700 (PDT)
> >
> >I too am trying to use 1.1.* of the Xerces Java SAX
> >parser with namespaces.  I read a note that spoke of
> >the same problem I am having, but saw no reply.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com