Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Included Schema not resolved in WSDL?
Included Schema not resolved in WSDL? [message #41662] Sun, 18 April 2004 06:46 Go to next message
Eclipse UserFriend
Originally posted by: adam.premasys.com

Hi all,

I'm wanting to use the XSD library to parse a wsdl document and gain access
to all of the defined types, both those
embedded in the wsdl document itself, and also those defined in an external
xsd document referenced by an
<include> element. When I write out the names of all of the complex type
definitions I see those defined in the main
document but not those from the external document.

I thought this could be a quirk related to parsing a wsdl document so I
rewrote my test case to use an xsd document with
an included schema and got the same result.

I've included my test case below, perhaps someone can point out where I'm
going wrong with this?

Thanks in advance,
Adam

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "wsdl",
new XSDResourceFactoryImpl());
String uri = "xml/wsdl/Party.wsdl";
ResourceSet resourceSet = new ResourceSetImpl();
XSDResourceImpl xsdSchemaResource = (XSDResourceImpl)
resourceSet.getResource(URI.createDeviceURI(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 allTypes = schema.getTypeDefinitions();
for (Iterator iter = allTypes.iterator(); iter.hasNext();) {
XSDTypeDefinition typedef = (XSDTypeDefinition) iter.next();
if (typedef instanceof XSDComplexTypeDefinition) {
String name = typedef.getName();
System.out.println(name);
}
}
}
}
Re: Included Schema not resolved in WSDL? [message #41693 is a reply to message #41662] Sun, 18 April 2004 11:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

--------------9C2BAD65159E2D4D0B53DBB2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Adam,

Two things I noticed below will cause you problems.

1. The URI of the resource you start with is not absolute, so relative
schemaLocation references within the document will fail to resolve; use
java.io.File to create an absolute or canonical path and then use
URI.createFileURI to create an absolute file schema URI.
2. The getSchema method will access only the one schema, which is fine for a
.xsd document, but a .wsdl document can contain more schemas; iterate over
the getContents of the resource to access them all.

Adam Ratcliffe wrote:

> Hi all,
>
> I'm wanting to use the XSD library to parse a wsdl document and gain access
> to all of the defined types, both those
> embedded in the wsdl document itself, and also those defined in an external
> xsd document referenced by an
> <include> element. When I write out the names of all of the complex type
> definitions I see those defined in the main
> document but not those from the external document.
>
> I thought this could be a quirk related to parsing a wsdl document so I
> rewrote my test case to use an xsd document with
> an included schema and got the same result.
>
> I've included my test case below, perhaps someone can point out where I'm
> going wrong with this?
>
> Thanks in advance,
> Adam
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "wsdl",
> new XSDResourceFactoryImpl());
> String uri = "xml/wsdl/Party.wsdl";
> ResourceSet resourceSet = new ResourceSetImpl();
> XSDResourceImpl xsdSchemaResource = (XSDResourceImpl)
> resourceSet.getResource(URI.createDeviceURI(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 allTypes = schema.getTypeDefinitions();
> for (Iterator iter = allTypes.iterator(); iter.hasNext();) {
> XSDTypeDefinition typedef = (XSDTypeDefinition) iter.next();
> if (typedef instanceof XSDComplexTypeDefinition) {
> String name = typedef.getName();
> System.out.println(name);
> }
> }
> }
> }

--------------9C2BAD65159E2D4D0B53DBB2
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Adam,
<p>Two things I noticed below will cause you problems.
<ol>
<li>
The URI of the resource you start with is not absolute, so relative schemaLocation
references within the document will fail to resolve; use java.io.File to
create an absolute or canonical path and then use URI.createFileURI to
create an absolute file schema URI.</li>

<li>
The getSchema method will access only the one schema, which is fine for
a .xsd document, but a .wsdl document can contain more schemas; iterate
over the getContents of the resource to access them all.</li>
</ol>

