You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by "Sherman, Dennis (END-CHI)" <de...@endinfosys.com> on 2005/09/06 16:29:17 UTC

validation issues - more elements than maxOccurs

I'm using XMLBeans 2.0.0 to create schema documents for Google Scholar
(http://scholar.google.com/scholar/libraries.html for full information,
http://scholar.google.com/scholar/institutional_links.xml and
http://scholar.google.com/scholar/institutional_holdings.xml for relevant
schema)

I'm having trouble getting validation to tell me the actual error.  (I know
the real cause, 'cause I'm working in a TDD style, and making sure to cause
all the errors before I use the schema with real data.)

Google doesn't provide an XSD file, so I'm writing my own.  The relevant
fragment for my current question is:

    <xs:element name="institutional_links">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="institution"/>
                <xs:element ref="keywords" minOccurs="0"
maxOccurs="unbounded"/>
                <xs:element ref="contact" minOccurs="0" maxOccurs="5"/>
                <xs:element ref="electronic_link_label"/>
                <xs:element ref="other_link_label"/>
                <xs:element ref="openurl_base"/>
                <xs:element ref="openurl_option" maxOccurs="unbounded"/>
                <xs:element ref="patron_ip_range" minOccurs="0"
maxOccurs="unbounded"/>
                <xs:element ref="patron_ip_required" minOccurs="0"/>
                <xs:element name="electronic_holdings"
type="electronic_holdingsType" maxOccurs="1000"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

When I add 6 contacts to an otherwise valid document, validation fails, as
expected.  What isn't expected is the error message: 
error.getMessage(): Expected element
'electronic_link_label@http://scholar.google.com' instead of
'contact@http://scholar.google.com' here in element
institutional_links@http://scholar.google.com

I understand why it is giving me that message, and it isn't the _wrong_
message, exactly... but I'd much prefer that it tell me something more along
the line of "number of contacts is greater than maxOccurs".

So the questions:

1) is it possible to set an XmlOption or something to get my preferred error
message?
2) if #1 isn't possible, how can I get the maxOccurs value for contacts
programmatically, so I can do this validation myself without having to
"know" that 5 is my magic number?

Thanks.

--
Dennis R. Sherman


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