Reverse engineer DataBase (episode 2) Generating Class Diagram Image from XMI.

in my last article (Reverse engineer DataBase to XMI.)

I wrote how to reverse  engineer DataBase and produce XMI file from the data base using andromda Schema2xmi plug-in.

in this article I will speak about how to produce PNG (Portable Network Graphics) Image or any other type of Image that produces the Class Diagram representation from the XMI file that we produced earlier from our Data Base.

ok lets start.

I will use XSLT, and graphviz to achieve this task.

Prerequisites:

   1. XSLT 2.0.

   2. graphviz.

Requiered steps to generate the png class diagram from our xmi file are:

  1. Write XSL file that generate the dot file from our xmi.
  2. Generate the dot file using the XSL file.
  3. Use graphviz to generate the png image from the dot file.

1. Writing the XSL transformer file that generate the dot file from our xmi:

the following is the XSL file (XMITransformer.xsl) that applies to our xmi file and produces the dot file from it.

­


<xsl:stylesheet version="2.0"      
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"      
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes"
                xmlns:UML="org.omg.xmi.namespace.UML"     
                exclude-result-prefixes="xs xdt UML">

    <!--xsl:key name="class" match="UML:Class" use="@xmi.id" /-->
    <xsl:output method="text" media-type="text/xml" indent="yes" encoding="ISO-8859-1" />
    <xsl:variable name="from" select="0"/>
    <xsl:variable name="to" select="NON"/>
    <xsl:template match="XMI.header"/>
    <xsl:template match="XMI.content">
        <xsl:call-template name="pre-graph"/>
        <xsl:apply-templates
                    select="UML:Model/UML:Namespace.ownedElement/UML:Package/UML:Namespace.ownedElement/UML:Class" />     
        <xsl:apply-templates
                    select="UML:Model/UML:Namespace.ownedElement/UML:Package/UML:Namespace.ownedElement/UML:Association"/>
        <xsl:call-template name="post-graph"/>
        <!--xsl:call-template name="attributes"/>
        <xsl:call-template name="functions"/-->
    </xsl:template>
      
    <xsl:template name="attributes">
        int x;
    </xsl:template>
      
    <xsl:template name="functions">
        public static void main(String[] args){
        }
    </xsl:template>
      
    <xsl:template name="pre-graph">
        digraph g {      
        graph [      
        rankdir = "LR"      
        ];

        node [      
        fontsize = "16"      
        shape = "ellipse"
        ];
      
        edge [
        ];
    </xsl:template>
      
    <xsl:template name="post-graph">
        }
    </xsl:template>
      
    <xsl:template match="UML:Namespace.ownedElement/UML:Class">
        <!--"<xsl:value-of select="@xmi.id"/>" [
        label = "<xsl:value-of select="@name"/>"
        shape = "record"
        ];-->
        "<xsl:value-of select="@xmi.id"/>" [
        label = "<xsl:value-of select="@name"/> | <xsl:value-of select="@visibility"/> |  "
        shape = "record"
        ];
      
        <!--xsl:text>  </xsl:text>
        <xsl:value-of select="@visibility"/-->
        <!-- new Line character-->
        <!--xsl:text>&#xa;        </xsl:text-->
    </xsl:template>
      
    <xsl:template match="UML:Association.connection">
        <xsl:apply-templates select="UML:AssociationEnd/UML:AssociationEnd.participant/UML:Class"/>
    </xsl:template>

    <xsl:template match="UML:Association">
        <xsl:variable name="f"
                      select="UML:Association.connection/UML:AssociationEnd/UML:AssociationEnd.participant/UML:Class/@xmi.idref"/>
        "<xsl:value-of select="$f[1]"/>" -> "<xsl:value-of select="$f[2]"/>" [
        id = <xsl:value-of select="@xmi.id"/>
        ];
    </xsl:template>

    <xsl:template match="UML:Attribute">
    </xsl:template>      
</xsl:stylesheet>

­

