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

method DeclHandler.attributeDecl type is ENUMERATION when it should be(v1|v2|v3)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.1
    • xml



      Name: bsT130419 Date: 10/11/2001


      java version "1.4.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
      Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)

      1. compile attribute reader
      2. run reader on sample xml file
      3. view output

      ************ sample dtd (at.dtd) *********************************
      <!ELEMENT at EMPTY>
      <!ATTLIST at
      index CDATA #REQUIRED
      status (out-of-service reserved available in-use) #REQUIRED
      owner CDATA "no-owner"
      >
      ******************************************************************
      ************** test.xml ******************************************
      <?xml version='1.0' encoding='utf-8'?>
      <!--
         PDLG Site Manager lab list xml
      -->
      <!DOCTYPE at SYSTEM "at.dtd">
      <at index="504" status="in-use" owner="jflow">
      </at>
      *******************************************************************
      ************ DclReader.java ***************************************
      *******************************************************************
      import java.io.*;
      import org.xml.sax.ext.*;
      import org.xml.sax.*;
      import javax.xml.parsers.SAXParser;
      import javax.xml.parsers.SAXParserFactory;
      import javax.xml.parsers.FactoryConfigurationError;
      import javax.xml.parsers.ParserConfigurationException;
      import org.xml.sax.helpers.DefaultHandler;

      public class DeclReader
      implements DeclHandler
      {
      public void elementDecl(String name,
                              String model)
                       throws SAXException
      {
      }

      public void attributeDecl(String eName,
                                String aName,
                                String type,
                                String valueDefault,
                                String value)
                         throws SAXException
      {
      System.out.println("eName = " + eName + "; aName = " +
      aName + "; type = " + type);
      }

      public void internalEntityDecl(String name,
                                     String value)
                              throws SAXException
      {
      }

      public void externalEntityDecl(String name,
                                     String publicId,
                                     String systemId)
                              throws SAXException
      {
      }

      public static void main(String argv[])
         {
      File f = new File("test.xml");
      DeclReader declReader = new DeclReader();
      SAXParserFactory saxFactory = SAXParserFactory.newInstance();
      try {
      SAXParser saxParser = saxFactory.newSAXParser();
      saxParser.setProperty(
      "http://xml.org/sax/properties/declaration-handler",
      declReader);
      DefaultHandler dh = new DefaultHandler();
      saxParser.parse(f,dh);
      }
      catch (Throwable t) {
            t.printStackTrace();
            }

      System.out.println("File Loaded " + f.toString());
      }
      }
      ******************************************************************************
      *************** output *******************************************************
      eName = at; aName = index; type = CDATA
      eName = at; aName = status; type = ENUMERATION
      eName = at; aName = owner; type = CDATA
      File Loaded test.xml
      ******************************************************************************
      ********** EXPECTED OUTPUT ***************************************************
      eName = at; aName = index; type = CDATA
      eName = at; aName = status; type = (out-of-service|reserved|available|in-use)
      eName = at; aName = owner; type = CDATA
      File Loaded test.xml
      *******************************************************************************
      Note: the bug is actualy in the parser factory.
            I can not build a DTD aware editor without being able to access the
            list of legit values.
      (Review ID: 133586)
      ======================================================================

            egoei Edwin Goei (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: