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 <[email protected]>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) > <[email protected]> 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: [email protected] > For additional commands, e-mail: [email protected] > >
