users@jaxb.java.net

validating a minOccurs="0" does not seem to work

From: Steve Maring <steve.s.maring_at_us.pwc.com>
Date: Tue, 08 Jul 2003 14:28:44 -0400

I'm using JAXB from JWSDP-1.2

When I try to validate an XML document with:

unmarshaller.setValidating( true );

I get exceptions on the lack of certain elements in the document that the
schema declares to have a minOccurs="0".

    [junit] DefaultValidationEventHandler: [ERROR]: uncompleted content
model. expecting: <ASSIGNED_OFFICE_CODE>,
...
    [junit] at com.sun.msv.verifier.Verifier.onError(Verifier.java:331)
    [junit] at com.sun.msv.verifier.Verifier.onError(Verifier.java:327)
    [junit] at
com.sun.msv.verifier.Verifier.endElement(Verifier.java:289)
    [junit] at
com.sun.msv.verifier.VerifierFilter.endElement(VerifierFilter.java:102)
    [junit] at
org.iso_relax.verifier.impl.ForkContentHandler.endElement(Unknown Source)
    [junit] at
org.apache.xerces.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:546)
    [junit] at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:533)
    [junit] at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentSca
nnerImpl.java:1535)
    [junit] at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:348)
    [junit] at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:539)
    [junit] at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:595)
    [junit] at
org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
    [junit] at
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1125)
    [junit] at
com.pwc.us.mw.common.dto.impl.runtime.UnmarshallerImpl.unmarshal(Unknown
Source)
    [junit] at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:131)


This is the relavent section from my schema:

...
<xsd:complexType name="PersonDetailType">
  <xsd:all>
    <xsd:element name="ASSIGNED_OFFICE_CODE" type="xsd:string" minOccurs=
"0" maxOccurs="1"/>
...


I'm I doing something wrong here?

Cheers.
Steve Maring

_________________________________________________________________
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from any
computer.