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

Thank you for helping

Thank
you for helping people get the information they need. Great stuff as usual.
Keep up the great work!!!

Triche fallout shelter

This is such a great

This is
such a great resource that you are providing and you give it away for free. I
love seeing blog that understand the value. Im glad to have found this post
as its such an interesting one! I am always on the lookout for quality posts
and articles so i suppose im lucky to have found this! I hope you will be
adding more in the future...

Asian hadicap

Good artcile. but it

Good
artcile. but it would be better if in future you can share more about this
subject. Keep posting.

world at arms gold stars hack generator

I’m not that much of a

I’m not that much of a internet reader to be honest but your sites really nice, keep it up! I’ll go ahead and bookmark your website to come back later. All the best
rental property management company

I have recently

I have
recently started a blog. the info you provide on this site has helped me
greatly. Thanksfor all of your time
& work.

Rinjani Trekking Package

This is a smart blog.

This is
a smart blog. I mean it. You have so much knowledge about this issue. and so
much passion. You also know how to make people rally behind it. obviously
from the responses.

Rinjani Trekking

Nice blog and


Nice blog and absolutely outstanding. You can do something much better but i still say this perfect.Keep trying for the best.

kostenloser 3ds emulator fur android

Great content material

Great content
material and great layout. Your website deserves all of the positive feedback
it’s been getting.

www.usapctechsupport.com

Thank you very much

Thank
you very much for writing such an interesting article on this topic.This has really made me think and I hope to
read more.  tighten vaginal muscles

Just admiring your

Just
admiring your work and wondering how you managed this blog so well. It’s so
remarkable that I can't afford to not go through this valuable information
whenever I surf the internet!

removals kent

Nice post! This is a

Nice
post! This is a very nice blog that I will definitively come back to more
times this year! Thanks for informative post.  kids toys online

Very good written

Very
good written article. It will be supportive to anyone who utilizes it.
including me. Keep doing what you are doing – can’r wait to read more posts.

www.girlfriendactivationsystemreviews.com

I really appreciate this

I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people.
custom Awning

Thanks for another

Thanks for another wonderful post. Where else could anybody get that type of info in such an ideal way of writing?
The Secret Brain System

You should comment on the

You should comment on the competition comparison of the blog. You can highlight it's mind boggling. Your blog exploration/tour will broaden your conversions. Joyful-spirit.com Hotelbaia.net

This is highly informatics,

This is highly informatics, crisp and clear. I think that everything has been described in systematic manner so that reader could get maximum information and learn many things.

how to get your ex boyfriend back via text

The post is written in very

The post is written in very a good manner and it contains many useful information for me.
รับทำ seo google adwords

You have a real ability for

You have a real ability for writing unique content. I like how you think and the way you represent your views in this article. I agree with your way of thinking. Thank you for sharing.
اخبار اليمن العاجلة

These are some great tools

These are some great tools that i definitely use for SEO work. This is a great list to use in the future..
טיפול אקנה

Thank you very much for

Thank you very much for writing such an interesting article on this topic. This has really made me think and I hope to read more.
obsession phrases does it work

Awesome blog. I enjoyed

Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!

emu oil uses

Thanks a lot for

Thanks a
lot for sharing us about this update. Hope you will not get tired on making
posts as informative as this.

как выучить английский язык

Thank you for helping

Thank
you for helping people get the information they need. Great stuff as usual.
Keep up the great work!!!

online-schauen

Im no expert, but I believe

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.

voyance téléphone

hi was just seeing if

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

Superbly written

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

More details

That is the excellent

That is the excellent mindset, nonetheless is just not help to make every sence whatsoever preaching about that mather. Virtually any method many thanks in addition to i had endeavor to promote your own article in to delicius nevertheless it is apparently a dilemma using your information sites can you please recheck the idea. thanks once more.
http://www.omvs-hc.org/girlfriend-activation-system-tricks-6-elements-of-masculine-power/

It seems to be a good way to

It seems to be a good way to use this code to apply on mattress topper and similar things..

You have done a great

You have
done a great job on this article.It’s
very readable and highly intelligent.You have even managed to make it understandable and easy to read.You have some real writing talent. Thank
you.

Under Amour

This was really an

This was
really an interesting topic and I kinda agree with what you have mentioned
here!
tile

Very useful post. This

Very
useful post. This is my first time i visit here. I found so many interesting
stuff in your blog especially its discussion. Really its great article. Keep
it up.

paket wisata lombok

Software convert mts files

Software convert mts files video to avi, mp4, wmv, mov, fcp/fce, iMovie, mts converter and

software avchd converter to download, convert HD camcorder files. mxf to avi mp4 mov mkv

with mxf converter, so to convert mts files

for playing on your devices. convert avchd files

Nice post! This is a

Nice
post! This is a very nice blog that I will definitively come back to more
times this year! Thanks for informative post.

http://www.girlfriendactivationsystemreview.org

Well written articles like

Well written articles like yours renews my faith in today’s writers. You’ve written information I can finally agree on and use. Thank you for sharing.
https://www.rebelmouse.com/reviewstinnitusmiracle/

Your blog provided us with

Your blog provided us with valuable information to work with. Each & every tips of your post are awesome. Thanks a lot for sharing. Keep blogging..
https://www.rebelmouse.com/textyourexback2review/

Very interesting blog. Alot

Very interesting blog. Alot of blogs I see these days don't really provide anything that I'm interested in, but I'm most definately interested in this one. Just thought that I would post and let you know.
desire system order

Thanks for taking the time

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic.
insurance for new drivers

This is just the

Please continue this great work and I look forward to more of your awesome blog posts.
luxury rehab facilities

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.

The Penguin method

https://www.rebelmouse.com/rebuildhairprogramreviews/

Hey, Thanks for the great blog. I'm a big fan of your writing style. I will comeback and read all the other articles you posted. Keep posting like this. https://www.rebelmouse.com/rebuildhairprogramreviews/

I really loved reading

I really
loved reading your blog. It was very well authored and easy to understand.
Unlike other blogs I have read which are really not that good.Thanks alot!

Campad Electronics

probioslim side effects

We are really grateful for your blog post. You will find a lot of approaches after visiting your post. Great work.probioslim side effects

Impressive web site.

Impressive
web site. Distinguished feedback that I can tackle. Im moving forward and may
apply to my current job as apet
sitter. which is very enjoyable. but I need to additionalexpand. Regards.

Création site internet Macon

I really like your take on

I really like your take on the issue. I now have a clear idea on what this matter is all about..
​Posizionamento Siti

adderum reviews

A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up. Great work.adderum reviews

This is such a great

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free.
reddit girlfriend activation system

Awesome post thanks for

Awesome post thanks for sharing
Valentines Day Week List 2016

amazing article Valentines

amazing article
Valentines Day Weeklist

the Festival of Love has

the Festival of Love has arrived so let us welcome
Happy Valentines Day

Awesome Show i.e. Bigg

Powered by Drupal - Design by artinet