Hi Mukul,

I did some debugging with your latest XML schema document and I too get the
same error message you get. However according to my observations the type
alternatives implementation assign the correct address type to the ADDRESS
element. I'll continue to test this scenario further.

Thanks

Best Regards,
Hiranya

On Thu, Dec 18, 2008 at 10:08 AM, Hiranya Jayathilaka
<[email protected]>wrote:

> Hi Mukul,
>
> I'm a bit surprised to hear that type alternatives implementation is not
> working as expected. In all the debug sessions I ran recently I haven't
> found any issues in the type alternatives code. I can clearly see the type
> alternatives getting parsed properly and a type being assigned based on the
> evaluation of the XPath expressions.
>
> Anyway I'll test it with the latest XML schema document you have posted.
> The error you have reported here seems to be a SAX exception and I'm not
> sure whether it has anything to do with the type alternatives code.
>
> Thanks
>
> Best Regards,
> Hiranya
>
>
> On Wed, Dec 17, 2008 at 10:20 PM, Mukul Gandhi <[email protected]>wrote:
>
>> Hi Michael,
>>  Thanks for the code you gave earlier to invoke the XML Schema 1.1
>> processor, and the below information.
>>
>> I have now downloaded the latest Xerces SVN code (as per the below
>> information you gave).
>>
>> Now the type alternative is being recognized by Xerces.
>>
>> Below are the XML document and XML Schema I am trying:
>>
>> XML file:
>>
>> <PERSON xsi:noNamespaceSchemaLocation="person.xsd"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>>  <FNAME>Mukul</FNAME>
>>  <LNAME>Gandhi</LNAME>
>>  <DOB>1999-06-02</DOB>
>>  <ADDRESS type="short">
>>    <street1>ddd</street1>
>>        <street2>aaa</street2>
>>        <city>aaa</city>
>>  </ADDRESS>
>> </PERSON>
>>
>> XML Schema file:
>>
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
>>
>>   <xs:element name="PERSON" type="PersonType" />
>>
>>   <xs:complexType name="PersonType">
>>      <xs:sequence>
>>        <xs:element name="FNAME" type="xs:string" />
>>        <xs:element name="LNAME" type="xs:string" />
>>        <xs:element name="DOB" type="xs:date" />
>>        <xs:element name="ADDRESS" type="Address">
>>          <xs:alternative test="@type='short'" type="ShortAddress"/>
>>          <xs:alternative test="@type='long'" type="LongAddress"/>
>>        </xs:element>
>>      </xs:sequence>
>>   </xs:complexType>
>>
>>   <xs:complexType name="Address">
>>     <xs:sequence>
>>       <xs:element name="street1" type="xs:string" />
>>       <xs:element name="street2" type="xs:string" minOccurs="0" />
>>     </xs:sequence>
>>     <xs:attribute name="type" type="xs:string"/>
>>   </xs:complexType>
>>
>>   <xs:complexType name="ShortAddress">
>>     <xs:complexContent>
>>       <xs:extension base="Address">
>>         <xs:sequence>
>>           <xs:element name="city" type="xs:string" />
>>         </xs:sequence>
>>       </xs:extension>
>>     </xs:complexContent>
>>   </xs:complexType>
>>
>>   <xs:complexType name="LongAddress">
>>     <xs:complexContent>
>>       <xs:extension base="Address">
>>         <xs:sequence>
>>           <xs:element name="city" type="xs:string" />
>>           <xs:element name="state" type="xs:string" />
>>           <xs:element name="pin" type="xs:string" />
>>           <xs:element name="country" type="xs:string" />
>>         </xs:sequence>
>>       </xs:extension>
>>     </xs:complexContent>
>>   </xs:complexType>
>>
>> </xs:schema>
>>
>> After validation I am getting below errors:
>>
>> org.xml.sax.SAXParseException: cvc-complex-type.2.4.d: Invalid content
>> was found starting with element 'city'.
>>  No child element is expected at this point.
>>         at
>> org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:196)
>>        at
>> org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:132)
>>        at
>> org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:394)
>>        at
>> org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
>>        at
>> org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:282)
>>        at
>> org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:4
>> 66)
>>        at
>> org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3473)
>>         at
>> org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1949)
>>         at
>> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:782)
>>         at
>> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:283)
>>
>>        at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumen
>> tFragmentScannerImpl.java:1653)
>>        at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.j
>> ava:324)
>>        at
>> org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:864)
>>        at
>> org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:787)
>>        at
>> org.apache.xerces.jaxp.validation.StreamValidatorHelper.validate(StreamValidatorHelper.java:181)
>>        at
>> org.apache.xerces.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:129)
>>        at javax.xml.validation.Validator.validate(Unknown Source)
>>        at XMLSchema11Test.main(XMLSchema11Test.java:15)
>>
>> Following are my observations:
>> 1) Type alternative is not working as expected
>> 2) Even without specifying version="1.1" in the Schema, type
>> alternatives are recognized
>> 3) The above error message do not display location of the error. It
>> doesn't also say whether the error was in the XML document or the
>> Schema.
>>
>> Please correct me on any of the points.
>>
>> My objective of testing type alternatives is to help make it's
>> implementation accurate and robust.
>>
>> On Wed, Dec 17, 2008 at 6:19 PM, Michael Glavassevich
>> <[email protected]> wrote:
>> > Hi Mukul,
>> >
>> > The language identifier [1] we were using for XML Schema 1.1 was
>> incorrect.
>> > I just committed a fix to SVN. You should replace occurrences of
>> > "http://www.w3.org/2001/XMLSchema/v1.1"; with
>> > "http://www.w3.org/XML/XMLSchema/v1.1";.
>> >
>> > Thanks.
>> >
>> > [1] http://www.w3.org/TR/xmlschema11-1/#nonnormative-language-ids
>> >
>> > Michael Glavassevich
>> > XML Parser Development
>> > IBM Toronto Lab
>> > E-mail: [email protected]
>> > E-mail: [email protected]
>>
>>
>>
>> --
>> Regards,
>> Mukul Gandhi
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>

Reply via email to