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

This is my first time i

This is my first time i visit here. I found so many entertaining 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 leisure here! Keep up the good work. I have been meaning to write something like this on my website and you have given me an idea Jasa Pembuatan Website

Best Mac Pc Computer Repair Services West Palm Beach

Thank you for sharing This knowledge.Excellently written article,
Awesome job and really thank you very much for this awesome publish.....Best Mac Pc Computer Repair Services West Palm Beach

I agree with your

I agree with your suggestions. Thanks for sharing all, this is helpful for many people. Printed Circuit Board Supplier

Best Clubs in New York City

I’ve just decided to create a blog, which I have been wanting to do for a
while. Thanks for this post, garage door is the largest entryway into
your property, and you likely use it multiple times a day.   
Best Clubs in New York City

pain management with hypnosis

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

pain management with hypnosis

oral motor tools

You have done a great job. I will definitely dig it and personally
recommend to my friends. I am confident they will be benefited from this
site 

oral motor tools

Visit site

A very awesome blog post. We are really grateful for your blog post. You
will find a lot of approaches after visiting your post. 

Visit site

The particular transpiring

The particular transpiring provides got much easier pertaining to personally so that you can represent this desolate with a billet travel. I would also so that you can accept to the actual suggestions intended for looking at this diffuse. Extol an individual with your information. Get Rid of Cellulite

Explanation, this exegesis

Explanation, this exegesis is a clean culmination which often typically is aware of this activate's episode of a situation location. Think of your document in an didactic placing is actually known because "official book" is usually soporific by disciples, academy trees, flicker analysts to do the tasks. http://www.freetrialsytropin.com/

Extraordinary submit. Just

Extraordinary submit. Just lately we all right here encouraged your site along with advised to convey as we acquire really hugely valued looking for your site articles or blog posts.adult shop

This was exactly what i was

This was exactly what i was searching for. Have been fighting for a while to do this, thanks for have posted. more info Nice post. I learn something totally new and challenging on blogs I stumbleupon on a daily basis. more info. It's always helpful to read through articles from other writers and practice a little something from other sites.

Great article with excellent

Great article with excellent idea!Thank you for such a valuable article. I really appreciate for this great information . more info

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. steam mop reviews | ASUS ZenFone Smartphone Android Terbaik

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 pusat jam tangan swiss army | Modifikasi Motor Bebek

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!!!! 2015 4runner | download mp3 gratis

This type of position might

This type of position might actually be outstanding along with exactly what a brand new wonderful look at that you've achieved. These have served many people all kinds. thanks numerous a lot. Excellent notiion open-handed in order to try to counter with your own particular customized attain report collection easy site.Discounted Islamic Books

I sense looking at black and

I sense looking at black and white digital cameras with it's video equal is much like evaluating apples with oranges. They only are not the exact same thing in feel and look. www.besocial-blog.weebly.com I mentioned this in detail partly 1 of the sequence. When speaking with photographer Hellen Truck Meene she describe film as experiencing "miracle". Now I'm not sure what the techical expression for wonder is but creatively I understand exactly what Hellen signifies. 

I learn some new stuff from

I learn some new stuff from it too, thanks for sharing your information.  hop over to this website

Please let me know if

Please let me know if you’re looking for a article writer for your site. You have some really great posts and I feel I would be a good asset. More Bonuses

I must say, I thought this

I must say, I thought this was a pretty interesting read when it comes to this topic. Liked the material.  content

It has no way of it. But

It has no way of it. But there is another aspect of interest that not only can understand it, but already knows about it.

see page

Seems interesting, but I'm

Seems interesting, but I'm just not good enough at the language. I'll keep working on it.

Life Insurance Philadelphia

Great, This specific net

Great, This specific net webpage is seriously thrilling and enjoyment to
learn. I’m an enormous fan from the subjects mentioned.

iso container

 Definitely a great post.

 Definitely a great post. Hats off to you! The information that you have provided is very helpful.

Lady Gaga

Thank you again for all the

Thank you again for all the knowledge you distribute,Good post. I was
very interested in the article, it's quite inspiring I should admit.

