[jboss-jira] [JBoss JIRA] Created: (JBXB-182) Parse error if a choice is between an element and a sequence which also contains the element

Matt Wringe (JIRA) jira-events at lists.jboss.org
Thu Feb 19 15:19:45 EST 2009


Parse error if a choice is between an element and a sequence which also contains the element
--------------------------------------------------------------------------------------------

                 Key: JBXB-182
                 URL: https://jira.jboss.org/jira/browse/JBXB-182
             Project: JBoss XML Binding (JBossXB)
          Issue Type: Bug
         Environment: JBoss AS5, JBossXB 2.0.0.GA
            Reporter: Matt Wringe


JBossXB fails to parse an xml file if the xsd contains a choice between an element and a sequence which also contains the element.

For example, in the follow the choice should allow the option between specifying A and then B, or just B

                        <choice>
                                <sequence>
                                        <element name="A"/>
                                        <element name="B"/>
                                </sequence>
                                <element name="B"/>
                        </choice>

But, if an xml file used contains just B, an exception will be thrown saying that B is in the wrong order for the sequence. The expected result would be that it should work since just having B is valid.

Part of the actual xsd file (http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd) in question:

                        <choice>
                                <sequence>
                                        <element name="resource-bundle" type="portlet:resource-bundleType"/>
                                        <element name="portlet-info" type="portlet:portlet-infoType" minOccurs="0"/>
                                </sequence>
                                <element name="portlet-info" type="portlet:portlet-infoType"/>
                        </choice>

Part of the stacktrace thrown when a portlet-info element is declared in an portlet.xml file without resource-bundle:

Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Requested element {http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd}portlet-info is not allowed in this position in the sequence. The next element should be {http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd}resource-bundle
        at org.jboss.xb.binding.sunday.unmarshalling.SequenceBinding$1.startElement(SequenceBinding.java:226)
        at org.jboss.xb.binding.sunday.unmarshalling.ChoiceBinding$1.startElement(ChoiceBinding.java:230)
        at org.jboss.xb.binding.sunday.unmarshalling.SequenceBinding$1.startElement(SequenceBinding.java:254)
        at org.jboss.xb.binding.sunday.unmarshalling.ModelGroupBinding$Cursor.startElement(ModelGroupBinding.java:185)
        at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:451)
        at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:401)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
        at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)

Note: when using other tools, the xsd file validates as a proper xsd file, and the xml file used properly validates against the specified xsd.

More information (stacktraces, actual files used, etc...) is available upon requested.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list