6 Replies Latest reply on Jun 4, 2009 12:15 AM by jeff.zhang

    about JBMETA 198/199

    jeff.zhang

       


      > > The problem is there is no way to specify the namespace for the root
      > > element. So, this approach (hack in fact) will only work for DTDs and
      > > schemas with default namespace. Which is not your case.
      > > You can continue hacking by wrapping your metadata classes (I think just
      > > wrapping the root class will be sufficient) and bind these wrappers to
      > > the default namespace and then use that in the -beans.xml binding file.


      1. extend the JCA15MetaData and JBossRAMetaData classes and create 2 wrap classes. in which I define the namespace in the class by using annotation @JBossXmlSchema, is it correct?

      2. define SchemaConfig that binding xsd file and metadata class, like
      <entry>
      <key>connector_1_5.xsd</key>
      <value>org.jboss.metadata.rar.spec.JCA15MetaData</value>
      </entry>
      

      In metadata project, we don't import MC project, so I can add this bind into MetaDataSchemaResolverFactory class like:
      resolver.mapLocationToClass("connector_1_5.xsd", JCA15MetaData.class);
      

      but the map key "connector_1_5.xsd" is used, how could I bind xsd file into new wrap class?

      thanks a lot

        • 1. Re: about JBMETA 198/199
          aloubyansky

           

          1. extend the JCA15MetaData and JBossRAMetaData classes and create 2 wrap classes. in which I define the namespace in the class by using annotation @JBossXmlSchema, is it correct?


          Yes.

          For the binding, your intent is to bind to an XML w/o schema information. So, you just need to specify the root element name in the key.

          • 2. Re: about JBMETA 198/199
            jeff.zhang

            I still meet parser issue for default namespace, the JCA15DefaultNSMetadata class has annotation like this.

            @XmlRootElement(name="connector", namespace=JavaEEMetaDataConstants.JAVAEE_NS)
            @JBossXmlSchema(
             xmlns={@XmlNs(namespaceURI = JavaEEMetaDataConstants.JAVAEE_NS},
             ignoreUnresolvedFieldOrClass=true,
             namespace=JavaEEMetaDataConstants.JAVAEE_NS,
             elementFormDefault=XmlNsForm.QUALIFIED,
             normalizeSpace=true,
             strict=false)
            


            I don't know where I can add xsd definition in the JBossXmlSchema annotation.
            Thanks.

            • 3. Re: about JBMETA 198/199
              aloubyansky

              The namespace should be "" or not used at all.

              • 4. Re: about JBMETA 198/199
                jeff.zhang

                I still meet problem about default namespace parser. The test can't pass when it parser xml file like

                <connector>
                 <vendor-name>Red Hat Middleware LLC</vendor-name>
                 <eis-type>JMS 1.1 Server</eis-type>
                 <resourceadapter-version>6.0</resourceadapter-version>
                 <resourceadapter>
                 </resourceadapter>
                </connector>
                


                I had commit some minimal codes about this test (r89720), currently I ignore the test ignoretestDefaultNS in RA16EverythingUnitTestCase

                could you help me to check what is wrong and give me some point about this?
                Thanks a lot

                • 5. Re: about JBMETA 198/199
                  aloubyansky

                  So, what's not clear about the error?

                  The error is "Failed to resolve schema nsURI= location=connector".
                  Which comes from resolver.
                  Which means "connector" has not been mapped to any class.

                  + public static SchemaBindingResolver initResolver()
                  + {
                  + MutableSchemaResolver resolver = MetaDataSchemaResolverFactory.createSchemaResolver();
                  + resolver.mapLocationToClass("connector", JCA16DefaultNSMetaData.class);
                  + return resolver;
                  + }


                  • 6. Re: about JBMETA 198/199
                    jeff.zhang

                    OK, got it. Thanks for youe help :)