-
1. Re: 2 root elements question
aloubyansky Jan 7, 2009 6:42 AM (in response to aloubyansky)XML schema can contain multiple top-level/root elements. The corresponding classes have to be annotated with @XmlRootElement.
The problem is at the moment JBossXBBuilder (which is a SchemaBinding producer) takes only one class (which may reference other classes annotated with @XmlRootElement).
Until support for binding a set of classes to the same SchemaBinding is supported, there could be a few workarounds/hacks:
- just introduce an artificial class (which doesn't have to have a representation in the xsd) that would reference your top-level classes;
- build separate SchemaBinding's for datasources and connection-factories and then merge them into one.
The first one should be easier. Adding support for that to JBossXBBuilder should not be a problem as well. I am not sure whether JAXB defines a standard way to do that. -
2. Re: 2 root elements question
jeff.zhang Jan 7, 2009 8:26 AM (in response to aloubyansky)Thanks Alex.
I will try 1st way.
We had looked JAXB document but not find the standard way. We will search more article on Internet. And if you have more idea, please tell me. :) -
3. Re: 2 root elements question
aloubyansky Jan 12, 2009 9:36 AM (in response to aloubyansky)Here is the issue I am going to work on this week.
https://jira.jboss.org/jira/browse/JBXB-169 -
4. Re: 2 root elements question
jeff.zhang Feb 6, 2009 4:01 AM (in response to aloubyansky)I would like use this feature. ;)
I had notice there is jbossxb-2.0.1.Beta1.jar in svn repo, is it ok if I change metadata pom.xml to use xb 2.0.1B1?
To use 2 roots, I could just follow usage of testcase, like
SchemaBinding schema = JBossXBBuilder.build(MainRootMainNs.class, YetAnotherRootMainNs.class, AnotherRootMainNs.class);
is it correct?
Thanks a lot -
-
6. Re: 2 root elements question
jeff.zhang Feb 9, 2009 8:26 AM (in response to aloubyansky)Hi Alex,
Could you give me some tip about how to use this feature in the metadata test framework?
Almost testcase use like this:
public static SchemaBindingResolver initResolver()
{
DefaultSchemaResolver resolver = new DefaultSchemaResolver();
resolver.addClassBindingForLocation("jboss-ds_5_0.xsd", ManagedConnectionFactoryDeploymentGroup.class);
return resolver;
}
And unmarshal.
I tried and another root element class into resolver, but testcase fail. I saw your change (Revision 2956) only modify JBossXBBuilder and JBossXBNoSchemaBuilder. That mean the testcase should use these XBBuilder directly? Thanks -
7. Re: 2 root elements question
aloubyansky Feb 10, 2009 8:32 AM (in response to aloubyansky)Ah, I didn't think about adding this to the resolver. You can try a workaround using the examples in the testsuite and SchemaBindingInitializer.
I'll add support for multi-class binding to the resolver. -
8. Re: 2 root elements question
jeff.zhang Feb 10, 2009 11:29 PM (in response to aloubyansky)Thanks Alex.
Please noticed me when we have multi-class binding resolver.
And do you have plan to release 1.0.0CR17 this week? -
9. Re: 2 root elements question
aloubyansky Feb 11, 2009 5:26 AM (in response to aloubyansky)Ok. Whether I release CR17 depends on whether I complete the next cleaning step. Hopefully so. Let me know if it's a blocker for you.
-
10. Re: 2 root elements question
jeff.zhang Feb 11, 2009 8:22 AM (in response to aloubyansky)Thanks
-
11. Re: 2 root elements question
aloubyansky Feb 27, 2009 5:48 AM (in response to aloubyansky)The resolver issue is https://jira.jboss.org/jira/browse/JBXB-185
It's done now. I'm gonna look into JBXB-182 and then release the XB. And after that the next metadata CR. -
12. Re: 2 root elements question
jeff.zhang Mar 1, 2009 8:35 PM (in response to aloubyansky)Cool!
So our tests initResolver() should like this: ?
public static SchemaBindingResolver initResolver()
{
MultiClassSchemaResolver resolver = new MultiClassSchemaResolver();
resolver.addClassBindingForLocation("jboss-ds_5_0.xsd", ManagedConnectionFactoryDeploymentGroup.class, ConnectionFactoryDeploymentGroup.class);
return resolver;
}
I will go those testcases done after JBXB 2.0.1 Beta 2 release. -
13. Re: 2 root elements question
aloubyansky Mar 2, 2009 7:14 AM (in response to aloubyansky)That's the idea. Metadata has been updated to use XB-2.0.1.Beta2.
-
14. Re: 2 root elements question
jeff.zhang Mar 3, 2009 2:21 AM (in response to aloubyansky)tests passed!
Thanks Alex...
I can resolved some JIRAs for metadata. ;)