Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » extrating imported schema from WSDL file
extrating imported schema from WSDL file [message #46527] Mon, 31 May 2004 10:33 Go to next message
Eclipse User
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
Re: extrating imported schema from WSDL file [message #46555 is a reply to message #46527] Mon, 31 May 2004 11:23 Go to previous message
Eclipse User
Originally posted by: merks.ca.ibm.com

PS,

This looks like a completely bogus use of resolveTypeDefinition which takes a
name and a namespace of a type and tries to resolve it, but you've passed it a
namespace of a schema, and a schema location, so I'm not sure what you are
expecting it to do? It sounds like maybe you just need to use
XSDSchemaDirective.getResolveSchema on the XSDImport to navigate to the imported
schema.


PS wrote:

> 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
Re: extrating imported schema from WSDL file [message #587915 is a reply to message #46527] Mon, 31 May 2004 11:23 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26037
Registered: July 2009
Senior Member
PS,

This looks like a completely bogus use of resolveTypeDefinition which takes a
name and a namespace of a type and tries to resolve it, but you've passed it a
namespace of a schema, and a schema location, so I'm not sure what you are
expecting it to do? It sounds like maybe you just need to use
XSDSchemaDirective.getResolveSchema on the XSDImport to navigate to the imported
schema.


PS wrote:

> 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:extrating imported schema from WSDL file
Next Topic:Building Editor for
Goto Forum:
  


Current Time: Mon Sep 15 04:22:29 GMT 2014

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

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