Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Moving components from one XSD schema to another
Moving components from one XSD schema to another [message #25573] Thu, 31 July 2003 09:48 Go to next message
Hayden Marchant is currently offline Hayden MarchantFriend
Messages: 90
Registered: July 2009
Member
I need to take a pre-existing XSD, and prune off lots of bits and pieces
that are not relevant for a certain flavor of XML that needs to be
validated. The reason this needs to be done is that the sheer size of the
original XSD (>800kb) makes it unfeasible to validate against.

I have already figured out how to remove parts of a schema (using
ECoreUtil.remove() ), however I am not sure how to re-write the changed
schema back to a file. The re-write I need to do is a bit different to a
plain old write. If the schema I am working on includes/imports another
schema, I also need to write the updated reference schema.

I would very much like to be able to merge the references schemas into a
single smaller main schema. I need to be able to tell all of the
XSDConcreteComponents that they know belong to a different schema, without
breaking the references to them. I also need to update the underlying DOM
representation of these refered schemas.

How do I go about this merging task? What methods do I need to call on
these referred components?

Thanks,
Hayden Marchant
Re: Moving components from one XSD schema to another [message #25612 is a reply to message #25573] Thu, 31 July 2003 11:53 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Hayden,

Given any EObject "x" contained by a resource, (that includes any
XSDConcreteComponent), you can save it back to it's original location like
this

Resource resource = x.eResource();
resource.save(null);

or you can save it to a stream like this

resource.save(System.out, null);

If you want to save your whole set of related schemas to a new location, you
can call resource.setURI() for each resource to change it's location. You'll
also need to change the import/includes to use the new names.

You can only merge included schemas into a single schema since imports imply a
different namespace and each different target namespace will require a
different schema document to be defined. If you want something to be
contained by a particular schema you would add it to the list returned by
xsdSchema.getContents(); adding it to a new container will remove it from its
old container automatically.


Hayden Marchant wrote:

> I need to take a pre-existing XSD, and prune off lots of bits and pieces
> that are not relevant for a certain flavor of XML that needs to be
> validated. The reason this needs to be done is that the sheer size of the
> original XSD (>800kb) makes it unfeasible to validate against.
>
> I have already figured out how to remove parts of a schema (using
> ECoreUtil.remove() ), however I am not sure how to re-write the changed
> schema back to a file. The re-write I need to do is a bit different to a
> plain old write. If the schema I am working on includes/imports another
> schema, I also need to write the updated reference schema.
>
> I would very much like to be able to merge the references schemas into a
> single smaller main schema. I need to be able to tell all of the
> XSDConcreteComponents that they know belong to a different schema, without
> breaking the references to them. I also need to update the underlying DOM
> representation of these refered schemas.
>
> How do I go about this merging task? What methods do I need to call on
> these referred components?
>
> Thanks,
> Hayden Marchant
Re: Moving components from one XSD schema to another [message #575061 is a reply to message #25573] Thu, 31 July 2003 11:53 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Hayden,

Given any EObject "x" contained by a resource, (that includes any
XSDConcreteComponent), you can save it back to it's original location like
this

Resource resource = x.eResource();
resource.save(null);

or you can save it to a stream like this

resource.save(System.out, null);

If you want to save your whole set of related schemas to a new location, you
can call resource.setURI() for each resource to change it's location. You'll
also need to change the import/includes to use the new names.

You can only merge included schemas into a single schema since imports imply a
different namespace and each different target namespace will require a
different schema document to be defined. If you want something to be
contained by a particular schema you would add it to the list returned by
xsdSchema.getContents(); adding it to a new container will remove it from its
old container automatically.


Hayden Marchant wrote:

> I need to take a pre-existing XSD, and prune off lots of bits and pieces
> that are not relevant for a certain flavor of XML that needs to be
> validated. The reason this needs to be done is that the sheer size of the
> original XSD (>800kb) makes it unfeasible to validate against.
>
> I have already figured out how to remove parts of a schema (using
> ECoreUtil.remove() ), however I am not sure how to re-write the changed
> schema back to a file. The re-write I need to do is a bit different to a
> plain old write. If the schema I am working on includes/imports another
> schema, I also need to write the updated reference schema.
>
> I would very much like to be able to merge the references schemas into a
> single smaller main schema. I need to be able to tell all of the
> XSDConcreteComponents that they know belong to a different schema, without
> breaking the references to them. I also need to update the underlying DOM
> representation of these refered schemas.
>
> How do I go about this merging task? What methods do I need to call on
> these referred components?
>
> Thanks,
> Hayden Marchant


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Moving components from one XSD schema to another
Next Topic:Generating Java Classes from XSD
Goto Forum:
  


Current Time: Fri Apr 19 22:46:00 GMT 2024

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

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

Back to the top