[ 
https://issues.apache.org/jira/browse/XERCESJ-1467?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Michael Glavassevich resolved XERCESJ-1467.
-------------------------------------------

    Resolution: Invalid

It took me awhile to realize what was going on but the reason why you can't use 
xsi:type here is because of the blockDefault="#all" at the top of 
XMLSchema.xsd.  This blocks type substitutions for "xs:complexType" and other 
type definitions in the Schema for schemas.  Removing blockDefault="#all" from 
the schema allows the xsi:type, but I'm sure the W3C working group had some 
reason for defining it the way they did.  You would have to check with them as 
to why.

Thanks.

> cvc-elt.4.3: Type 'xs:localComplexType' is not validly derived from the type 
> definition, 'complexType', of element 'child'. 
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1467
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1467
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: XML Schema 1.0 Structures
>    Affects Versions: 2.10.0
>         Environment: Xerces2-J 2.10.0
>            Reporter: David Green-Lank
>            Assignee: Michael Glavassevich
>         Attachments: XERCESJ-1467.zip
>
>
> 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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to