<p><br>Adam Ratcliffe wrote:
<blockquote TYPE=CITE>Hi all,
<p>I'm wanting to use the XSD library to parse a wsdl document and gain
access
<br>to all of the defined types, both those
<br>embedded in the wsdl document itself, and also those defined in an
external
<br>xsd document referenced by an
<br>&lt;include> element. When I write out the names of all of the complex
type
<br>definitions I see those defined in the main
<br>document but not those from the external document.
<p>I thought this could be a quirk related to parsing a wsdl document so
I
<br>rewrote my test case to use an xsd document with
<br>an included schema and got the same result.
<p>I've included my test case below, perhaps someone can point out where
I'm
<br>going wrong with this?
<p>Thanks in advance,
<br>Adam
<p> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "wsdl",
<br>new XSDResourceFactoryImpl());
<br>String uri = "xml/wsdl/Party.wsdl";
<br>ResourceSet resourceSet = new ResourceSetImpl();
<br>XSDResourceImpl xsdSchemaResource = (XSDResourceImpl)
<br>resourceSet.getResource(URI.createDeviceURI(uri), true);
<p>Iterator resources = resourceSet.getResources().iterator();
<br>while (resources.hasNext()) {
<br>&nbsp; Resource res = (Resource) resources.next();
<br>&nbsp; if (res instanceof XSDResourceImpl) {
<br>&nbsp;&nbsp;&nbsp; XSDResourceImpl xsdResource = (XSDResourceImpl)
res;
<br>&nbsp;&nbsp;&nbsp; XSDSchema schema = xsdResource.getSchema();
<p>&nbsp;&nbsp;&nbsp; List allTypes = schema.getTypeDefinitions();
<br>&nbsp;&nbsp;&nbsp; for (Iterator iter = allTypes.iterator(); iter.hasNext();)
{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XSDTypeDefinition typedef = (XSDTypeDefinition)
iter.next();
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (typedef instanceof XSDComplexTypeDefinition)
{
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; String name = typedef.getName();
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; System.out.println(name);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp; }
<br>}</blockquote>
</html>

--------------9C2BAD65159E2D4D0B53DBB2--
Re: Included Schema not resolved in WSDL? [message #41724 is a reply to message #41693] Sun, 18 April 2004 22:05 Go to previous message
Eclipse UserFriend
Originally posted by: adam.premasys.com

Hi Ed,

Thanks for putting me back on track, in addition to the 2 changes you
suggested I also needed to register a resource factory for 'xsd' documents
in addition to the factory already registered for 'wsdl' documents.

Regards,
Adam

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:4082673D.4B45E48E@ca.ibm.com...
Adam,
Two things I noticed below will cause you problems.
The URI of the resource you start with is not absolute, so relative
schemaLocation references within the document will fail to resolve; use
java.io.File to create an absolute or canonical path and then use
URI.createFileURI to create an absolute file schema URI.
The getSchema method will access only the one schema, which is fine for a
..xsd document, but a .wsdl document can contain more schemas; iterate over
the getContents of the resource to access them all.

Adam Ratcliffe wrote:
Hi all,
I'm wanting to use the XSD library to parse a wsdl document and gain access
to all of the defined types, both those
embedded in the wsdl document itself, and also those defined in an external
xsd document referenced by an
<include> element. When I write out the names of all of the complex type
definitions I see those defined in the main
document but not those from the external document.
I thought this could be a quirk related to parsing a wsdl document so I
rewrote my test case to use an xsd document with
an included schema and got the same result.
I've included my test case below, perhaps someone can point out where I'm
going wrong with this?
Thanks in advance,
Adam
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "wsdl",
new XSDResourceFactoryImpl());
String uri = "xml/wsdl/Party.wsdl";
ResourceSet resourceSet = new ResourceSetImpl();
XSDResourceImpl xsdSchemaResource = (XSDResourceImpl)
resourceSet.getResource(URI.createDeviceURI(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 allTypes = schema.getTypeDefinitions();
for (Iterator iter = allTypes.iterator(); iter.hasNext();) {
XSDTypeDefinition typedef = (XSDTypeDefinition) iter.next();
if (typedef instanceof XSDComplexTypeDefinition) {
String name = typedef.getName();
System.out.println(name);
}
}
}
}
Re: Included Schema not resolved in WSDL? [message #585758 is a reply to message #41662] Sun, 18 April 2004 11:32 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31557
Registered: July 2009
Senior Member
--------------9C2BAD65159E2D4D0B53DBB2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Adam,

Two things I noticed below will cause you problems.

1. The URI of the resource you start with is not absolute, so relative
schemaLocation references within the document will fail to resolve; use
java.io.File to create an absolute or canonical path and then use
URI.createFileURI to create an absolute file schema URI.
2. The getSchema method will access only the one schema, which is fine for a
.xsd document, but a .wsdl document can contain more schemas; iterate over
the getContents of the resource to access them all.

Adam Ratcliffe wrote:

> Hi all,
>
> I'm wanting to use the XSD library to parse a wsdl document and gain access
> to all of the defined types, both those
> embedded in the wsdl document itself, and also those defined in an external
> xsd document referenced by an
> <include> element. When I write out the names of all of the complex type
> definitions I see those defined in the main
> document but not those from the external document.
>
> I thought this could be a quirk related to parsing a wsdl document so I
> rewrote my test case to use an xsd document with
> an included schema and got the same result.
>
> I've included my test case below, perhaps someone can point out where I'm
> going wrong with this?
>
> Thanks in advance,
> Adam
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "wsdl",
> new XSDResourceFactoryImpl());
> String uri = "xml/wsdl/Party.wsdl";
> ResourceSet resourceSet = new ResourceSetImpl();
> XSDResourceImpl xsdSchemaResource = (XSDResourceImpl)
> resourceSet.getResource(URI.createDeviceURI(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 allTypes = schema.getTypeDefinitions();
> for (Iterator iter = allTypes.iterator(); iter.hasNext();) {
> XSDTypeDefinition typedef = (XSDTypeDefinition) iter.next();
> if (typedef instanceof XSDComplexTypeDefinition) {
> String name = typedef.getName();
> System.out.println(name);
> }
> }
> }
> }

--------------9C2BAD65159E2D4D0B53DBB2
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Adam,
<p>Two things I noticed below will cause you problems.
<ol>
<li>
The URI of the resource you start with is not absolute, so relative schemaLocation
references within the document will fail to resolve; use java.io.File to
create an absolute or canonical path and then use URI.createFileURI to
create an absolute file schema URI.</li>

<li>
The getSchema method will access only the one schema, which is fine for
a .xsd document, but a .wsdl document can contain more schemas; iterate
over the getContents of the resource to access them all.</li>
</ol>

<p><br>Adam Ratcliffe wrote:
<blockquote TYPE=CITE>Hi all,
<p>I'm wanting to use the XSD library to parse a wsdl document and gain
access
<br>to all of the defined types, both those
<br>embedded in the wsdl document itself, and also those defined in an
external
<br>xsd document referenced by an
<br>&lt;include> element. When I write out the names of all of the complex
type
<br>definitions I see those defined in the main
<br>document but not those from the external document.
<p>I thought this could be a quirk related to parsing a wsdl document so
I
<br>rewrote my test case to use an xsd document with
<br>an included schema and got the same result.
<p>I've included my test case below, perhaps someone can point out where
I'm
<br>going wrong with this?
<p>Thanks in advance,
<br>Adam
<p> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "wsdl",
<br>new XSDResourceFactoryImpl());
<br>String uri = "xml/wsdl/Party.wsdl";
<br>ResourceSet resourceSet = new ResourceSetImpl();
<br>XSDResourceImpl xsdSchemaResource = (XSDResourceImpl)
<br>resourceSet.getResource(URI.createDeviceURI(uri), true);
<p>Iterator resources = resourceSet.getResources().iterator();
<br>while (resources.hasNext()) {
<br>&nbsp; Resource res = (Resource) resources.next();
<br>&nbsp; if (res instanceof XSDResourceImpl) {
<br>&nbsp;&nbsp;&nbsp; XSDResourceImpl xsdResource = (XSDResourceImpl)
res;
<br>&nbsp;&nbsp;&nbsp; XSDSchema schema = xsdResource.getSchema();
<p>&nbsp;&nbsp;&nbsp; List allTypes = schema.getTypeDefinitions();
<br>&nbsp;&nbsp;&nbsp; for (Iterator iter = allTypes.iterator(); iter.hasNext();)
{
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XSDTypeDefinition typedef = (XSDTypeDefinition)
iter.next();
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (typedef instanceof XSDComplexTypeDefinition)
{
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; String name = typedef.getName();
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; System.out.println(name);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp; }
<br>}</blockquote>
</html>

--------------9C2BAD65159E2D4D0B53DBB2--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Included Schema not resolved in WSDL? [message #585774 is a reply to message #41693] Sun, 18 April 2004 22:05 Go to previous message
Adam Ratcliffe is currently offline Adam RatcliffeFriend
Messages: 3
Registered: July 2009
Junior Member
Hi Ed,

Thanks for putting me back on track, in addition to the 2 changes you
suggested I also needed to register a resource factory for 'xsd' documents
in addition to the factory already registered for 'wsdl' documents.

Regards,
Adam

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:4082673D.4B45E48E@ca.ibm.com...
Adam,
Two things I noticed below will cause you problems.
The URI of the resource you start with is not absolute, so relative
schemaLocation references within the document will fail to resolve; use
java.io.File to create an absolute or canonical path and then use
URI.createFileURI to create an absolute file schema URI.
The getSchema method will access only the one schema, which is fine for a
..xsd document, but a .wsdl document can contain more schemas; iterate over
the getContents of the resource to access them all.

Adam Ratcliffe wrote:
Hi all,
I'm wanting to use the XSD library to parse a wsdl document and gain access
to all of the defined types, both those
embedded in the wsdl document itself, and also those defined in an external
xsd document referenced by an
<include> element. When I write out the names of all of the complex type
definitions I see those defined in the main
document but not those from the external document.
I thought this could be a quirk related to parsing a wsdl document so I
rewrote my test case to use an xsd document with
an included schema and got the same result.
I've included my test case below, perhaps someone can point out where I'm
going wrong with this?
Thanks in advance,
Adam
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "wsdl",
new XSDResourceFactoryImpl());
String uri = "xml/wsdl/Party.wsdl";
ResourceSet resourceSet = new ResourceSetImpl();
XSDResourceImpl xsdSchemaResource = (XSDResourceImpl)
resourceSet.getResource(URI.createDeviceURI(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 allTypes = schema.getTypeDefinitions();
for (Iterator iter = allTypes.iterator(); iter.hasNext();) {
XSDTypeDefinition typedef = (XSDTypeDefinition) iter.next();
if (typedef instanceof XSDComplexTypeDefinition) {
String name = typedef.getName();
System.out.println(name);
}
}
}
}
Previous Topic:Included Schema not resolved in WSDL?
Next Topic:Announcement: New EMF/XSD Community Page: EMF/XSD Implementations, Solutions, Extensions
Goto Forum:
  


Current Time: Thu Oct 29 02:52:56 GMT 2020

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

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

Back to the top