jaxp
  1. jaxp
  2. JAXP-23

JAXP 1.3 cannot failed to validate XML against DTD

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      23

      Description

      JAXP 1.3 failed to parse an valid XML against a DTD. Using the following Java
      class and XML document to test.

      import javax.xml.parsers.*;
      import org.xml.sax.*;
      import org.xml.sax.helpers.*;
      import java.io.*;

      /**

      • To test:
      • 1. Using jdk1.4.2.
      • 2. Put the six jar files of JAXP 1.2 in $jdkhome/jre/lib/endorsed directory.
      • 3. Compile and run. Parsing is a success.
      • 4. Replace the six jar files of JAXP 1.2 with the five jar files of JAXP 1.3.
      • 5. Compile and run. Parsing is a failure.
        */
        public class XmlTest {

      /** The property name to specify schema language. */
      public static final String JAXP_SCHEMA_LANGUAGE =
      "http://java.sun.com/xml/jaxp/properties/schemaLanguage";

      /** The property value for W3C schema language. */
      public static final String W3C_XML_SCHEMA =
      "http://www.w3.org/2001/XMLSchema";

      public static void main(String[] args) {
      try {
      SAXParserFactory factory = SAXParserFactory.newInstance();
      System.out.println("SAXParserFactory: "+factory.getClass().getName());

      factory.setNamespaceAware(true);
      factory.setValidating(true);

      SAXParser parser = factory.newSAXParser();
      FileInputStream xmlStream = new FileInputStream("ejbxml.xml");
      DefaultHandler handler = new DefaultHandler() {
      // override to do validation
      public void error(SAXParseException e) throws SAXException

      { throw e; }

      };

      // If the following line is enabled, the parsing will fail. The
      // xml is defined by a DTD rather than a schema. Therefore, the
      // parser should not fail due to the following line. In fact, the
      // failure only occurs when using JAXP 1.3 (i.e. JDK 1.5), JAXP 1.2
      // works just fine.
      parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);

      parser.parse(xmlStream, handler);

      System.out.println("Successfully parsed XML");
      System.exit(0);
      } catch(Exception e)

      { System.out.println("Caught exception"); e.printStackTrace(); System.exit(1); }

      }
      }

      <?xml version="1.0"?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans
      1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
      <ejb-jar>
      <display-name>AccountEjbJar</display-name>
      <enterprise-beans>
      <entity>
      <display-name>AccountEjb</display-name>
      <ejb-name>AccountEjb</ejb-name>
      <home>j2eetrails.account.ejb.AccountHome</home>
      <remote>j2eetrails.account.ejb.Account</remote>
      <ejb-class>j2eetrails.account.ejb.AccountEjb</ejb-class>
      <persistence-type>Bean</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      <reentrant>False</reentrant>
      <resource-ref>
      <res-ref-name>jdbc/SQLServerDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>
      </entity>
      </enterprise-beans>
      <assembly-descriptor>
      <security-role>
      <role-name>all</role-name>
      </security-role>
      <method-permission>
      <role-name>all</role-name>
      <method>
      <ejb-name>AccountEjb</ejb-name>
      <method-name>*</method-name>
      </method>
      </method-permission>
      <container-transaction>
      <method>
      <ejb-name>AccountEjb</ejb-name>
      <method-intf>Home</method-intf>
      <method-name>remove</method-name>
      <method-params>
      <method-param>java.lang.Object</method-param>
      </method-params>
      </method>
      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction>
      <method>
      <ejb-name>AccountEjb</ejb-name>
      <method-intf>Remote</method-intf>
      <method-name>debit</method-name>
      <method-params>
      <method-param>double</method-param>
      </method-params>
      </method>
      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction>
      <method>
      <ejb-name>AccountEjb</ejb-name>
      <method-intf>Remote</method-intf>
      <method-name>getBalance</method-name>
      </method>
      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction>
      <method>
      <ejb-name>AccountEjb</ejb-name>
      <method-intf>Remote</method-intf>
      <method-name>credit</method-name>
      <method-params>
      <method-param>double</method-param>
      </method-params>
      </method>
      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>

        Activity

        tryzigc created issue -
        Hide
        Joe Wang added a comment -

        Assigning to Norm

        Show
        Joe Wang added a comment - Assigning to Norm
        kenaiadmin made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 23 46707

          People

          • Assignee:
            ndw
            Reporter:
            tryzigc
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: