You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org> on 2008/12/16 21:09:44 UTC

[jira] Commented: (XERCESJ-1351) Type alternatives implementation seems to be broken

    [ https://issues.apache.org/jira/browse/XERCESJ-1351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12657142#action_12657142 ] 

Michael Glavassevich commented on XERCESJ-1351:
-----------------------------------------------

Mukul, I get different behaviour when I try your test.  The only error I'm getting is:

org.xml.sax.SAXParseException: cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type 'shortString'.
	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:466)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3473)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidComplexType(XMLSchemaValidator.java:3387)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidType(XMLSchemaValidator.java:3356)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.processElementContent(XMLSchemaValidator.java:3258)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleEndElement(XMLSchemaValidator.java:2349)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:888)

I would have expected that an error be reported for the schema, because your example isn't actually valid.  Each type alternative must be substitutible [1] for the declared type, however ShortAddress isn't derived from LongAddress. When I replace the declared type with xs:anyType, I get yet another error:

java.lang.NullPointerException
	at org.apache.xerces.impl.xpath.XPath20$NodeTest.evaluateNodeTest(XPath20.java:1356)
	at org.apache.xerces.impl.xpath.XPath20.visitNode(XPath20.java:93)
	at org.apache.xerces.impl.xpath.XPath20.traverseTree(XPath20.java:72)
	at org.apache.xerces.impl.xs.alternative.Test.evaluateTest(Test.java:56)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2261)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:782)

so it seems there are a bunch of problems which need to be addressed/fixed.

[1] http://www.w3.org/TR/xmlschema11-1/#d0e13952

> Type alternatives implementation seems to be broken
> ---------------------------------------------------
>
>                 Key: XERCESJ-1351
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1351
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: XML Schema 1.1 Structures
>         Environment: Windows XP, JRE 1.5.0_15
>            Reporter: Mukul Gandhi
>
> I am running the latest Xerces-J development code from SVN repository. I tried the following sample XML document, and the XML Schema document.
> XML document:
> <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">my address</ADDRESS>
> </PERSON>
> Schema:
> <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="LongAddress">
>           <xs:alternative test="@type='short'" type="ShortAddress"/>
> 	  <xs:alternative test="@type='long'" type="LongAddress"/>
> 	</xs:element>
>       </xs:sequence>
>    </xs:complexType>
>    <xs:complexType name="ShortAddress"> 
>      <xs:simpleContent> 
>        <xs:extension base="shortString"> 
>          <xs:attribute name="type" type="xs:string"/> 
>        </xs:extension> 
>      </xs:simpleContent> 
>    </xs:complexType> 
>    <xs:simpleType name="shortString"> 
>      <xs:restriction base="xs:string"> 
>        <xs:minLength value="1" /> 
>        <xs:maxLength value="50" /> 
>      </xs:restriction> 
>    </xs:simpleType>
>    <xs:complexType name="LongAddress">
>      <xs:sequence>
>        <xs:element name="street1" type="xs:string" />
>        <xs:element name="street2" type="xs:string" minOccurs="0" />
>        <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:attribute name="type" type="xs:string"/>
>    </xs:complexType>
> </xs:schema>
> When I apply validation using the above examples, with Xerces, I get following errors:
> [Error] person.xsd:11:69: s4s-elt-must-match.1: The content of 'ADDRESS' must match (annotation?, (simpleType
> | complexType)?, alternative*, (unique | key | keyref)*)). A problem was found starting at: alternative.
> [Error] person.xml:5:45: cvc-complex-type.2.3: Element 'ADDRESS' cannot have character [children], because the
>  type's content type is element-only.
> [Error] person.xml:5:45: cvc-complex-type.2.4.b: The content of element 'ADDRESS' is not complete. One of '{st
> reet1}' is expected.
> It seems to me, that type alternative support in Xerces is not working as expected.
> Some comments about the Java class, org.apache.xerces.impl.xpath.XPath20 (which I think is used by type alternatives)
> The method, 
> public boolean  evaluateNodeTest(QName element, XMLAttributes attributes) 
> doesn't use the parameter, "element" anywhere in the method body.
> Please correct me, on any of the points I have mentioned.

-- 
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: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


Re: [jira] Commented: (XERCESJ-1351) Type alternatives implementation seems to be broken

Posted by Hiranya Jayathilaka <hi...@gmail.com>.
Hi Mukul,

Type alternatives feature is present only in XML Schema 1.1. Therefore the
type alternatives traverser will be triggered only if the schema version is
1.1.

About the other issues you and Michael have reported I'll look into them
asap and will post in some remarks. Thanks for taking time to test the type
alternatives implementation.

Thanks

Best Regards,
Hiranya


On Wed, Dec 17, 2008 at 11:25 AM, Mukul Gandhi <ga...@gmail.com>wrote:

> Hi Michael,
>   I was using a slightly older SVN code for Xerces. Now I have
> downloaded today the latest Xerces SVN code. I am creating a file
> like, xercesImpl.jar from the latest SVN code and using it.
>
> I am now trying the below examples (with corrections in the Schema as
> you have pointed).
>
> 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>
>
> Schema:
>
> <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>
>
> When I perform the validation (using the jaxp.SourceValidator
> utility), I get following errors:
>
> [Error] person.xsd:11:69: s4s-elt-must-match.1: The content of
> 'ADDRESS' must match (annotation?, (simpleType | complexType)?,
> alternative*, (unique | key | keyref)*)). A problem was found starting
> at: alternative.
> [Error] person.xml:8:8: cvc-complex-type.2.4.d: Invalid content was
> found starting with element 'city'. No child element is expected at
> this point.
>
> I saw following code in the Java file, XSDElementTraverser.java
>
> if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
>     while (childName.equals(SchemaSymbols.ELT_ALTERNATIVE)) {
>        fSchemaHandler.fTypeAlternativeTraverser.traverse(child,
> element, schemaDoc, grammar);
>
> It seems to me, that TypeAlternativeTraverser is triggered only when
> version 1.1 is specified in the XSD file. How should I specify this
> information in the Schema file?
>
> Thanks for your help ...
>
> On Wed, Dec 17, 2008 at 1:39 AM, Michael Glavassevich (JIRA)
> <xe...@xml.apache.org> wrote:
> >
> >    [
> https://issues.apache.org/jira/browse/XERCESJ-1351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12657142#action_12657142]
> >
> > Michael Glavassevich commented on XERCESJ-1351:
> > -----------------------------------------------
> >
> > Mukul, I get different behaviour when I try your test.  The only error
> I'm getting is:
> >
> > org.xml.sax.SAXParseException: cvc-minLength-valid: Value '' with length
> = '0' is not facet-valid with respect to minLength '1' for type
> 'shortString'.
>
>
>
> --
> Regards,
> Mukul Gandhi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org
>
>

Re: [jira] Commented: (XERCESJ-1351) Type alternatives implementation seems to be broken

Posted by Mukul Gandhi <ga...@gmail.com>.
Hi Hiranya,
  I'll be eagerly waiting for your further comments and findings.

On Thu, Dec 18, 2008 at 11:04 AM, Hiranya Jayathilaka
<hi...@gmail.com> wrote:
> 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


-- 
Regards,
Mukul Gandhi

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


Re: [jira] Commented: (XERCESJ-1351) Type alternatives implementation seems to be broken

Posted by Hiranya Jayathilaka <hi...@gmail.com>.
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
<hi...@gmail.com>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 <ga...@gmail.com>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
>> <mr...@ca.ibm.com> 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: mrglavas@ca.ibm.com
>> > E-mail: mrglavas@apache.org
>>
>>
>>
>> --
>> Regards,
>> Mukul Gandhi
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
>> For additional commands, e-mail: j-dev-help@xerces.apache.org
>>
>>
>

Re: [jira] Commented: (XERCESJ-1351) Type alternatives implementation seems to be broken

Posted by Hiranya Jayathilaka <hi...@gmail.com>.
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 <ga...@gmail.com>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
> <mr...@ca.ibm.com> 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: mrglavas@ca.ibm.com
> > E-mail: mrglavas@apache.org
>
>
>
> --
> Regards,
> Mukul Gandhi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org
>
>

Re: SchemaFactory and XML Schema 1.1 (was: [jira] Commented: (XERCESJ-1351) Type alternatives implementation seems to be broken)

Posted by Mukul Gandhi <ga...@gmail.com>.
Thanks, Michael for the information ... It helps me.

On Fri, Dec 19, 2008 at 10:02 AM, Michael Glavassevich
<mr...@ca.ibm.com> wrote:
> Hi Mukul,
>
> The version attribute which you can add to <xs:schema> is for user
> convenience only, I suppose as a possible mechanism for versioning their
> schemas. This attribute has no semantics defined for it. Aside from checking
> that its value is a valid xs:token it's going to be ignored by Xerces. It's
> the identifier you pass to SchemaFactory.newInstance() which determines
> whether you get an XML Schema 1.0 or 1.1 processor. More details on this are
> on the Wiki [1].
>
> Thanks.
>
> [1] http://wiki.apache.org/xerces/Xerces-J:_XML_Schema_1.1_Design_Thoughts
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org



-- 
Regards,
Mukul Gandhi

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


SchemaFactory and XML Schema 1.1 (was: [jira] Commented: (XERCESJ-1351) Type alternatives implementation seems to be broken)

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Mukul,

The version attribute which you can add to <xs:schema> is for user
convenience only, I suppose as a possible mechanism for versioning their
schemas. This attribute has no semantics defined for it. Aside from
checking that its value is a valid xs:token it's going to be ignored by
Xerces. It's the identifier you pass to SchemaFactory.newInstance() which
determines whether you get an XML Schema 1.0 or 1.1 processor. More details
on this are on the Wiki [1].

Thanks.

[1] http://wiki.apache.org/xerces/Xerces-J:_XML_Schema_1.1_Design_Thoughts

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

"Mukul Gandhi" <ga...@gmail.com> wrote on 12/17/2008 11:53:36 AM:

> On Wed, Dec 17, 2008 at 10:20 PM, Mukul Gandhi <ga...@gmail.com>
wrote:
> > 2) Even without specifying version="1.1" in the Schema, type
> > alternatives are recognized
>
> I think this is because, we specified following in the file,
> XMLSchema11Test.java
>
> System.setProperty("javax.xml.validation.SchemaFactory:http://www.
> w3.org/XML/XMLSchema/v1.1",
> "org.apache.xerces.jaxp.validation.XMLSchema11Factory");
> SchemaFactory sf =
> SchemaFactory.newInstance("http://www.w3.org/XML/XMLSchema/v1.1");
>
>
> --
> Regards,
> Mukul Gandhi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org

Re: [jira] Commented: (XERCESJ-1351) Type alternatives implementation seems to be broken

Posted by Mukul Gandhi <ga...@gmail.com>.
On Wed, Dec 17, 2008 at 10:20 PM, Mukul Gandhi <ga...@gmail.com> wrote:
> 2) Even without specifying version="1.1" in the Schema, type
> alternatives are recognized

I think this is because, we specified following in the file,
XMLSchema11Test.java

System.setProperty("javax.xml.validation.SchemaFactory:http://www.w3.org/XML/XMLSchema/v1.1",
"org.apache.xerces.jaxp.validation.XMLSchema11Factory");
SchemaFactory sf =
SchemaFactory.newInstance("http://www.w3.org/XML/XMLSchema/v1.1");


-- 
Regards,
Mukul Gandhi

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


Re: [jira] Commented: (XERCESJ-1351) Type alternatives implementation seems to be broken

Posted by Mukul Gandhi <ga...@gmail.com>.
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
<mr...@ca.ibm.com> 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: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org



-- 
Regards,
Mukul Gandhi

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


Re: [jira] Commented: (XERCESJ-1351) Type alternatives implementation seems to be broken

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
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: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Michael Glavassevich/Toronto/IBM@IBMCA wrote on 12/17/2008 07:19:53 AM:

> Hi Mukul,
>
> The jaxp.SourceValidator sample creates a SchemaFactory for XML
> Schema 1.0 by default. There's no identifier for an XML Schema 1.1
> document. You need to explicitly select an XML Schema 1.1 processor
> if you want to load and use it.
>
> For example:
>
> import javax.xml.transform.stream.StreamSource;
> import javax.xml.validation.Schema;
> import javax.xml.validation.SchemaFactory;
> import javax.xml.validation.Validator;
>
> public class XMLSchema11Test {
>
>     public static void main (String [] args) {
>         try {
>             System.setProperty("javax.xml.validation.SchemaFactory:
> http://www.w3.org/2001/XMLSchema/v1.1",
>                  "org.apache.xerces.jaxp.validation.XMLSchema11Factory");
>             SchemaFactory sf = SchemaFactory.newInstance("http:
> //www.w3.org/2001/XMLSchema/v1.1");
>             Schema s = sf.newSchema(new StreamSource(args[0]));
>             Validator v = s.newValidator();
>             v.validate(new StreamSource(args[1]));
>         }
>         catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
> }
>
> Thanks.
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> "Mukul Gandhi" <ga...@gmail.com> wrote on 12/17/2008 12:55:42 AM:
>
> > Hi Michael,
> >    I was using a slightly older SVN code for Xerces. Now I have
> > downloaded today the latest Xerces SVN code. I am creating a file
> > like, xercesImpl.jar from the latest SVN code and using it.
> >
> > I am now trying the below examples (with corrections in the Schema as
> > you have pointed).
> >
> > 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>
> >
> > Schema:
> >
> > <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>
> >
> > When I perform the validation (using the jaxp.SourceValidator
> > utility), I get following errors:
> >
> > [Error] person.xsd:11:69: s4s-elt-must-match.1: The content of
> > 'ADDRESS' must match (annotation?, (simpleType | complexType)?,
> > alternative*, (unique | key | keyref)*)). A problem was found starting
> > at: alternative.
> > [Error] person.xml:8:8: cvc-complex-type.2.4.d: Invalid content was
> > found starting with element 'city'. No child element is expected at
> > this point.
> >
> > I saw following code in the Java file, XSDElementTraverser.java
> >
> > if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
> >      while (childName.equals(SchemaSymbols.ELT_ALTERNATIVE)) {
> >         fSchemaHandler.fTypeAlternativeTraverser.traverse(child,
> > element, schemaDoc, grammar);
> >
> > It seems to me, that TypeAlternativeTraverser is triggered only when
> > version 1.1 is specified in the XSD file. How should I specify this
> > information in the Schema file?
> >
> > Thanks for your help ...
> >
> > On Wed, Dec 17, 2008 at 1:39 AM, Michael Glavassevich (JIRA)
> > <xe...@xml.apache.org> wrote:
> > >
> > >    [ https://issues.apache.org/jira/browse/XERCESJ-1351?page=com.
> > atlassian.jira.plugin.system.issuetabpanels:comment-
> > tabpanel&focusedCommentId=12657142#action_12657142 ]
> > >
> > > Michael Glavassevich commented on XERCESJ-1351:
> > > -----------------------------------------------
> > >
> > > Mukul, I get different behaviour when I try your test.  The only
> > error I'm getting is:
> > >
> > > org.xml.sax.SAXParseException: cvc-minLength-valid: Value '' with
> > length = '0' is not facet-valid with respect to minLength '1' for
> > type 'shortString'.
> >
> >
> >
> > --
> > Regards,
> > Mukul Gandhi
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-dev-help@xerces.apache.org

Re: [jira] Commented: (XERCESJ-1351) Type alternatives implementation seems to be broken

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Mukul,

The jaxp.SourceValidator sample creates a SchemaFactory for XML Schema 1.0
by default. There's no identifier for an XML Schema 1.1 document. You need
to explicitly select an XML Schema 1.1 processor if you want to load and
use it.

For example:

import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;

public class XMLSchema11Test {

    public static void main (String [] args) {
        try {
            System.setProperty(
"javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema/v1.1",
                 "org.apache.xerces.jaxp.validation.XMLSchema11Factory");
            SchemaFactory sf = SchemaFactory.newInstance(
"http://www.w3.org/2001/XMLSchema/v1.1");
            Schema s = sf.newSchema(new StreamSource(args[0]));
            Validator v = s.newValidator();
            v.validate(new StreamSource(args[1]));
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

"Mukul Gandhi" <ga...@gmail.com> wrote on 12/17/2008 12:55:42 AM:

> Hi Michael,
>    I was using a slightly older SVN code for Xerces. Now I have
> downloaded today the latest Xerces SVN code. I am creating a file
> like, xercesImpl.jar from the latest SVN code and using it.
>
> I am now trying the below examples (with corrections in the Schema as
> you have pointed).
>
> 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>
>
> Schema:
>
> <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>
>
> When I perform the validation (using the jaxp.SourceValidator
> utility), I get following errors:
>
> [Error] person.xsd:11:69: s4s-elt-must-match.1: The content of
> 'ADDRESS' must match (annotation?, (simpleType | complexType)?,
> alternative*, (unique | key | keyref)*)). A problem was found starting
> at: alternative.
> [Error] person.xml:8:8: cvc-complex-type.2.4.d: Invalid content was
> found starting with element 'city'. No child element is expected at
> this point.
>
> I saw following code in the Java file, XSDElementTraverser.java
>
> if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
>      while (childName.equals(SchemaSymbols.ELT_ALTERNATIVE)) {
>         fSchemaHandler.fTypeAlternativeTraverser.traverse(child,
> element, schemaDoc, grammar);
>
> It seems to me, that TypeAlternativeTraverser is triggered only when
> version 1.1 is specified in the XSD file. How should I specify this
> information in the Schema file?
>
> Thanks for your help ...
>
> On Wed, Dec 17, 2008 at 1:39 AM, Michael Glavassevich (JIRA)
> <xe...@xml.apache.org> wrote:
> >
> >    [ https://issues.apache.org/jira/browse/XERCESJ-1351?page=com.
> atlassian.jira.plugin.system.issuetabpanels:comment-
> tabpanel&focusedCommentId=12657142#action_12657142 ]
> >
> > Michael Glavassevich commented on XERCESJ-1351:
> > -----------------------------------------------
> >
> > Mukul, I get different behaviour when I try your test.  The only
> error I'm getting is:
> >
> > org.xml.sax.SAXParseException: cvc-minLength-valid: Value '' with
> length = '0' is not facet-valid with respect to minLength '1' for
> type 'shortString'.
>
>
>
> --
> Regards,
> Mukul Gandhi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org

Re: [jira] Commented: (XERCESJ-1351) Type alternatives implementation seems to be broken

Posted by Mukul Gandhi <ga...@gmail.com>.
Hi Michael,
   I was using a slightly older SVN code for Xerces. Now I have
downloaded today the latest Xerces SVN code. I am creating a file
like, xercesImpl.jar from the latest SVN code and using it.

I am now trying the below examples (with corrections in the Schema as
you have pointed).

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>

Schema:

<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>

When I perform the validation (using the jaxp.SourceValidator
utility), I get following errors:

[Error] person.xsd:11:69: s4s-elt-must-match.1: The content of
'ADDRESS' must match (annotation?, (simpleType | complexType)?,
alternative*, (unique | key | keyref)*)). A problem was found starting
at: alternative.
[Error] person.xml:8:8: cvc-complex-type.2.4.d: Invalid content was
found starting with element 'city'. No child element is expected at
this point.

I saw following code in the Java file, XSDElementTraverser.java

if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
     while (childName.equals(SchemaSymbols.ELT_ALTERNATIVE)) {
        fSchemaHandler.fTypeAlternativeTraverser.traverse(child,
element, schemaDoc, grammar);

It seems to me, that TypeAlternativeTraverser is triggered only when
version 1.1 is specified in the XSD file. How should I specify this
information in the Schema file?

Thanks for your help ...

On Wed, Dec 17, 2008 at 1:39 AM, Michael Glavassevich (JIRA)
<xe...@xml.apache.org> wrote:
>
>    [ https://issues.apache.org/jira/browse/XERCESJ-1351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12657142#action_12657142 ]
>
> Michael Glavassevich commented on XERCESJ-1351:
> -----------------------------------------------
>
> Mukul, I get different behaviour when I try your test.  The only error I'm getting is:
>
> org.xml.sax.SAXParseException: cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type 'shortString'.



-- 
Regards,
Mukul Gandhi

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org