Web Cast

A good example of content

A good example of content presentation. Thanks for sharing this information. Keep blogging

apartment movers

This course, you would own

This course, you would own ensured the position has received limit
outlook on some sift locomotive away there moreover the please has
reached the targeted assembly.

recommended you read

That's pretty powerful

That's pretty powerful stuff. I like the way your logic follows, and how you're able to put it into words with such a powerful post! I am enthralled.

Lej en pølsevogn

You are studio quality

You are studio quality images cannot be good if there is a picture taken from a street in the weather? Here are some tips on how to achieve that.

anchor

I really appreciate this

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

usb block erupter

I agree with you. This post

I agree with you. This post is truly inspiring. I like your post and everything you share with us is current and very informative.

click reference

First You got a great blog

First You got a great blog .I will be interested in more similar topics. i see you got really very useful topics , i will be always checking your blog thanks.

popunder traffic

Definitely a great post.

Definitely a great post. Hats off to you! The information that you have provided is very helpful.
chicken coop tips

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.

dog grooming

This is also a very good

This is also a very good post which I really enjoyed reading. It is not every day that I have the possibility to see something like this.. tour bali | Modifikasi Motor Satria FU

I wish your article that I

I wish your article that I read all your articles in a single day. Please continue and keep on writing excellent posts. powered essays review

e

I just read through the entire article of yours and it was quite good. This is a great article thanks for sharing this informative information. pdf to flash converter | pdf converter

The ape writers formats

The ape writers formats attentively elocution close the country score sizzle amongs horizontal in-intensity analysis mediums as gadget a upshot sturdy passage records on the mesh. franchising.ua

By getting students to

By getting students to discuss a topic and come to a conclusion on it a teacher can get them to show how good they are at taking in information, reasoning about it and explaining where they stand on the issue. visit this site

DayTradeTheWorld

We were watching "The Stoler Report" — the
real-estate roundtable program on Channel 75 — the other evening...
Developer Ben Shaoul, president of Magnum Real Estate Group, was one of
the guests discussing the residential market in Manhattan and the
boroughs... it was a fairly sobering discussion on everything from end
loans for condos ... debt yields... capital gains...DayTradeTheWorld

Download Dinosaur 13

Amazing Post , very well job done. Awesome font and text and realy well written.... Thank you ... it's really cool blog.. Awesome and interesting article. Great things you've always shared with us. Download Dinosaur 13

I really like this site

Thisis a great sitebut has asimple conceptthatIhave been interestedto visitthis site.

 Visit site

I lost track of the minicab

I lost track of the minicab online booking companies coming and going near me and so I had a quick look online. This site here has been a read blessing, they do all the hard work for me now. I just book with them nowadays.

Well-known gratuitys steadys

Well-known gratuitys steadys homogeneous touch about to assist performance. This sort of discerning image surely turn out to be somewhat attractiveness independently despite the fact that Once i package tight many mafia of fortuitous to assist valuable our own web page potential customer. Urban fiction

You actually make it look so

You actually make it look so easy with your performance but I find this matter to be actually something which I think I would never comprehend. It seems too complicated and extremely broad for me. I'm looking forward for your next post, I’ll try to get the hang of it 15 Motor Tiger Modifikasi | Modifikasi Motor Tiger Revo Touring | Modifikasi Motor Tiger 2005

I simply want to tell you

I simply want to tell you that I am new to weblog and definitely liked this blog site. Very likely I’m going to bookmark your blog . You absolutely have wonderful stories. Cheers for sharing with us your blog jual jam tangan murah | spa khusus wanita di bogor dan salon khusus wanita di bogor

This is my first time i

This is my first time i visit here. I found so many entertaining 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 leisure here! Keep up the good work. I have been meaning to write something like this on my website and you have given me an idea formal hairstyles | minyak aroma terapi dan jual essential oil

I feel really happy to have

I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details Jasa penulis artikel | analisa forex hari ini

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 short hairstyles | prediksi bola

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!!!! panduan blog dan komputer | Best Seller Products

Powered by Drupal - Design by artinet