Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » How to update imported schema files
How to update imported schema files [message #73411] Thu, 06 December 2007 21:28 Go to next message
Eclipse UserFriend
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 22:12 Go to previous messageGo to next message
Eclipse UserFriend
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] Tue, 11 December 2007 00:40 Go to previous message
Eclipse UserFriend
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 22:12 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
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?
>
>
>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to update imported schema files [message #602747 is a reply to message #73439] Tue, 11 December 2007 00:40 Go to previous message
mike is currently offline mikeFriend
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: Thu Apr 18 02:53:54 GMT 2024

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

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

Back to the top