2. Generate the dot file using the XSL file:

 java net.sf.saxon.Transform -o dotFileName.dot transformed.xmi XMITransformer.xsl

3. Use graphviz to generate the png image from the dot file:

dot -Tpng -o Diagram.png dotFileName.dot

Over days gone by several

Over days gone by several decades, the vacation industry continues to be
growing drastically, yet the original Travel Agent Enterprize model has
recently been steadily regressing. Travel & Lodging

This is a great

This is a great
inspiring article.I am pretty much pleased with your good work.You put really
very helpful information. Keep it up. Keep blogging. Looking to reading your
next post.

https://rebelmouse.com/wraphimaroundyourfingerreviews

 

It is a great website.. The

It is a great website.. The Design looks very good.. Keep working like that!.
Video Maximus

Positive site, where

Positive site,
where did u come up with the information on this posting?I have read a few of
the articles on your website now, and I really like your style. Thanks a
million and please keep up the effective work.
free stuff by mail

So, you try to power nourish

So, you try to power nourish your redundancy to be able to obtain position without dropping people entirely in the procedure. Think "Family Feud" where the aggressive near relatives is known as Dawson. Homepage

This was a really great

This was a really great contest and hopefully I can attend the next one. It was alot of fun and I really enjoyed myself..

http://ebookreviews.ning.com/pdf/girlfriend-activation-system-review

wallens

That is
really nice to hear. thank you for the update and good luck.

free
twitter followers

free facebook likes

Your work is very good and

Your work is very good and I appreciate you and hopping for some more informative posts. Thank you for sharing great information to us.

bongs over the net

 

Im no expert, but I

Im no expert, but I
believe you just made an excellent point. You certainly fully understand what
youre speaking about, and I can truly get behind that.
free
stuff by mail

abosolutely right

Whether the information you write is the truth? I hope your article is useful for the readers on the internet

http://www.facebook.com/hannacreated

supermasive blog

I will bookmark this site, so komprehensif information.

 http://facebook.com/13clothingstore

 

Nice info anyway

 I really like you writing this post and will subscribe your blog! And will follow your next post

www.ahlikolesterol.com

The information you have

The information you have posted is very useful. The sites you have referred was good. Thanks for sharing..
http://textmate2.org/

very usefull info

Your writing is very useful for us reader.

 www.bajumurahbingit.com

 

Word is growing and people

Word is growing and people are coming in. Unfortunately, however, whenever people look to use the globally web for pick-up, they are not finding you, just the other soup restaurant that is a prevent away. Who do you think they purchase from. Read More Here

I'm glad I found this web

I'm glad I found this web site, I couldn't find any knowledge on this matter prior to.Also operate a site and if you are ever interested in doing some visitor writing for me if possible feel free to let me know, im always look for people to check out my web site. check out

great archievement

a story that you wrote is very touching the hearts of the readers

http://www.bshindonesia.com

Thanks for the blog loaded

Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for.

bacterial vaginosis
home remedy

Learning a few off-page SEO

Learning a few off-page SEO techniques can help increase your web page position without depleting your banking account. First of all, be sure that your web page is enhanced for SEO using search phrases and exciting duplicate on each web page. visit site

This is a great

This is a great
article thanks for sharing this informative information. I will visit your
blog regularly for some latest post. I will visit your blog regularly for
Some latest post.
Avocado Oil For
Skin

This is a great

This is a great
inspiring article.I am pretty much pleased with your good work.You put really
very helpful information. Keep it up. Keep blogging. Looking to reading your
next post.

yuasa batteries

An SEO organization Modern

An SEO organization Modern sydney is no different to this and they also are enjoying a big part in providing excellent solutions to company homes from all across the globe. bajrangi bhaijaan

Great Information

Great Information
sharing .. I am very happy to read this article .. thanks for giving us go
through info.Fantastic nice. I appreciate this post.
backlinks

i was just browsing

