Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » copy xsd type definition from one schema to another
copy xsd type definition from one schema to another [message #77145] Wed, 18 February 2009 17:08 Go to next message
Eclipse UserFriend
Originally posted by: jacek.pospychala.pl.ibm.com

hi,
I'm trying to copy a XSDTypeDefinition from one schema to another with
following code:

XSDSchema dstSchema = // destination schema
XSDSchema srcSchema = // source schema

XSDTypeDefinition srcType = srcSchema.getTypeDefinitions().get(0);

// 1. copy schema element
XSDTypeDefinition dstType = (XSDTypeDefinition)
srcType.cloneConcreteComponent(true, true);

// 2. copy DOM element
Element dstElement = (Element)
dstSchema.getDocument().importNode(newType.getElement(), true);
dstType.setElement(dstElement);

// 3. put copied element to new schema
srcSchema.getContents().add(dstType);



But this way I seem to loose sync between schema model and DOM model of
copied XSDTypeDefinition.
When I do only 1., then some DOM elements are missing.

What's the correct way to do the copy?


THanks in advance!

Jacek
Re: copy xsd type definition from one schema to another [message #77192 is a reply to message #77145] Thu, 19 February 2009 09:16 Go to previous message
Eclipse UserFriend
Originally posted by: jacek.pospychala.pl.ibm.com

ok, I see earlier topic "How to clone annotations".

Jacek Pospychala pisze:
> hi,
> I'm trying to copy a XSDTypeDefinition from one schema to another with
> following code:
>
> XSDSchema dstSchema = // destination schema
> XSDSchema srcSchema = // source schema
>
> XSDTypeDefinition srcType = srcSchema.getTypeDefinitions().get(0);
>
> // 1. copy schema element
> XSDTypeDefinition dstType = (XSDTypeDefinition)
> srcType.cloneConcreteComponent(true, true);
>
> // 2. copy DOM element
> Element dstElement = (Element)
> dstSchema.getDocument().importNode(newType.getElement(), true);
> dstType.setElement(dstElement);
>
> // 3. put copied element to new schema
> srcSchema.getContents().add(dstType);
>
>
>
> But this way I seem to loose sync between schema model and DOM model of
> copied XSDTypeDefinition.
> When I do only 1., then some DOM elements are missing.
>
> What's the correct way to do the copy?
>
>
> THanks in advance!
>
> Jacek
Re: copy xsd type definition from one schema to another [message #604036 is a reply to message #77145] Thu, 19 February 2009 09:16 Go to previous message
Jacek Pospychala is currently offline Jacek PospychalaFriend
Messages: 159
Registered: July 2009
Senior Member
ok, I see earlier topic "How to clone annotations".

Jacek Pospychala pisze:
> hi,
> I'm trying to copy a XSDTypeDefinition from one schema to another with
> following code:
>
> XSDSchema dstSchema = // destination schema
> XSDSchema srcSchema = // source schema
>
> XSDTypeDefinition srcType = srcSchema.getTypeDefinitions().get(0);
>
> // 1. copy schema element
> XSDTypeDefinition dstType = (XSDTypeDefinition)
> srcType.cloneConcreteComponent(true, true);
>
> // 2. copy DOM element
> Element dstElement = (Element)
> dstSchema.getDocument().importNode(newType.getElement(), true);
> dstType.setElement(dstElement);
>
> // 3. put copied element to new schema
> srcSchema.getContents().add(dstType);
>
>
>
> But this way I seem to loose sync between schema model and DOM model of
> copied XSDTypeDefinition.
> When I do only 1., then some DOM elements are missing.
>
> What's the correct way to do the copy?
>
>
> THanks in advance!
>
> Jacek
Previous Topic:copy xsd type definition from one schema to another
Next Topic:Foregrownd color issue at "=" sign
Goto Forum:
  


Current Time: Sat Dec 20 08:03:56 GMT 2014

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

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