Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4681390

internalEntityDecl() is called twice for entity declaration

    XMLWordPrintable

    Details

      Description



      Name: viR10068 Date: 05/07/2002



      The api doc for the interface DeclHandler the method
      public void internalEntityDecl(String name, String value) throws SAXException
      says:
      "Only the effective (first) declaration for each entity will be reported."

      But the xerces in JAXP 1.2 build b18 reports both entity declaration.
      Note, the crimson in JDK 1.4.1 reports only one.

      See the log below for details:

      % cat xml_ex2.xml
      <?xml version="1.0" ?>
      <!DOCTYPE root [
         <!ENTITY inEntity 'internal' >
         <!ENTITY inEntity 'internal' >
      ]>
      <root>data</root>

      % cat xml_ex.java
      import java.io.PrintStream;
      import java.io.File;
      import javax.xml.parsers.SAXParserFactory;
      import javax.xml.parsers.SAXParser;
      import org.xml.sax.helpers.DefaultHandler;
      import org.xml.sax.SAXException;
      import org.xml.sax.ext.DeclHandler;

      class StubHl implements DeclHandler {
          public void externalEntityDecl(String name, String publicId, String systemId) throws
      SAXException{
          }
          public void attributeDecl(String eName, String aName, String type, String
      valueDefault, String value) throws SAXException {
          }
          public void elementDecl(String name, String model) throws SAXException {
          }
          public void internalEntityDecl(String name, String value) throws SAXException{
              System.out.println("internalEntityDecl: name is " + name);
              System.out.println("internalEntityDecl: value is " + value);
          }
          public void setIntEntDeclHook(String name, String value){
          }
      }

      public class xml_ex {

          public static void main(String [] args) {
              try {
                  // create and initialize the parser
                  SAXParserFactory spf = SAXParserFactory.newInstance();
                  spf.setNamespaceAware(true);
                  spf.setValidating(true);
                  SAXParser parser = spf.newSAXParser();

                  StubHl handler = new StubHl();
                  parser.setProperty("http://xml.org/sax/properties/declaration-handler",
      handler);

                  File xmlFile = new File(args[0]);
                  parser.parse(xmlFile, new DefaultHandler());
                  System.out.println("Passed.");
              } catch (Exception e) {
                  e.printStackTrace();
                  System.out.println("Failed.");
              }
          }
      }
       

      % echo $CLASSPATH && /export/ld25/java/dest/jdk1.3.1/solsparc/bin/java -showversion xml_ex
      xml_ex2.xml
      /export/ld25/java/dest/JAXP/jaxp-1.2.0-fcs-b18-24_apr_2002/xalan.jar:.:/export/ld25/java/d
      est/JAXP/jaxp-1.2.0-fcs-b18-24_apr_2002/jaxp-api.jar:/export/ld25/java/dest/JAXP/jaxp-1.2.
      0-fcs-b18-24_apr_2002/xercesImpl.jar:/export/ld25/java/dest/JAXP/jaxp-1.2.0-fcs-b18-24_apr
      _2002/sax.jar:
      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

      internalEntityDecl: name is inEntity
      internalEntityDecl: value is internal
      internalEntityDecl: name is inEntity
      internalEntityDecl: value is internal
      Passed.
      %

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              nbajajsunw Neeraj Bajaj (Inactive)
              Reporter:
              vivsunw Viv Viv (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: