Uploaded image for project: 'Xerces2-J'
  1. Xerces2-J
  2. XERCESJ-1467

cvc-elt.4.3: Type 'xs:localComplexType' is not validly derived from the type definition, 'complexType', of element 'child'.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • 2.10.0
    • None
    • None
    • Xerces2-J 2.10.0

    Description

      Given the schema (dgreen.xsd):

      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="http://www.w3.org/2001/XMLSchema.xsd"/>
      <xs:element name="root">
      <xs:complexType>
      <xs:sequence>
      <xs:element name="child" type="xs:complexType"/>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:schema>

      Parsing the instance document (dgreen.xml):

      <?xml version="1.0"?>
      <root>
      <child xsi:type="xs:localComplexType"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
      </root>

      Code to reproduce (Main.java):

      import org.apache.xerces.jaxp.validation.XMLSchemaFactory;
      import javax.xml.validation.Schema;
      import javax.xml.validation.Validator;
      import javax.xml.transform.stream.StreamSource;
      import java.io.File;
      public class Main {
      public static void main( String... args ) throws Exception

      { XMLSchemaFactory schemaFactory = new XMLSchemaFactory(); Schema schema = schemaFactory.newSchema( new File( "dgreen.xsd" ) ); Validator validator = schema.newValidator(); validator.validate( new StreamSource( new File( "dgreen.xml" ) ) ); }

      }

      Produces the following:

      Exception in thread "main" org.xml.sax.SAXParseException: cvc-elt.4.3: Type 'xs:localComplexType' is not validly derived from the type definition, 'complexType', of element 'child'.
      at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
      at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
      at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
      at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
      at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
      at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
      at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
      at org.apache.xerces.impl.xs.XMLSchemaValidator.getAndCheckXsiType(Unknown Source)
      at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
      at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown Source)
      at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.jaxp.validation.StreamValidatorHelper.validate(Unknown Source)
      at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)
      at javax.xml.validation.Validator.validate(Validator.java:127)
      at Main.main(Main.java:11)

      I believe that localComplexType is validly derived from complexType, or am I missing something? I apologize in advance if I filed this bug in error.

      Attachments

        1. XERCESJ-1467.zip
          1.0 kB
          David Green-Lank

        Activity

          People

            mrglavas@ca.ibm.com Michael Glavassevich
            milliway@gmail.com David Green-Lank
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: