[jboss-jira] [JBoss JIRA] Commented: (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
Fri Feb 20 10:57:44 EST 2009


    [ https://jira.jboss.org/jira/browse/JBXB-182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12453517#action_12453517 ] 

Matt Wringe commented on JBXB-182:
----------------------------------

Ok, I am going to attach a file that contains a very simple test case for this situation. This is a very simple test and doesn't even include a metadata class for the xml file.

The tar.gz contains a simple file that sets up an unmarshaller and tried to unmarshall an xml file (test.test.App) as well as a simple xml (test.xml) file and a simple xsd file (test.xsd).

Its setup as a maven project, so all you need to do to build and run the application is:
mvn package exec:java -Dexec.mainClass="test.test.App"

The way the project is setup right now it will fail, to make it run without failing either uncomment the <foo> option or remove <bar> in test.xml.

StackTrace:

org.jboss.xb.binding.JBossXBException: Failed to parse source: Requested element {file:///tmp/test.xsd}bar is not allowed in this position in the sequence. The next element should be {file:///tmp/test.xsd}foo
        at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:203)
        at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:183)
        at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:161)
        at test.test.App.main(App.java:35)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:283)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Requested element {file:///tmp/test.xsd}bar is not allowed in this position in the sequence. The next element should be {file:///tmp/test.xsd}foo
        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.ModelGroupBinding$Cursor.startElement(ModelGroupBinding.java:185)
        at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:397)
        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)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:199)
        ... 9 more




> 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
>            Assignee: Alexey Loubyansky
>             Fix For: JBossXB-2.0.1.Beta2
>
>         Attachments: test-schema.tar.gz
>
>
> 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