Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » How to update imported schema files
How to update imported schema files [message #73411] Thu, 06 December 2007 16:28 Go to next message
Eclipse User
Originally posted by: mliu.technicacorp.com

I have a requirement to open a XSD schema file that has references to
other schemas by 'import', add my attributes to some types defined in the
imported schemas, and finally save these changed schemas. To simplify the
case, the imported schemas are assumed to be all in the local file system
and are editable. I have no problem loading the main XSD, parsing it to
locate the DOM objects that I want to add my own attributes to and update
it. Everything is going on well but I can't save the changes I made to the
definitions to the imported schemas.

As an example:

I open the main schema, A.xsd which imports B.xsd that imports C.xsd. In
C.xsd, a type is defined as:

<xsd:sequence>
<xsd:element name="description" type="xsd:string"/>
</xsd:sequence>

What I need to do is to change this definition to:
<xsd:sequence>
<xsd:element name="description" type="xsd:string" myOwnAttribute="value"/>
</xsd:sequence>

And finally save this change.

I then try to serializ the DOM of the main schema, hoping to save the
change to C.xsd.

I loaded the main schema from A.xsd which internally populated all the
type definitions from imported B.xsd and C.xsd. But when I serialize the
edited DOM object, C.xsd is not being saved with the added attributes
because C.xsd was never explicitly loaded. In fact, only schema defined in
A.xsd is saved.

When all the types are defined in one file, I have no problem saving the
changes.

Is there a way to save changes to the imported schemas?
Re: How to update imported schema files [message #73439 is a reply to message #73411] Thu, 06 December 2007 17:12 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

Mike,

When you load a schema resource into a resource set you'll notice if you
look in the resource set as a whole (i.e., resourceSet.getResources()),
there will be one resource per separate schema document. Each can be
saved separately. Given any XSDConcreteComponent (any XSD model
object), you can use xsdConcreteComponent.eResource() to determine the
resource that contains it. So you must save the C.xsd resource itself
if that's where you've made your changes.


mike wrote:
>
> I have a requirement to open a XSD schema file that has references to
> other schemas by 'import', add my attributes to some types defined in
> the imported schemas, and finally save these changed schemas. To
> simplify the case, the imported schemas are assumed to be all in the
> local file system and are editable. I have no problem loading the main
> XSD, parsing it to locate the DOM objects that I want to add my own
> attributes to and update it. Everything is going on well but I can't
> save the changes I made to the definitions to the imported schemas.
> As an example:
>
> I open the main schema, A.xsd which imports B.xsd that imports C.xsd.
> In C.xsd, a type is defined as:
>
> <xsd:sequence>
> <xsd:element name="description" type="xsd:string"/> </xsd:sequence>
>
> What I need to do is to change this definition to:
> <xsd:sequence>
> <xsd:element name="description" type="xsd:string"
> myOwnAttribute="value"/>
> </xsd:sequence>
>
> And finally save this change.
> I then try to serializ the DOM of the main schema, hoping to save the
> change to C.xsd.
>
> I loaded the main schema from A.xsd which internally populated all the
> type definitions from imported B.xsd and C.xsd. But when I serialize
> the edited DOM object, C.xsd is not being saved with the added
> attributes because C.xsd was never explicitly loaded. In fact, only
> schema defined in A.xsd is saved.
>
> When all the types are defined in one file, I have no problem saving
> the changes.
>
> Is there a way to save changes to the imported schemas?
>
>
>
>
>
>
Re: How to update imported schema files [message #73456 is a reply to message #73439] Mon, 10 December 2007 19:40 Go to previous message
Eclipse User
Originally posted by: mliu.technicacorp.com

Ed, thanks a lot for the help. All is working!
Re: How to update imported schema files [message #602739 is a reply to message #73411] Thu, 06 December 2007 17:12 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25907
Registered: July 2009
Senior Member
Mike,

When you load a schema resource into a resource set you'll notice if you
look in the resource set as a whole (i.e., resourceSet.getResources()),
there will be one resource per separate schema document. Each can be
saved separately. Given any XSDConcreteComponent (any XSD model
object), you can use xsdConcreteComponent.eResource() to determine the
resource that contains it. So you must save the C.xsd resource itself
if that's where you've made your changes.


mike wrote:
>
> I have a requirement to open a XSD schema file that has references to
> other schemas by 'import', add my attributes to some types defined in
> the imported schemas, and finally save these changed schemas. To
> simplify the case, the imported schemas are assumed to be all in the
> local file system and are editable. I have no problem loading the main
> XSD, parsing it to locate the DOM objects that I want to add my own
> attributes to and update it. Everything is going on well but I can't
> save the changes I made to the definitions to the imported schemas.
> As an example:
>
> I open the main schema, A.xsd which imports B.xsd that imports C.xsd.
> In C.xsd, a type is defined as:
>
> <xsd:sequence>
> <xsd:element name="description" type="xsd:string"/> </xsd:sequence>
>
> What I need to do is to change this definition to:
> <xsd:sequence>
> <xsd:element name="description" type="xsd:string"
> myOwnAttribute="value"/>
> </xsd:sequence>
>
> And finally save this change.
> I then try to serializ the DOM of the main schema, hoping to save the
> change to C.xsd.
>
> I loaded the main schema from A.xsd which internally populated all the
> type definitions from imported B.xsd and C.xsd. But when I serialize
> the edited DOM object, C.xsd is not being saved with the added
> attributes because C.xsd was never explicitly loaded. In fact, only
> schema defined in A.xsd is saved.
>
> When all the types are defined in one file, I have no problem saving
> the changes.
>
> Is there a way to save changes to the imported schemas?
>
>
>
>
>
>
Re: How to update imported schema files [message #602747 is a reply to message #73439] Mon, 10 December 2007 19:40 Go to previous message
mike is currently offline mike
Messages: 35
Registered: July 2009
Member
Ed, thanks a lot for the help. All is working!
Previous Topic:How to update imported schema files
Next Topic:Problem reading imported schemas with absolute path
Goto Forum:
  


Current Time: Tue Jul 22 09:39:34 EDT 2014

Powered by FUDForum. Page generated in 0.01697 seconds