Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Load XSDSchema from DOM rather than file
Load XSDSchema from DOM rather than file [message #60456] Mon, 02 May 2005 22:23 Go to next message
Eclipse UserFriend
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 22:32 Go to previous message
Eclipse UserFriend
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 22:32 Go to previous message
Gary J is currently offline Gary JFriend
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 Apr 24 22:05:30 GMT 2024

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

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

Back to the top