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

validation.SchemaFactory: invalid particle restriction is not detected

    XMLWordPrintable

Details

    • 1.3
    • generic
    • generic

    Backports

      Description

        particlesQ031
            api/xml_schema/msxsdtest/Particles/particlesR006.html#particlesR006
            api/xml_schema/msxsdtest/Particles/particlesR010.html#particlesR010
            api/xml_schema/msxsdtest/Particles/particlesR014.html#particlesR014
            api/xml_schema/msxsdtest/Particles/particlesR018.html#particlesR018
            api/xml_schema/msxsdtest/Particles/particlesR021.html#particlesR021
            api/xml_schema/msxsdtest/Particles/particlesR023.html#particlesR023
            api/xml_schema/msxsdtest/Particles/particlesR025.html#particlesR025
            api/xml_schema/msxsdtest/Particles/particlesR026.html#particlesR026
            api/xml_schema/msxsdtest/Particles/particlesR027.html#particlesR027
            api/xml_schema/msxsdtest/Particles/particlesR028.html#particlesR028
            api/xml_schema/msxsdtest/Particles/particlesR031.html#particlesR031
            api/xml_schema/msxsdtest/Particles/particlesS002.html#particlesS002
            api/xml_schema/msxsdtest/Particles/particlesS005.html#particlesS005
            api/xml_schema/msxsdtest/Particles/particlesS006.html#particlesS006
            api/xml_schema/msxsdtest/Particles/particlesS008.html#particlesS008
            api/xml_schema/msxsdtest/Particles/particlesS009.html#particlesS009
            api/xml_schema/msxsdtest/Particles/particlesS010.html#particlesS010
            api/xml_schema/msxsdtest/Particles/particlesT002.html#particlesT002
            api/xml_schema/msxsdtest/Particles/particlesT008.html#particlesT008
            api/xml_schema/msxsdtest/Particles/particlesT009.html#particlesT009
            api/xml_schema/msxsdtest/Particles/particlesT010.html#particlesT010
            api/xml_schema/msxsdtest/Particles/particlesT011.html#particlesT011
            api/xml_schema/msxsdtest/Particles/particlesU001.html#particlesU001
            api/xml_schema/msxsdtest/Particles/particlesU002.html#particlesU002
            api/xml_schema/msxsdtest/Particles/particlesU006.html#particlesU006
            api/xml_schema/msxsdtest/Particles/particlesU008.html#particlesU008
            api/xml_schema/msxsdtest/Particles/particlesU009.html#particlesU009
            api/xml_schema/msxsdtest/Particles/particlesV002.html#particlesV002
            api/xml_schema/msxsdtest/Particles/particlesV005.html#particlesV005
            api/xml_schema/msxsdtest/Particles/particlesV016.html#particlesV016
            api/xml_schema/msxsdtest/Particles/particlesV017.html#particlesV017
            api/xml_schema/msxsdtest/Particles/particlesV018.html#particlesV018
            api/xml_schema/msxsdtest/Particles/particlesV020.html#particlesV020
            api/xml_schema/msxsdtest/Particles/particlesW002.html#particlesW002
            api/xml_schema/msxsdtest/Particles/particlesW005.html#particlesW005
            api/xml_schema/msxsdtest/Particles/particlesW007.html#particlesW007
            api/xml_schema/msxsdtest/Particles/particlesW010.html#particlesW010
            api/xml_schema/msxsdtest/Particles/particlesW012.html#particlesW012
            api/xml_schema/msxsdtest/Particles/particlesW013.html#particlesW013
            api/xml_schema/msxsdtest/Particles/particlesW014.html#particlesW014
            api/xml_schema/msxsdtest/Particles/particlesW015.html#particlesW015

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

        Name: eaR10174 Date: 03/23/2004


        The following forbidden particle restriction(Choice:Sequence)
        is not detected:

        ------------------------------------------ test.java
        <?xml version="1.0"?>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               targetNamespace="http://xsdtesting"
               xmlns:x="http://xsdtesting"
               elementFormDefault="qualified">
            <xsd:complexType name="base">
                <xsd:sequence>
                    <xsd:element name="e1" minOccurs="0"/>
                    <xsd:element name="e2" minOccurs="0"/>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:element name="doc">
                <xsd:complexType>
                    <xsd:complexContent>
                        <xsd:restriction base="x:base">
                            <xsd:choice>
                                <xsd:element name="e1" minOccurs="0"/>
                            </xsd:choice>
                        </xsd:restriction>
                    </xsd:complexContent>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
        ------------------------------------------------ log
        $ java -showversion test test.xsd
        java version "1.5.0-beta2"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b43)
        Java HotSpot(TM) Client VM (build 1.5.0-beta2-b43, mixed mode)

        Failed: test.xsd is valid
        ----------------------------------------------------


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

        Name: eaR10174 Date: 03/23/2004


        The following violation of Schema Component Constraint: Particle Derivation OK
        (All/Choice/Sequence:Any -- NSRecurseCheckCardinality) is not detected:

        ------------------------------------------ test.xsd
        <?xml version="1.0"?>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               targetNamespace="http://xsdtesting"
               xmlns:x="http://xsdtesting">
            <xsd:complexType name="B">
                <xsd:sequence>
                    <xsd:element name="foo" minOccurs="1" maxOccurs="1"/>
                    <xsd:any namespace="##any" minOccurs="0" maxOccurs="3"/>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="R">
                <xsd:complexContent>
                    <xsd:restriction base="x:B">
                        <xsd:sequence>
                            <xsd:element name="foo" minOccurs="1" maxOccurs="1"/>
                            <xsd:sequence minOccurs="0" maxOccurs="1">
                                <xsd:group ref="x:g1"/>
                                <xsd:group ref="x:g2"/>
                            </xsd:sequence>
                        </xsd:sequence>
                    </xsd:restriction>
                </xsd:complexContent>
            </xsd:complexType>

            <xsd:group name="g1">
                <xsd:choice>
                    <xsd:element name="e1" maxOccurs="2"/>
                </xsd:choice>
            </xsd:group>

            <xsd:group name="g2">
                <xsd:choice>
                    <xsd:element name="e2" maxOccurs="2"/>
                </xsd:choice>
            </xsd:group>
        </xsd:schema>
        ------------------------------------------------ log
        $ java -showversion test test.xsd
        java version "1.5.0-beta2"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b43)
        Java HotSpot(TM) Client VM (build 1.5.0-beta2-b43, mixed mode)

        Failed: test.xsd is valid
        ----------------------------------------------------


        ======================================================================
        Name: erR10175 Date: 02/02/2004


         
          The method

        public Schema newSchema(File schema) throws SAXException

        in the class javax.xml.validation.SchemaFactory does not detect
        violation of the constraints described in XML Schema spec (XML Schema Part 1: Structures,
        Section 3.9.6 Constraints on Particle Schema Components, Schema Component Constraint:
        Particle Valid (Restriction) ).

        New 188 JCK-15 beta2 tests adopted from W3C XSTC-20020116 testsuite (see the list below)
        check that the validator detects the Particle Valid Restriction constraints, such as

        Occurrence Range OK,
        Particle Restriction OK (Elt:Elt -- NameAndTypeOK),
        Particle Derivation OK (Elt:Any -- NSCompat),
        Particle Derivation OK (Elt:All/Choice/Sequence -- RecurseAsIfGroup)
        ...

        All the tests fail since the test schemas are accepted as valid ones.

        The bug is found in jdk1.5.0/beta/b35 and it is reproducible in jdk1.5.0/beta/b36.

        Similar bug was reported a year ago against JAXP 1.2. For more details see
        4793367 invalid particle restriction is not detected

        To reproduce the bug compile and run the following code as shown in the log below.
        Instead of the test.xsd try different schemas from the mentioned tests
        that violate various parts of the Particle Valid Restriction constraint:
        ------------------------------------------ test.java
        import java.io.File;
        import org.xml.sax.SAXException;
        import org.xml.sax.SAXParseException;
        import org.xml.sax.helpers.DefaultHandler;
        import javax.xml.validation.SchemaFactory;

        public class test {

            protected static class ErrorHandler extends DefaultHandler {
                public int errorCounter = 0;

                public void error(SAXParseException e) throws SAXException {
                    System.out.println(e);
                    errorCounter++;
                }

                public void fatalError(SAXParseException e) throws SAXException {
                    System.out.println(e);
                    errorCounter++;
                }
            }

            public static void main(String [] args) {
                SchemaFactory schemaFactory =
                        SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");

                ErrorHandler errorHandler = new ErrorHandler();
                schemaFactory.setErrorHandler(errorHandler);

                try {
                    schemaFactory.newSchema(new File(args[0]));
                } catch (SAXException e) {
                    exit(1, "Fatal Error: " + e);
                }

                if (errorHandler.errorCounter == 0) {
                    exit(1, "Failed: " + args[0] + " is valid");
                } else {
                    exit(0, "Passed.");
                }
            }

            public static void exit(int errCode, String msg) {
                System.out.println(msg);
                System.exit(errCode);
            }
        }
        ----------------------------------------------------

        The following schema violates p3. of Schema Component Constraint: Particle
        Restriction OK (Elt:Elt -- NameAndTypeOK).
        ------------------------------------------- test.xsd
        <?xml version="1.0"?>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                    targetNamespace="http://xsdtesting"
                    xmlns:x="http://xsdtesting">
        <xsd:complexType name="B">
        <xsd:all>
        <xsd:element name="e1" minOccurs="1" maxOccurs="1"/>
        <xsd:element name="e2" minOccurs="1" maxOccurs="1"/>
        </xsd:all>
        </xsd:complexType>
        <xsd:complexType name="R">
        <xsd:complexContent>
        <xsd:restriction base="x:B">
        <xsd:sequence>
        <xsd:element name="e1" minOccurs="1" maxOccurs="1"/>
        <xsd:element name="e2" minOccurs="1" maxOccurs="2"/>
        </xsd:sequence>
        </xsd:restriction>
        </xsd:complexContent>
        </xsd:complexType>
        <xsd:element name="doc">
        <xsd:complexType>
        <xsd:choice>
        <xsd:element name="elem" type="x:R"/>
        </xsd:choice>
        </xsd:complexType>
        </xsd:element>
        </xsd:schema>
        ----------------------------------------------------

        ------------------------------------------------ log
        $javac test.java && java -showversion test test.xsd
        java version "1.5.0-beta2"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b35)
        Java HotSpot(TM) Client VM (build 1.5.0-beta2-b35, mixed mode)

        Failed: test.xsd is valid
        ----------------------------------------------------

        This bug affects new tests in JCK 1.5
            api/xml_schema/msxsdtest/Particles/particlesFb003.html#particlesFb003
            api/xml_schema/msxsdtest/Particles/particlesHb001.html#particlesHb001
            api/xml_schema/msxsdtest/Particles/particlesHb002.html#particlesHb002
            api/xml_schema/msxsdtest/Particles/particlesHb003.html#particlesHb003
            api/xml_schema/msxsdtest/Particles/particlesHb004.html#particlesHb004
            api/xml_schema/msxsdtest/Particles/particlesHb006.html#particlesHb006
            api/xml_schema/msxsdtest/Particles/particlesHb007.html#particlesHb007
            api/xml_schema/msxsdtest/Particles/particlesHb008.html#particlesHb008
            api/xml_schema/msxsdtest/Particles/particlesHb009.html#particlesHb009
            api/xml_schema/msxsdtest/Particles/particlesHb010.html#particlesHb010
            api/xml_schema/msxsdtest/Particles/particlesHb011.html#particlesHb011
            api/xml_schema/msxsdtest/Particles/particlesIa006.html#particlesIa006
            api/xml_schema/msxsdtest/Particles/particlesIa008.html#particlesIa008
            api/xml_schema/msxsdtest/Particles/particlesIb002.html#particlesIb002
            api/xml_schema/msxsdtest/Particles/particlesIb004.html#particlesIb004
            api/xml_schema/msxsdtest/Particles/particlesIb006.html#particlesIb006
            api/xml_schema/msxsdtest/Particles/particlesIb007.html#particlesIb007
            api/xml_schema/msxsdtest/Particles/particlesIc002.html#particlesIc002
            api/xml_schema/msxsdtest/Particles/particlesIc004.html#particlesIc004
            api/xml_schema/msxsdtest/Particles/particlesId003.html#particlesId003
            api/xml_schema/msxsdtest/Particles/particlesId006.html#particlesId006
            api/xml_schema/msxsdtest/Particles/particlesId012.html#particlesId012
            api/xml_schema/msxsdtest/Particles/particlesIe006.html#particlesIe006
            api/xml_schema/msxsdtest/Particles/particlesIe009.html#particlesIe009
            api/xml_schema/msxsdtest/Particles/particlesIe012.html#particlesIe012
            api/xml_schema/msxsdtest/Particles/particlesIe014.html#particlesIe014
            api/xml_schema/msxsdtest/Particles/particlesIf007.html#particlesIf007
            api/xml_schema/msxsdtest/Particles/particlesIf008.html#particlesIf008
            api/xml_schema/msxsdtest/Particles/particlesIf009.html#particlesIf009
            api/xml_schema/msxsdtest/Particles/particlesIg006.html#particlesIg006
            api/xml_schema/msxsdtest/Particles/particlesIg007.html#particlesIg007
            api/xml_schema/msxsdtest/Particles/particlesIg008.html#particlesIg008
            api/xml_schema/msxsdtest/Particles/particlesIg009.html#particlesIg009
            api/xml_schema/msxsdtest/Particles/particlesIg010.html#particlesIg010
            api/xml_schema/msxsdtest/Particles/particlesIg013.html#particlesIg013
            api/xml_schema/msxsdtest/Particles/particlesIg016.html#particlesIg016
            api/xml_schema/msxsdtest/Particles/particlesIj003.html#particlesIj003
            api/xml_schema/msxsdtest/Particles/particlesIj004.html#particlesIj004
            api/xml_schema/msxsdtest/Particles/particlesIj007.html#particlesIj007
            api/xml_schema/msxsdtest/Particles/particlesIj008.html#particlesIj008
            api/xml_schema/msxsdtest/Particles/particlesIj009.html#particlesIj009
            api/xml_schema/msxsdtest/Particles/particlesIj010.html#particlesIj010
            api/xml_schema/msxsdtest/Particles/particlesIj011.html#particlesIj011
            api/xml_schema/msxsdtest/Particles/particlesIj012.html#particlesIj012
            api/xml_schema/msxsdtest/Particles/particlesIj013.html#particlesIj013
            api/xml_schema/msxsdtest/Particles/particlesIj015.html#particlesIj015
            api/xml_schema/msxsdtest/Particles/particlesIj016.html#particlesIj016
            api/xml_schema/msxsdtest/Particles/particlesIk002.html#particlesIk002
            api/xml_schema/msxsdtest/Particles/particlesIk003.html#particlesIk003
            api/xml_schema/msxsdtest/Particles/particlesIk005.html#particlesIk005
            api/xml_schema/msxsdtest/Particles/particlesIk006.html#particlesIk006
            api/xml_schema/msxsdtest/Particles/particlesIk007.html#particlesIk007
            api/xml_schema/msxsdtest/Particles/particlesIk008.html#particlesIk008
            api/xml_schema/msxsdtest/Particles/particlesIk009.html#particlesIk009
            api/xml_schema/msxsdtest/Particles/particlesIk010.html#particlesIk010
            api/xml_schema/msxsdtest/Particles/particlesIk011.html#particlesIk011
            api/xml_schema/msxsdtest/Particles/particlesIk013.html#particlesIk013
            api/xml_schema/msxsdtest/Particles/particlesIk015.html#particlesIk015
            api/xml_schema/msxsdtest/Particles/particlesIk016.html#particlesIk016
            api/xml_schema/msxsdtest/Particles/particlesIk019.html#particlesIk019
            api/xml_schema/msxsdtest/Particles/particlesIk020.html#particlesIk020
            api/xml_schema/msxsdtest/Particles/particlesIk021.html#particlesIk021
            api/xml_schema/msxsdtest/Particles/particlesIk022.html#particlesIk022
            api/xml_schema/msxsdtest/Particles/particlesIk024.html#particlesIk024
            api/xml_schema/msxsdtest/Particles/particlesIk025.html#particlesIk025
            api/xml_schema/msxsdtest/Particles/particlesIk027.html#particlesIk027
            api/xml_schema/msxsdtest/Particles/particlesJa003.html#particlesJa003
            api/xml_schema/msxsdtest/Particles/particlesJa006.html#particlesJa006
            api/xml_schema/msxsdtest/Particles/particlesJa012.html#particlesJa012
            api/xml_schema/msxsdtest/Particles/particlesJb006.html#particlesJb006
            api/xml_schema/msxsdtest/Particles/particlesJb009.html#particlesJb009
            api/xml_schema/msxsdtest/Particles/particlesJb012.html#particlesJb012
            api/xml_schema/msxsdtest/Particles/particlesJb014.html#particlesJb014
            api/xml_schema/msxsdtest/Particles/particlesJc003.html#particlesJc003
            api/xml_schema/msxsdtest/Particles/particlesJc006.html#particlesJc006
            api/xml_schema/msxsdtest/Particles/particlesJc012.html#particlesJc012
            api/xml_schema/msxsdtest/Particles/particlesJd006.html#particlesJd006
            api/xml_schema/msxsdtest/Particles/particlesJd009.html#particlesJd009
            api/xml_schema/msxsdtest/Particles/particlesJd012.html#particlesJd012
            api/xml_schema/msxsdtest/Particles/particlesJd014.html#particlesJd014
            api/xml_schema/msxsdtest/Particles/particlesJe003.html#particlesJe003
            api/xml_schema/msxsdtest/Particles/particlesJe006.html#particlesJe006
            api/xml_schema/msxsdtest/Particles/particlesJe012.html#particlesJe012
            api/xml_schema/msxsdtest/Particles/particlesJf006.html#particlesJf006
            api/xml_schema/msxsdtest/Particles/particlesJf009.html#particlesJf009
            api/xml_schema/msxsdtest/Particles/particlesJf012.html#particlesJf012
            api/xml_schema/msxsdtest/Particles/particlesJf014.html#particlesJf014
            api/xml_schema/msxsdtest/Particles/particlesJg001.html#particlesJg001
            api/xml_schema/msxsdtest/Particles/particlesJh001.html#particlesJh001
            api/xml_schema/msxsdtest/Particles/particlesJj003.html#particlesJj003
            api/xml_schema/msxsdtest/Particles/particlesJj006.html#particlesJj006
            api/xml_schema/msxsdtest/Particles/particlesJj012.html#particlesJj012
            api/xml_schema/msxsdtest/Particles/particlesJk009.html#particlesJk009
            api/xml_schema/msxsdtest/Particles/particlesJk012.html#particlesJk012
            api/xml_schema/msxsdtest/Particles/particlesJk014.html#particlesJk014
            api/xml_schema/msxsdtest/Particles/particlesK004.html#particlesK004
            api/xml_schema/msxsdtest/Particles/particlesK006.html#particlesK006
            api/xml_schema/msxsdtest/Particles/particlesOa002.html#particlesOa002
            api/xml_schema/msxsdtest/Particles/particlesOa007.html#particlesOa007
            api/xml_schema/msxsdtest/Particles/particlesOa009.html#particlesOa009
            api/xml_schema/msxsdtest/Particles/particlesOa010.html#particlesOa010
            api/xml_schema/msxsdtest/Particles/particlesOa015.html#particlesOa015
            api/xml_schema/msxsdtest/Particles/particlesOb010.html#particlesOb010
            api/xml_schema/msxsdtest/Particles/particlesOb011.html#particlesOb011
            api/xml_schema/msxsdtest/Particles/particlesOb014.html#particlesOb014
            api/xml_schema/msxsdtest/Particles/particlesOb016.html#particlesOb016
            api/xml_schema/msxsdtest/Particles/particlesOb017.html#particlesOb017
            api/xml_schema/msxsdtest/Particles/particlesOb019.html#particlesOb019
            api/xml_schema/msxsdtest/Particles/particlesOb020.html#particlesOb020
            api/xml_schema/msxsdtest/Particles/particlesOb021.html#particlesOb021
            api/xml_schema/msxsdtest/Particles/particlesOb023.html#particlesOb023
            api/xml_schema/msxsdtest/Particles/particlesOb024.html#particlesOb024
            api/xml_schema/msxsdtest/Particles/particlesOb025.html#particlesOb025
            api/xml_schema/msxsdtest/Particles/particlesOb026.html#particlesOb026
            api/xml_schema/msxsdtest/Particles/particlesOb027.html#particlesOb027
            api/xml_schema/msxsdtest/Particles/particlesOb028.html#particlesOb028
            api/xml_schema/msxsdtest/Particles/particlesOb029.html#particlesOb029
            api/xml_schema/msxsdtest/Particles/particlesOb030.html#particlesOb030
            api/xml_schema/msxsdtest/Particles/particlesOb031.html#particlesOb031
            api/xml_schema/msxsdtest/Particles/particlesOb033.html#particlesOb033
            api/xml_schema/msxsdtest/Particles/particlesOb034.html#particlesOb034
            api/xml_schema/msxsdtest/Particles/particlesOb035.html#particlesOb035
            api/xml_schema/msxsdtest/Particles/particlesOb036.html#particlesOb036
            api/xml_schema/msxsdtest/Particles/particlesOb037.html#particlesOb037
            api/xml_schema/msxsdtest/Particles/particlesOb038.html#particlesOb038
            api/xml_schema/msxsdtest/Particles/particlesOb039.html#particlesOb039
            api/xml_schema/msxsdtest/Particles/particlesOb040.html#particlesOb040
            api/xml_schema/msxsdtest/Particles/particlesOb041.html#particlesOb041
            api/xml_schema/msxsdtest/Particles/particlesOb043.html#particlesOb043
            api/xml_schema/msxsdtest/Particles/particlesOb044.html#particlesOb044
            api/xml_schema/msxsdtest/Particles/particlesOb045.html#particlesOb045
            api/xml_schema/msxsdtest/Particles/particlesOb046.html#particlesOb046
            api/xml_schema/msxsdtest/Particles/particlesOb049.html#particlesOb049
            api/xml_schema/msxsdtest/Particles/particlesOb050.html#particlesOb050
            api/xml_schema/msxsdtest/Particles/particlesOb051.html#particlesOb051
            api/xml_schema/msxsdtest/Particles/particlesOb058.html#particlesOb058
            api/xml_schema/msxsdtest/Particles/particlesQ006.html#particlesQ006
            api/xml_schema/msxsdtest/Particles/particlesQ008.html#particlesQ008
            api/xml_schema/msxsdtest/Particles/particlesQ012.html#particlesQ012
            api/xml_schema/msxsdtest/Particles/particlesQ018.html#particlesQ018
            api/xml_schema/msxsdtest/Particles/particlesQ021.html#particlesQ021
            api/xml_schema/msxsdtest/Particles/particlesQ023.html#particlesQ023
            api/xml_schema/msxsdtest/Particles/particlesQ025.html#particlesQ025
            api/xml_schema/msxsdtest/Particles/particlesQ026.html#particlesQ026
            api/xml_schema/msxsdtest/Particles/particlesQ027.html#particlesQ027
            api/xml_schema/msxsdtest/Particles/particlesQ028.html#particlesQ028
            api/xml_schema/msxsdtest/Particles/particlesQ031.html#

        Attachments

          Issue Links

            Activity

              People

                kkawagucsunw Kohsuke Kawaguchi (Inactive)
                reysunw Rey Rey (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: