1 2 3 4 Previous Next 52 Replies Latest reply on Mar 25, 2008 10:03 AM by kabirkhan Go to original post
      • 45. Re: Implementing JAXB style parsing for aop-mc-int
        kabirkhan

        Cool,

        Now that the xsd:redefine issue has been resolved, this all seems to work a lot better!

        • 46. Re: Implementing JAXB style parsing for aop-mc-int
          kabirkhan

          I've got the JAXB parsing to almost the same level as for the old AOPBeanSchemaInitializer method, and will now work on adding the rest of the features. Locally I build and install snapshots of common-core and jbossxb, and use those.

          I did notice however when using the AOPBeanSchemaInitializer again by accident that the https://svn.jboss.org/repos/jbossas/projects/microcontainer/branches/jaxb-aop-mc-int/aop-mc-int/src/resources/main/schema/aop-beans_1_0.xsd does not parse properly. If I use the AOPBeanSchemaInitializer I get exceptions like:

          org.jboss.xb.binding.JBossXBException: Failed to parse source: file:/C:/cygwin/home/Kabir/sourcecontrol/microcontainer-jaxb-aop-mc-int/aop-mc-int/target/tests-classes/org/jboss/test/microcontainer/beans/test/CFlowAopTestCase.xml@3,38
           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:177)
           at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:139)
           at org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer.deploy(BasicXMLDeployer.java:147)
           at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.deploy(MicrocontainerTestDelegate.java:294)
           at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.deploy(MicrocontainerTestDelegate.java:438)
           at org.jboss.test.aop.junit.AOPMicrocontainerTestDelegate.deploy(AOPMicrocontainerTestDelegate.java:76)
           at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.setUp(MicrocontainerTestDelegate.java:83)
           at org.jboss.test.aop.junit.AOPMicrocontainerTestDelegate.setUp(AOPMicrocontainerTestDelegate.java:60)
           at org.jboss.test.AbstractTestSetup.setUp(AbstractTestSetup.java:63)
           at junit.extensions.TestSetup$1.protect(TestSetup.java:18)
           at junit.framework.TestResult.runProtected(TestResult.java:124)
           at junit.extensions.TestSetup.run(TestSetup.java:23)
           at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
           at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
           at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
           at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
           at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
           at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
          Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Failed to parse schema for nsURI=urn:jboss:aop-beans:1.0, baseURI=null, schemaLocation=aop
           at org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver.resolve(DefaultSchemaResolver.java:338)
           at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:302)
           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:407)
           at org.apache.xerces.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:496)
           at org.apache.xerces.xinclude.XIncludeHandler.startElement(XIncludeHandler.java:938)
           at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:283)
           at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:733)
           at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1754)
           at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:324)
           at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:845)
           at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:768)
           at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:108)
           at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1127)
           at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:567)
           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:173)
           ... 17 more
          Caused by: org.jboss.xb.binding.JBossXBRuntimeException: -1:-1 124:37 s4s-elt-must-match.2: The content of 'group (global)' must match (annotation?, (all | choice | sequence)). Not enough elements were found.
           at org.jboss.xb.binding.sunday.unmarshalling.XsdBinderTerminatingErrorHandler.handleError(XsdBinderTerminatingErrorHandler.java:40)
           at org.apache.xerces.impl.xs.XMLSchemaLoader.reportDOMFatalError(XMLSchemaLoader.java:1124)
           at org.apache.xerces.impl.xs.XSLoaderImpl.load(XSLoaderImpl.java:175)
           at org.jboss.xb.binding.Util.loadSchema(Util.java:395)
           at org.jboss.xb.binding.sunday.unmarshalling.XsdBinder.bind(XsdBinder.java:175)
           at org.jboss.xb.binding.sunday.unmarshalling.XsdBinder.bind(XsdBinder.java:146)
           at org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver.resolve(DefaultSchemaResolver.java:330)
           ... 31 more
          


          Does anybody know what this means :-)

          And is there an easier way to turn on validation of the schema than hacking it to use the AOPBeanSchemaInitializer in SingletonSchemaResolverFactory? I've tried calling org.jboss.xb.binding.Unmarshaller.setValidation() and org.jboss.xb.binding.Unmarshaller.setSchemaValidation() but they don't seem to have any effect.





          • 47. Re: Implementing JAXB style parsing for aop-mc-int
            kabirkhan

            I edited my previous post to describe better what I was doing

            • 48. Re: Implementing JAXB style parsing for aop-mc-int
              aloubyansky

              I guess, it should be

              <xsd:group ref="..."/>

              instead of
              <xsd:group name="..."/>


              That's what makes the difference between the group definition and a reference to it.

              • 49. Re: Implementing JAXB style parsing for aop-mc-int
                aloubyansky

                About validation, this error should be seen every time you run the test if the XsdBinder is used to load the schema. There is not config option that would turn it on or off. Unmarshaller's options are for validation during XML parsing in the JAXB parser layer. And this error is coming from XsdBinder, the XB SchemaBinding resolution layer.

                • 50. Re: Implementing JAXB style parsing for aop-mc-int
                  kabirkhan

                   

                  "alex.loubyansky@jboss.com" wrote:
                  I guess, it should be
                  <xsd:group ref="..."/>

                  instead of
                  <xsd:group name="..."/>


                  That's what makes the difference between the group definition and a reference to it.


                  The only group defined is valueGroup. In the aop beans schema I do:
                   <xsd:redefine schemaLocation="jboss-beans-common_2_0.xsd">
                   ...
                   <xsd:group name="valueGroup"/>
                   ...
                   </xsd:redefine>
                  


                  in the jboss-beans-common schema, the group is defined
                   <xsd:group name="valueGroup">
                   <xsd:annotation>
                   <xsd:documentation>
                  ...
                   </xsd:documentation>
                   </xsd:annotation>
                   <xsd:choice>
                   <!--<xsd:element name="bean" type="beanType"/>-->
                   <!--<xsd:element name="lazy" type="lazyType"/>-->
                   <xsd:element name="value" type="plainValueType"/>
                   <xsd:element name="inject" type="injectionType"/>
                   <xsd:element name="value-factory" type="valueFactoryType"/>
                   <xsd:element name="collection" type="collectionType"/>
                   <xsd:element name="list" type="listType"/>
                   <xsd:element name="set" type="setType"/>
                   <xsd:element name="array" type="arrayType"/>
                   <xsd:element name="map" type="mapType"/>
                   <xsd:element name="null">
                   <xsd:complexType/>
                   </xsd:element>
                   <xsd:element name="this">
                   <xsd:complexType/>
                   </xsd:element>
                   <xsd:any namespace="##other" processContents="strict">
                   <xsd:annotation>
                   <xsd:documentation>An extension value</xsd:documentation>
                   </xsd:annotation>
                   </xsd:any>
                   </xsd:choice>
                   </xsd:group>
                  


                  Then everywhere it is used it uses 'ref', e.g.
                   <xsd:complexType name="valueType" mixed="true">
                   <xsd:annotation>
                   <xsd:documentation>
                   <![CDATA[
                   A value that can take other values, i.e. properties and parameters.
                  
                   e.g.
                   <parameter><value class="com.acme.MyClass">xxx</value></parameter>
                   ]]>
                   </xsd:documentation>
                   </xsd:annotation>
                   <xsd:complexContent>
                   <xsd:extension base="plainValueType">
                   <xsd:sequence>
                   <xsd:choice minOccurs="0">
                   <xsd:group ref="valueGroup"/>
                   </xsd:choice>
                   </xsd:sequence>
                   </xsd:extension>
                   </xsd:complexContent>
                   </xsd:complexType>
                  


                  There isn't any group called "global"?

                  • 51. Re: Implementing JAXB style parsing for aop-mc-int
                    aloubyansky

                    Right, this is not valid

                    <xsd:group name="valueGroup"/>


                    This is not the definition since it's missing the content. And to be a reference it must have ref instead of name. The error message actually gives you the line number of the error.
                    global should be a hint to the scope of the group in the xsd.

                    • 52. Re: Implementing JAXB style parsing for aop-mc-int
                      kabirkhan

                      This works better

                       <xsd:redefine schemaLocation="jboss-beans-common_2_0.xsd">
                      ...
                       <xsd:group name="valueGroup">
                       <xsd:choice>
                       <xsd:element name="value" type="plainValueType"/>
                       <xsd:element name="inject" type="injectionType"/>
                       <xsd:element name="value-factory" type="valueFactoryType"/>
                       <xsd:element name="collection" type="collectionType"/>
                       <xsd:element name="list" type="listType"/>
                       <xsd:element name="set" type="setType"/>
                       <xsd:element name="array" type="arrayType"/>
                       <xsd:element name="map" type="mapType"/>
                       <xsd:element name="null">
                       <xsd:complexType/>
                       </xsd:element>
                       <xsd:element name="this">
                       <xsd:complexType/>
                       </xsd:element>
                       <xsd:any namespace="##other" processContents="strict">
                       <xsd:annotation>
                       <xsd:documentation>An extension value</xsd:documentation>
                       </xsd:annotation>
                       </xsd:any>
                       </xsd:choice>
                       </xsd:group>
                      ...
                       </xsd:redefine>
                      


                      1 2 3 4 Previous Next