You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Denis McCarthy <dm...@fexco.ie> on 2003/03/05 18:03:05 UTC

schema problem

Hi there
I'm having a problem with some schema validation rules. I want to allow one
of two sequences to
be present in an xml document (I'd prefer not to have to use sequences, but
I don't think I can use <xsd:all within an xsd:choice tag). However, the
following xsd code rule only seems to allow the FIRST sequence to be
validated correctly - when I send an xml doc with the second sequence type I
get the following SAXParseTypeException:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content
starting with element 
'ELEMENT_3' .  The content must match
'((("":ELEMENT_1),("":ELEMENT_2))|((("":ELEMENT_1){0-1},("":ELEMENT_3)),("":
ELEMENT_4)))'.
As far as I can see, the content does match this. Can anyone see a problem
with this schema?

<xsd:choice>
    <xsd:sequence>
        <xsd:element name="ELEMENT_1"        type="TYPE_1"/>
        <xsd:element name="ELEMENT_2"         type="TYPE_2"/>
    </xsd:sequence>
    <xsd:sequence>
        <xsd:element name="ELEMENT_1"       type="TYPE_1"
            minOccurs="0"/>
        <xsd:element name="ELEMENT_3"        type="TYPE_3"/>
        <xsd:element name="ELEMEMT_4"         type="TYPE_4"/>
    </xsd:sequence>
</xsd:choice>

Thanks
Denis


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
your system administrator.

This footnote also confirms that this email message has been checked for 
the presence of computer viruses.

www.fexco.com
**********************************************************************


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


Re: schema problem

Posted by Bob Schloss <rs...@us.ibm.com>.



Denis,

      Your schema contains what is known as an ambiguous content model,
because when a streaming processor found ELEMENT_1 in an instance document,
it wouldn't know if that matched the particle for the first branch of the
choice or the particle for the second branch of the choice.

      It is a good idea to check any schema you write with special tools
which do 100% checking of XML Schemas to make sure they conform to every
one of the constraints built into W3C XML Schema (many of which can't be
detected just by validating the syntax of the XML Schema documents).  One
tool (which I did some work on) is the IBM XML Schema Quality Checker.  You
can find it at http://www.alphaworks.ibm.com/tech/xmlsqc .

            Good luck,
            Bob

Bob Schloss
XML/XSL Transformational Systems
IBM T. J. Watson Research Center
Yorktown Heights, New York, USA





                                                                                                                             
                      Denis McCarthy                                                                                         
                      <dmccarthy@fexco.        To:       xerces-j-user@xml.apache.org                                        
                      ie>                      cc:                                                                           
                                               Subject:  schema problem                                                      
                      03/05/2003 12:03                                                                                       
                      PM                                                                                                     
                      Please respond to                                                                                      
                      xerces-j-user                                                                                          
                                                                                                                             




Hi there
I'm having a problem with some schema validation rules. I want to allow one
of two sequences to
be present in an xml document (I'd prefer not to have to use sequences, but
I don't think I can use <xsd:all within an xsd:choice tag). However, the
following xsd code rule only seems to allow the FIRST sequence to be
validated correctly - when I send an xml doc with the second sequence type
I
get the following SAXParseTypeException:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content
starting with element
'ELEMENT_3' .  The content must match
'((("":ELEMENT_1),("":ELEMENT_2))|((("":ELEMENT_1){0-1},("":ELEMENT_3)),("":

ELEMENT_4)))'.
As far as I can see, the content does match this. Can anyone see a problem
with this schema?

<xsd:choice>
    <xsd:sequence>
        <xsd:element name="ELEMENT_1"        type="TYPE_1"/>
        <xsd:element name="ELEMENT_2"         type="TYPE_2"/>
    </xsd:sequence>
    <xsd:sequence>
        <xsd:element name="ELEMENT_1"       type="TYPE_1"
            minOccurs="0"/>
        <xsd:element name="ELEMENT_3"        type="TYPE_3"/>
        <xsd:element name="ELEMEMT_4"         type="TYPE_4"/>
    </xsd:sequence>
</xsd:choice>

Thanks
Denis


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
your system administrator.

This footnote also confirms that this email message has been checked for
the presence of computer viruses.

www.fexco.com
**********************************************************************


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




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