Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » extrating imported schema from WSDL file
extrating imported schema from WSDL file [message #587903] Mon, 31 May 2004 10:33
Eclipse UserFriend
Originally posted by: user.no-such-domain.com

hi Ed,

Im trying to extract the schema from http://uddi.org/wsdl/inquire_v2.wsdl
this WSDL has a schema imported from http://www.uddi.org/schema/uddi_v2.xsd
when ever I try

xsdImport.resolveTypeDefinition(xsdImport.getNamespace(),
xsdImport.getSchemaLocation());

i get an exception. i tried to have the file on local machine, and change
the path parameter accordingly but dosent seem to work. im a newbie at XSD,
i dont understand what im dong wrong.

im trying code posted on this newsgroup midified slightiy.

import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.xsd.XSDComplexTypeDefinition;
import org.eclipse.xsd.XSDImport;
import org.eclipse.xsd.XSDSchema;
import org.eclipse.xsd.XSDSchemaContent;
import org.eclipse.xsd.XSDTypeDefinition;
import org.eclipse.xsd.util.XSDResourceFactoryImpl;
import org.eclipse.xsd.util.XSDResourceImpl;

class XSDTry {
public static void main(String args[]) {

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "wsdl",
new XSDResourceFactoryImpl());
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd",
new XSDResourceFactoryImpl());
String uri = "inquire_v2.wsdl";
ResourceSet resourceSet = new ResourceSetImpl();
XSDResourceImpl xsdSchemaResource = (XSDResourceImpl)
resourceSet.getResource(URI.createFileURI(uri), true);
Iterator resources = resourceSet.getResources().iterator();
while (resources.hasNext()) {
Resource res = (Resource) resources.next();
if (res instanceof XSDResourceImpl) {
XSDResourceImpl xsdResource = (XSDResourceImpl) res;
XSDSchema schema = xsdResource.getSchema();
List schemaContents = schema.getContents();
for (Iterator i = schemaContents.iterator(); i.hasNext();) {

XSDSchemaContent content = (XSDSchemaContent) i.next();
if (content instanceof XSDImport) {
XSDImport xsdImport = (XSDImport) content;

xsdImport.resolveTypeDefinition(xsdImport.getNamespace(),
xsdImport.getSchemaLocation());
XSDResourceImpl xsr = (XSDResourceImpl)
resourceSet.getResource(URI.createURI(xsdImport.getSchemaLoc ation()),
false);
System.out.println(xsr);
}
}
List allTypes = schema.getTypeDefinitions();
for (Iterator i = allTypes.iterator(); i.hasNext();) {
XSDTypeDefinition typedef = (XSDTypeDefinition) i.next();
if (typedef instanceof XSDComplexTypeDefinition) {
String name = typedef.getName();
System.out.println(name);
}
}
}
}
}
}



i get an exception at:
xsdImport.resolveTypeDefinition(xsdImport.getNamespace(),
xsdImport.getSchemaLocation());

org.xml.sax.SAXParseException: Relative URI "XMLSchema.dtd"; can not be
resolved without a base URI.
at org.apache.crimson.parser.Parser2.fatal(Unknown Source)
at org.apache.crimson.parser.Parser2.fatal(Unknown Source)
at org.apache.crimson.parser.Parser2.resolveURI(Unknown Source)
at org.apache.crimson.parser.Parser2.maybeExternalID(Unknown Source)
[...]
at
org.eclipse.xsd.impl.XSDSchemaImpl.resolveTypeDefinition(XSD SchemaImpl.java:
2109)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.resolveTypeDef inition(XSDConcr
eteComponentImpl.java:2291)
at XSDTry.main(temp2.java:37)


i also get an exception at:
Resource res = (Resource) resources.next();
in the second iteration....of the while loop

java.util.ConcurrentModificationException
at
org.eclipse.emf.common.util.BasicEList$EIterator.checkModCou nt(BasicEList.ja
va:1226)
at
org.eclipse.emf.common.util.BasicEList$EIterator.next(BasicE List.java:1173)
at XSDTry.main(temp2.java:27)
Exception in thread "main"



what could be wrong?
TIA.

Regards,
PS
Previous Topic:xsd plugin directory structure
Next Topic:extrating imported schema from WSDL file
Goto Forum:
  


Current Time: Fri Apr 19 22:52:23 GMT 2024

Powered by FUDForum. Page generated in 0.03056 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top