Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Generate XML instance from XML schema [programmatically]
Generate XML instance from XML schema [programmatically] [message #1724865] Fri, 26 February 2016 16:00 Go to next message
aurel pestell is currently offline aurel pestellFriend
Messages: 90
Registered: October 2013
Location: Sweden
Member
Hi,

There is this nice tool in Eclipse where you can right click on an XSD file
and chose to generate an XML from it.
I was wondering if there was a way to do the same thing but from java.

(Background of what I am trying to achieve: I used the EMF tools to generate a genmodel along with its ecore model from a XSD. I used that genmodel to generate model code. I want to generate a XML file by using this generated code but I don't want to build the model instance from scratch with the code. Instead I would use the code to load this XML file)

Anybody has done something similar before or might know how to do this?
Thanks !

A.
Re: Generate XML instance from XML schema [programmatically] [message #1724921 is a reply to message #1724865] Sat, 27 February 2016 07:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Aurel,

Comments below.

On 26.02.2016 17:00, aurel pestell wrote:
> Hi,
>
> There is this nice tool in Eclipse where you can right click on an XSD
> file
> and chose to generate an XML from it.
> I was wondering if there was a way to do the same thing but from java.
I'm sure it's done in Java if it's a tool in Eclipse...
>
> (Background of what I am trying to achieve: I used the EMF tools to
> generate a genmodel along with its ecore model from a XSD. I used that
> genmodel to generate model code. I want to generate a XML file by
> using this generated code but I don't want to build the model instance
> from scratch with the code. Instead I would use the code to load this
> XML file)
How are you imagining generating the XML? You way you want to use the
generated model code, but you don't want to build the model instance
from scratch with code but rather load the XML, but how are you
imagining generating the XML with the model code other than by creating
an instance of the model and then serializing it?

This looks similar to what you're trying to do:
http://modeling-languages.com/a-pseudo-random-instance-generator-for-emf-models/
>
> Anybody has done something similar before or might know how to do this?
> Thanks !
>
> A.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Generate XML instance from XML schema [programmatically] [message #1724928 is a reply to message #1724921] Sat, 27 February 2016 08:42 Go to previous messageGo to next message
aurel pestell is currently offline aurel pestellFriend
Messages: 90
Registered: October 2013
Location: Sweden
Member
Hi Ed,

>How are you imagining generating the XML?

I don't know how the "new XML" Eclipse tool works but the result is great: the generated xml is minimal and
that's what I need to instantiate what could be the base of an instance of my ecore.
I don't think the generator involves my ecore model like in the link but only the xml schema (which it's derived from).
Re: Generate XML instance from XML schema [programmatically] [message #1724929 is a reply to message #1724928] Sat, 27 February 2016 10:00 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Aurel,

Yes, they no doubt use the schema to generate instances (just as the
link I gave uses the Ecore model and reflection to generated
instances). In either case, I don't know how the code works so only
Google is going to help provide more details...

On 27.02.2016 09:42, aurel pestell wrote:
> Hi Ed,
>
>> How are you imagining generating the XML?
>
> I don't know how the "new XML" Eclipse tool works but the result is
> great: the generated xml is minimal and
> that's what I need to instantiate what could be the base of an
> instance of my ecore.
> I don't think the generator involves my ecore model like in the link
> but only the xml schema (which it's derived from).
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Problem unmarshalling to Java object
Next Topic:Cloning annotations
Goto Forum:
  


Current Time: Thu Mar 28 11:07:21 GMT 2024

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

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

Back to the top