Book a Demo

Author Topic: Generating XML elements from class diagrams?  (Read 3941 times)

wsargent

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Generating XML elements from class diagrams?
« on: June 14, 2005, 09:49:40 pm »
I have an interesting situation.  I have an XML file that is responsible for defining a schema of beans (basically saying an order object consists of several line items, payment groups, shipping groups, etc.)

I have defined the appropriate mapping in Enterprise Architect, and I have the XML file... is there any way I can get EA to generate or synchronize classes with the appropriate stereotypes (preferably the element type) using the language facility?

Will.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Generating XML elements from class diagrams?
« Reply #1 on: June 14, 2005, 10:25:37 pm »
Quote
I have an interesting situation.  I have an XML file that is responsible for defining a schema of beans (basically saying an order object consists of several line items, payment groups, shipping groups, etc.)
Hi Will,

I (for one) am not clear on what you are asking....
An XML file that describes a schema is normally an XSD.  Is that what you have?  If not, can you post a sample extract?
Quote
I have defined the appropriate mapping in Enterprise Architect, and I have the XML file... is there any way I can get EA to generate or synchronize classes with the appropriate stereotypes (preferably the element type) using the language facility?

Will.
Are you saying you want to generate the XML instance from EA?  If so, then you can create your own language, munge the existing templates to your requirements (including variants based on their stereotype).  I've done that to export conceptual metadata (of the kind you hint at) from EA according to a separately defined XSD schema.  I then use that information to generate (eventually) artifacts, code, DB Schemas, documentation, tests etc...

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

wsargent

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Generating XML elements from class diagrams?
« Reply #2 on: June 15, 2005, 08:29:03 pm »
Lessee.  I can't attach images in this forum, but I can publish a Yahoo photo:



I dunno if they change the direct image links, so here's an album URL:

http://pg.photos.yahoo.com/ph/will_sargent/detail?.dir=b4ba&.dnm=a720.jpg&.src=ph

Basically I don't want a schema, I want actual generation of XML elements and attributes, mapped through a schema or DTD.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Generating XML elements from class diagrams?
« Reply #3 on: June 15, 2005, 09:20:45 pm »
Quote
http://pg.photos.yahoo.com/ph/will_sargent/detail?.dir=b4ba&.dnm=a720.jpg&.src=ph

Basically I don't want a schema, I want actual generation of XML elements and attributes, mapped through a schema or DTD.
Will,
From what I see there, you can use the approach I suggested.  I do the same kind of thing.  Good luck with the wonderful world of EA macros.  If I can be of assistance after you've had a try (good for the soul ;D)  send me a message and we can talk off-line.

HTH,

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

wsargent

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Generating XML elements from class diagrams?
« Reply #4 on: June 17, 2005, 09:39:57 am »
Can you point me to a resource on EA macros or any existing XML mappings?  I can't make head or tail of the existing language definitions, and the dialog based interface doesn't exactly make it easy.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Generating XML elements from class diagrams?
« Reply #5 on: June 17, 2005, 03:56:32 pm »
Quote
Can you point me to a resource on EA macros or any existing XML mappings?  I can't make head or tail of the existing language definitions, and the dialog based interface doesn't exactly make it easy.
Hi Will,
The help file is as good as it gets...  :'(
As with most of EA - once you turn your brain inside out to the way EA looks at the world, it's quite functional.

The way I approached it was to copy the C# definitions, and then set the language of the class to "NewLanguage", generated and then started tinkering...  If anyone else has a better idea...  (NOTE: you'll need to set up some Datatypes for your new language)  It actually didn't take too long to figure out what was going on.  (Adding some trace output helped to sort out which macros were being called when - and the Sparxians were helpful when I asked questions of them)

You DO realise you won't be able to reverse engineer?  You can only do that on one of the supported languages.  For me that's not a problem since I'm only every forward engineering.

As for your suggestion that the EA UI Is suboptimal...  Shame on you!   Are you conducting a personal vendetta on EA? ;D  (couldn't resist)

Paolo

« Last Edit: June 17, 2005, 03:57:46 pm by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!