users@jaxb.java.net

Exception compiling schema with empty element

From: Ellis Brover <Ellis.Brover_at_toyota.com.au>
Date: Tue, 28 Jan 2003 10:04:00 +1100

I have found that attempting to run "xjc" over a schema containing an empty
element causes an exception.

Using the schema fragment:

     <?xml version="1.0" encoding="UTF-8"?>
     <xsd:schema targetNamespace="whatever" xmlns:xsd="
http://www.w3.org/2001/XMLSchema">
          <xsd:element name="EmptyElement"/>
     </xsd:schema>

running through xjc results in:

     parsing a schema...
     Exception in thread "main" java.lang.IllegalArgumentException
             at
com.sun.xml.xsom.impl.ElementDecl.<init>(ElementDecl.java:40)
             at
com.sun.xml.xsom.impl.parser.state.elementDeclBody.makeResult(elementDeclBody.java:615)
             at
com.sun.xml.xsom.impl.parser.state.elementDeclBody.text(elementDeclBody.java:419)
             at
com.sun.xml.xsom.impl.parser.state.NGCCRuntime.processPendingText(NGCCRuntime.java:188)
             at
com.sun.xml.xsom.impl.parser.state.NGCCRuntime.endElement(NGCCRuntime.java:248)
             at org.xml.sax.helpers.XMLFilterImpl.endElement(Unknown
Source)
             at org.xml.sax.helpers.XMLFilterImpl.endElement(Unknown
Source)
             at org.xml.sax.helpers.XMLFilterImpl.endElement(Unknown
Source)
             at
org.iso_relax.verifier.impl.VerifierFilterImpl.endElement(Unknown Source)
             at
org.apache.xerces.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:585)
             at
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:222)
             at
org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(XMLNamespaceBinder.java:874)
             at
org.apache.xerces.impl.XMLNamespaceBinder.emptyElement(XMLNamespaceBinder.java:591)
             at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:747)
             at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1477)
             at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:329)
             at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:525)
             at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
             at
org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
             at
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
             at org.xml.sax.helpers.XMLFilterImpl.parse(Unknown Source)
             at org.xml.sax.helpers.XMLFilterImpl.parse(Unknown Source)
             at org.xml.sax.helpers.XMLFilterImpl.parse(Unknown Source)
             at
com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:151)
             at
com.sun.xml.xsom.impl.parser.XSOMParser.parse(XSOMParser.java:116)
             at
com.sun.tools.xjc.Driver.loadXMLSchemaGrammar(Driver.java:511)
             at com.sun.tools.xjc.Driver.loadGrammar(Driver.java:404)
             at com.sun.tools.xjc.Driver.run(Driver.java:268)
             at com.sun.tools.xjc.Driver.main(Driver.java:88)


A work-around appears to be to put an empty complexType inside the empty
element - then it compiles OK.

Regards,
Ellis.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                               DISCLAIMER
* This email and any attachment may contain confidential information.
  If you are not the intended recipient you are not authorised to copy
  or disclose all or any part of it without the prior written consent
  of Toyota.
* Opinions expressed in this email and any attachment are those of the
  sender and not necessarily the opinions of Toyota.
* Please scan this email and any attachment for viruses. Toyota does
  not accept any responsibility for problems caused by viruses, whether
  it is Toyota's fault or not.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -