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

Through this post, I know

Through this post, I know that your good knowledge in playing with all the pieces was very helpful. I notify that this is the first place where I find issues I've been searching for. You have a clever yet attractive way of writing. Otomotif Indonesia Dan Auto Indonesia | Review android terbaru

I like all the reviews have

I like all the reviews have been posted by the visitors of this site ,some of them are very good suggested regard the article.  7 seater taxi

I was very pleased to find

I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post spesifikasi Lenovo S920 | Cara Hidup Sehat

A highly skilled guitar

A highly skilled guitar player is a happen that is certainly certain rapidly so that you can pore, practically through verdant sorrys, tips on how to continue previous to fellow member formulate speedy regardless of during string so that you can pleasure ones cause.  minnetonka moccasins

A good blog always comes-up

A good blog always comes-up with new and exciting information and while reading I have feel that this blog is really have all those quality that qualify a blog to be a one.I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts interior room design | desain rumah minimalis

Thanks for sharing this

Thanks for sharing this interesting blog with us.My pleasure to being here on your blog..I wanna come beck here for new post from your site. GREAT!!!! Casting Indonesia | timnas u19

Through this post, I know

Through this post, I know that your good knowledge in playing with all the pieces was very helpful. I notify that this is the first place where I find issues I've been searching for. You have a clever yet attractive way of writing. Better Home Decorations | Tempat Wisata di Jawa Tengah

I wrote how to overturn

I wrote how to overturn construct DataBase also manufacture XMI tool from the information root using andromda Schema2xmi choke-in. in this doctrine I testament voice about how to parent PNG (Light Structure Vivids) Conception or some additional example of Emblem that stages the Rate Outline image from the XMI row that we produced before from our Material Despicable. lej árfolyam

I was very pleased to find

I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post pulsa murah | Desain Rumah Minimalis

This is my first t e i visit

This is my first t e i visit here. I found so many interesting stuff in
your blog especially its discussion. From the tons of comments on your
articles, I guess I am not the only one having all the enjoyment here!
keep up the good work.

living room

Head out have been greater

Head out have been greater than specifically approximately this type of anticipates preliminary the technique that you simply not enough this type of that you simply complicated. freedebtconsolidationquotes.com

I really had a lot of help

I really had a lot of help from this and I would like to return the favor and that's why I am writing this positive comment for your article. Madu Penyubur Kandungan | Modifikasi Motor Satria Fu

This great will be current

This great will be current creatures, with regards to many people a number of already been inadequate so that you can hoopla providing her or his inelegant skillets. facebook

it's really nice and

it's really nice and meanful. it's really cool blog. Linking is very useful thing.you have really helped lots of people who visit blog and provide them usefull information Ciri Gejala Penyakit | Modifikasi Motor CBR

Pretty good post. I just

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon toko herbal depok | Modifikasi Motor Byson

I'm more of a visual

I'm more of a visual learner,I found that to be more helpful well let me know how it turns out! I love what you guys are always up too. Such clever work and reporting!

mammoth lakes dui defense attorney

Surely owning that you

Surely owning that you simply procedure teach constantly constantly in place customer various difficulties. typically having. tiny holes inside the reinforce throughout live provide combined with complexion messing web-sites Many people currently take wound up provided total to help you built-in numerous higher-level pertaining to demonstrating top-notch option, which may be well-established.  ubytování jižní čechy

Thank you for sharing This

Thank you for sharing This knowledge.Excellently written article, if only all bloggers offered the same level of content as you, the internet would be a much better place. Please keep it up! Rumah Minimalis | idm crack

I thought it was going to be

I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. I am sure my visitors will locate that extremely useful. nano spray asli | Solar Movie

I was very impressed by this

I was very impressed by this post, this site has always been pleasant news Thank you very much for such an interesting post, and I meet them more often then I visited this site. Jual Kaos Futsal | busana muslim anak

I want you to thank for your

I want you to thank for your time of this wonderful read!!! I definately enjoy every little bit of it and I have you bookmarked to check out new stuff of your blog a must read blog!!!! Paket Wisata Bromo Tour Travel | Paket Wisata Bromo

Thank you so much for

Thank you so much for sharing this great blog.Very inspiring and helpful too.Hope you continue to share more of your ideas.I will definitely love to read. Video | Tips Cewek | Download Game Gratis Terbaru

This article is very well

This article is very well written and executed. The author have comprehend it very well and have great knowledge about it Grosir Distributor Baju Anak Muslim Murah Tanah Abang | Pusat Bisnis Baju Murah

I really had a lot of help

I really had a lot of help from this and I would like to return the favor and that's why I am writing this positive comment for your article. Pasar Grosir Tanah Abang Jakarta | Harga Grosir Distributor Murah | Peluang Usaha Daster Murah

it's really nice and

it's really nice and meanful. it's really cool blog. Linking is very useful thing.you have really helped lots of people who visit blog and provide them usefull information Peluang Usaha Di Surabaya Bisnis Baru | Pasar Grosir JATINEGARA Jakarta | Pasar Grosir CIPULIR Jakarta

Pretty good post. I just

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon BISNIS BAJU MURAH SURABAYA | GROSIR DASTER MURAH SURABAYA | PUSAT GROSIR MUKENA BALI MURAH SURABAYA

Amazing article! Great

Amazing article! Great material you've shared on this topic. I really had a lot of help from this and I would like to return the favor and that's why I am writing this positive comment for your article Peluang Bisnis Rumahan 2014 | Peluang Usaha Bisnis 2014 Terbaru | Pusat Grosir Baju Murah Surabaya

It is a great remarkable

It is a great remarkable blog post, Given plenty of information and facts with it, These kinds of blog posts maintains the people interest on the website, and keep on writing a little more ... all of the best grosir baju murah | Peluang Usaha Bisnis Rumahan Sampingan Baru Modal Kecil Sambilan Ibu Rumah Tangga | Tips Kesehatan dan penyakit terbaru

Sizzling offer nighs true

Sizzling offer nighs true phantasms problem which often usually intact capture worker debris. My own private duplicate with accession in order to previous i extricate humane abortive thingamajigs everyday by means of genre of several similar to this column associated with. free sex

I really enjoy simply

I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post. Hats off to you! The information that you have provided is very helpful. Tips Kecantikan dan Kesehatan | Pusat Grosir Baju Murah Grosir Kulakan | Peluang Usaha dan Bisnis Online

I thought it was going to be

I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. I am sure my visitors will locate that extremely useful. Fingerprint

I was very impressed by this

I was very impressed by this post, this site has always been pleasant news Thank you very much for such an interesting post, and I meet them more often then I visited this site. Nomor Cantik

It is a great remarkable

It is a great remarkable blog post, Given plenty of information and facts with it, These kinds of blog posts maintains the people interest on the website, and keep on writing a little more ... all of the best alat pemancung hidung

I really enjoy simply

I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post. Hats off to you! The information that you have provided is very helpful. obat penggemuk badan

Really great post, Thank you

Really great post, Thank you for sharing This knowledge.Excellently written article, if only all bloggers offered the same level of content as you, the internet would be a much better place. Please keep it up! jelly gamat gold g

This is a wonderful article,

This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck. desainrumah.me

Thank you for sharing This

Thank you for sharing This knowledge.Excellently written article, if only all bloggers offered the same level of content as you, the internet would be a much better place. Please keep it up! tas premium

I required to comment and say that I enjoyed reading your posts

I required to comment and say that I enjoyed reading your posts and they are all fine written out.
You make diaryging look easy lol i will arrange to begin a web log later today which i hope it’s nearly nearly as good as your blog! a lot of success to you!

untuk pemula yang ingin tau cara belajar trading forex online indonesia

Just wanna tell that this is often really useful

Just wanna tell that this is often really useful, Thanks for taking it slow to place in scripting this. Thanks..

cara belajar bermain trading forex online yang aman

It is a great remarkable

It is a great remarkable blog post, Given plenty of information and facts with it, These kinds of blog posts maintains the people interest on the website, and keep on writing a little more ... all of the best kaos couple

I really enjoy simply

I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post. Hats off to you! The information that you have provided is very helpful. belajar hipnotis

I want you to thank for your

I want you to thank for your time of this wonderful read!!! I definately enjoy every little bit of it and I have you bookmarked to check out new stuff of your blog a must read blog!!!! panduanpraktis.com

Thank you so much for

Thank you so much for sharing this great blog.Very inspiring and helpful too.Hope you continue to share more of your ideas.I will definitely love to read. IndoBeritaCom

This article is very well

This article is very well written and executed. The author have comprehend it very well and have great knowledge about it beyondinteriorsdesign.com

I really had a lot of help

I really had a lot of help from this and I would like to return the favor and that's why I am writing this positive comment for your article. contoh kata pengantar

it's really nice and

it's really nice and meanful. it's really cool blog. Linking is very useful thing.you have really helped lots of people who visit blog and provide them usefull information enetour.net

Pretty good post. I just

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon tips cepat hamil

Amazing article! Great

Amazing article! Great material you've shared on this topic. I really had a lot of help from this and I would like to return the favor and that's why I am writing this positive comment for your article vcc paypal

Five-part dissertation is

Five-part dissertation is usually most likely your existing finish brand-new let you throughout live provide combined with due to variants brand-new five-paragraph dissertation.  Nulled wordpress themes

It is a great remarkable

It is a great remarkable blog post, Given plenty of information and facts with it, These kinds of blog posts maintains the people interest on the website, and keep on writing a little more ... all of the best forex indonesia

Powered by Drupal - Design by artinet