Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Load XSDSchema from DOM rather than file
Load XSDSchema from DOM rather than file [message #60456] Mon, 02 May 2005 18:23 Go to next message
Eclipse User
Originally posted by: gvv_.pe.com

Hi,

I usually create an XSDSchema object from a file resource:

XSDSchema schema = xsdResource.getSchema();

where xsdResource is created from a resourceSet.

In this case all I have is a DOM Node that corresponds to the root of a
schema document that has already been parsed in.

is it possible to create an XSDSchema object using a DOM Node as input?

Thanks

Gary
Re: Load XSDSchema from DOM rather than file [message #60476 is a reply to message #60456] Mon, 02 May 2005 18:32 Go to previous message
Eclipse User
Originally posted by: gvv_.pe.com

I think I found the answer to my question by downloading a few more headers
from this newsgroup.

There's a method in XSDPrototypicalSchema that seems to do just what I want.
Here's a copy for anyone else who's looking for the same thing.

// Create a schema from an element.
public XSDSchema createSchema(org.w3c.dom.Element element)
{
// Test if the element is really a schema element.
//
if (element.getLocalName().equals("schema")
&& XSDConstants.isSchemaForSchemaNamespace(element.getNamespace URI()))
{
// Create the schema.
//
XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();

// Set the element to the schema.
// This it will build the corresponding component structure.
//
xsdSchema.setElement(element);
return xsdSchema;
}
else
{
return null;
}


"Gary J" <gvv_@pe.com> wrote in message
news:d569jm$3cr$1@news.eclipse.org...
Hi,

I usually create an XSDSchema object from a file resource:

XSDSchema schema = xsdResource.getSchema();

where xsdResource is created from a resourceSet.

In this case all I have is a DOM Node that corresponds to the root of a
schema document that has already been parsed in.

is it possible to create an XSDSchema object using a DOM Node as input?

Thanks

Gary
Re: Load XSDSchema from DOM rather than file [message #595335 is a reply to message #60456] Mon, 02 May 2005 18:32 Go to previous message
Gary J is currently offline Gary J
Messages: 61
Registered: July 2009
Member
I think I found the answer to my question by downloading a few more headers
from this newsgroup.

There's a method in XSDPrototypicalSchema that seems to do just what I want.
Here's a copy for anyone else who's looking for the same thing.

// Create a schema from an element.
public XSDSchema createSchema(org.w3c.dom.Element element)
{
// Test if the element is really a schema element.
//
if (element.getLocalName().equals("schema")
&& XSDConstants.isSchemaForSchemaNamespace(element.getNamespace URI()))
{
// Create the schema.
//
XSDSchema xsdSchema = XSDFactory.eINSTANCE.createXSDSchema();

// Set the element to the schema.
// This it will build the corresponding component structure.
//
xsdSchema.setElement(element);
return xsdSchema;
}
else
{
return null;
}


"Gary J" <gvv_@pe.com> wrote in message
news:d569jm$3cr$1@news.eclipse.org...
Hi,

I usually create an XSDSchema object from a file resource:

XSDSchema schema = xsdResource.getSchema();

where xsdResource is created from a resourceSet.

In this case all I have is a DOM Node that corresponds to the root of a
schema document that has already been parsed in.

is it possible to create an XSDSchema object using a DOM Node as input?

Thanks

Gary
Previous Topic:Load XSDSchema from DOM rather than file
Next Topic:Problems with generating list types
Goto Forum:
  


Current Time: Wed Jul 23 10:01:27 EDT 2014

Powered by FUDForum. Page generated in 0.01812 seconds