i was just browsing
along and came upon your blog. just wanted to say good blog and this article
really helped me.
USA Health Insure

To achieve out to all the

To achieve out to all the prospective clients all across the world the entrepreneurs require hiring the solutions of a efficient SEO Organization. cliquez ici

Thanks for the blog

Thanks for the blog
loaded with so many information. Stopping by your blog helped me to get what
I was looking for.

List
Academy Review

 

I recently found many useful

I recently found many useful information in your website especially this blog page. Among the lots of comments on your articles. Thanks for sharing.
Happy Independence Day India
Independence Day Quotes
Independence Day India

I have read your

I have read your
article, it is very informative and helpful for me.I admire the valuable
information you offer in your articles. Thanks for posting it..
http://bongandglasspipes.com/

I have read your

I have read your
article, it is very informative and helpful for me.I admire the valuable
information you offer in your articles. Thanks for posting it..
air
conditioning service Albuquerque

Anonymous

I recently found many useful information in your website especially this blog page. Among the lots of comments on your articles. Thanks for sharing.
Bajrangi Bhaijaan Box Office Collection,
Bajrangi Bhaijaan 1st Day Collection,

Box Office Collection of Bajrangi Bhaijaan,

You know your projects

You know your
projects stand out of the herd. There is something special about them. It
seems to me all of them are really brilliant!
Miami
waterfront properties

A worldwide SEO program

A worldwide SEO program objectives a worldwide audience. Therefore, for location-bound organizations such as those catering to customers within a city, city or region, a regional SEO service would be more appropriate.
clash of clans defense strategy

This is very educational

This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post!inseminacion

cccc

An interesting dialogue is price comment. I feel that it is best to write more on this matter, it may not be a taboo topic however usually individuals are not enough to talk on such topics. To the next. Cheers.

highster
mobile login

For this well-organized

For this well-organized statistics tools are used.
SEO New You are able to absolutely is aware of that how your website is noticed by the different google and what steps are to be taken for all. Huge SEO understanding is taken from the developing to the approval of the website. albumes

I really thank you for the

I really thank you for the valuable info on this great subject and look forward to more great posts. Thanks a lot for enjoying this beauty article with me. I am appreciating it very much! Looking forward to another great article. Good luck to the author! All the best!
professeur de chant

Selecting an recognized to

Selecting an recognized to do the job will preserve your resources and will make you more cash. An experienced knows what he is doing, that goes for any type of organization.
Hörgeräte

Most of the time I

Most of the time I
don’t make comments on websites, but I'd like to say that this article really
forced me to do so. Really nice post!
CTET Notification

Professional seo experts

Professional seo experts with good knowledge in SEO can offer you specialized services. Buy Nautical Instruments

hi was just seeing if you

hi was just seeing if you minded a comment. i like your website and the thme you picked is super. I will be back.

Mitsubishi luftvärmepump

This is very educational

This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post.!

www.uk-courtesans.com

 

Superbly written article, if

Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place.

Interesting post. I

Interesting post. I
Have Been wondering about this issue, so thanks for posting. Pretty cool
post.It 's really very nice and Useful post.Thanks
Ginefiv

Righ there I like it

Ask.fm social network website with thousands of relatively young people is great place to ask questions or reply to same on your or someones profile wall. There is an option to post these questions as anonymous user without exposing your name and even username to an owner of Ask fm profile you're posting to. But with using Ask.fm Tracker | Ask fm Hack App you can see anyone's identity information such as their FB profile link, IP address from where they made question and much more. Download the app for free and let's fun begin!

I am hoping the same best

I am hoping the same best effort from you in the future as well. In fact your creative writing skills has inspired me.

Buy Google Plus Followers

It is Enjoyable subtle

It is Enjoyable subtle components and amounts, numerous a lot obliged regarding portray regardingJoe Barry Panic Away Review. It is limitless to me today, however usually, the comfort and recommendation is mind-boggling. Much appreciated over again plus good prospects,

Powered by Drupal - Design by artinet