hi all, currently I involve in development of codegen module in axis2. there we use the xmlbeans as one of the databinding framwork. we have a problem when generating the databind classes for wsdl files having multiple imports for same .xsd file. ( see the attached test.wsdl file). i.e for an example the message.xsd fies is imported both in test.wsdl and runTest.xsd file.
from axis2 we call the XmlBeans.compileXmlBeans method to genereate the databind classes for codegen module. An Xmlbeans object with an EntityResolver and a Filer object is passed to above method to resolve schemas and write java classes. Following is a sample code it wrote to demostrate the problem public void compile() { //first get the Xmlschema Object try { WSDLReader wsdlReader = WSDLFactory.newInstance ().newWSDLReader(); Definition wsdlDefinition = wsdlReader.readWSDL("test.wsdl"); //schema list for that wsdl List schemaList = wsdlDefinition.getTypes ().getExtensibilityElements(); // conver to xmlobject list List xmlObjectList = new ArrayList(); XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection(); Schema schema; XmlSchema xmlSchema; for (Iterator iter = schemaList.iterator(); iter.hasNext();) { schema = (Schema) iter.next(); xmlSchema = xmlSchemaCollection.read(schema.getElement(), null); xmlObjectList.add(XmlObject.Factory.parse (getSchemaAsString(xmlSchema))); } XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setEntityResolver(new TestEntityResolver()); // compile the schema list using the xmlbeans class XmlObject[] xmlObjectArray = (XmlObject[]) xmlObjectList.toArray(new XmlObject[xmlObjectList.size()]); XmlBeans.compileXmlBeans( null, null, xmlObjectArray, null, XmlBeans.typeLoaderForClassLoader( SchemaDocument.class.getClassLoader()), new TestFiler(), xmlOptions); System.out.println("OK"); } catch (Exception e) { e.printStackTrace(); } } private static String getSchemaAsString(XmlSchema schema) throws IOException { StringWriter writer = new StringWriter(); schema.write(writer); return writer.toString(); } As it can be seen in the above code we create an wsdl definition Object using wsdl4j and parses the list of schemas as shown. Here is the stackrace. org.apache.xmlbeans.XmlException: project://local/message.xsd:12:5: error: sch-props-correct.2: Duplicate global type: MessageContext_Type@ http://service.foobar.com/entity/message/ (Original global type found in file: message.xsd) at org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler.compile( SchemaTypeSystemCompiler.java:225) 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:585) at org.apache.xmlbeans.XmlBeans.compileXmlBeans(XmlBeans.java:667) at test.com.xmlbeans.TestXmlBeans.compile(TestXmlBeans.java:67) at test.com.xmlbeans.TestXmlBeans.main(TestXmlBeans.java:89) 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:585) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86) further I noticed that the systemId (passed in resolveEntity(String publicId, String systemId) method) is different for the same xsd file when it imports from the wsdl file and the xsd file (see the testEntityResolver.java file). For an example the systemID for the message.xsd file import from the wsdl file is message.xsd and for runtTest.xsd is project://local/message.xsd. however by using the *scomp* command comes with the xmlbeans it is possible to generate the code for test.wsdl without any problem. Can some one please help me to figureout the problem? -- Amila Suriarachchi, WSO2 Inc.
xmlbeans.tar
Description: Unix tar archive
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]