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

It is imperative that we

It is imperative that we read blog post very carefully. I am already done it and find that this post is really amazing.
Language of Desire

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!
Check this out

Thanks for the nice blog. It

Thanks for the nice blog. It was very useful for me. I'm happy I found this blog. Thank you for sharing with us,I too always learn something new from your post.
r4 3ds

Love to read it,Waiting For

Love to read it,Waiting For More new Update and I Already Read your Recent Post its Great Thanks.
watch free tv series

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

irctc

Keep up the good work , I

Keep up the good work , I read few posts on this web site and I conceive that your blog is very interesting and has sets of fantastic information.

http://puregarciniacambogia.co/

This was an excellent page

This was an excellent page for such a hard subject to talk about. I look forward to reading many more great posts like these. Thanks
The Bonding Code Bob Grant

Great articles and great

Great articles and great layout. Your blog post deserves all of the positive feedback it’s been getting.

forskolin
review

I’ve been searching for

I’ve been searching for some decent stuff on the subject and haven't had any luck up until this point. You just got a new biggest fan!..
Bonding Code

Pretty good post. I

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. Big thanks for the useful info.

dr oz and garcinia cambogia reviews

Very nice article, I enjoyed

Very nice article, I enjoyed reading your post, very nice share, I want to twit this to my followers. Thanks!.

I have recently started a

I have recently started a blog, the info you provide on this site has helped me greatly. Thanks for all of your time & work.Superior Singing Method

I think this is an

I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.
Children Learning Reading

Nice to be visiting your

Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share.
Neko atsume kitty collector hack

I haven’t any word to

I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us.
Guilt Free Desserts Review

I really appreciate the

I really appreciate the kind of topics you post here. Thanks for sharing us a great information that is actually helpful. Good day!

Superior Singing Method

Thanks for taking the time

Thanks for taking the time to discuss this. I feel strongly that love and read more on this topic. If possible. such as gain knowledge. would you mind updating your blog with additional information? It is very useful for me.
Crooks and castles

I think this is an

I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.
Save The Marriage System

Wonderful blog! I found it

Wonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Appreciate it.

webmasters
wanted

 

It’s appropriate

It’s
appropriate time to make some plans for the future and it is time to be
happy. I have read this post and if I could I wish to suggest you few
interesting things or advice. Perhaps you could write next articles referring
to this article. I desire to read even more things about it!

Youtube to mp4

Thanks for posting

Thanks
for posting this info. I just want to let you know that I just check out your
site and I find it very interesting and informative. I can't wait to read
lots of your posts.

Lavorare in sicurezza

This is my first time

This is
my first time visit here. From the tons of comments on your articles.I guess
I am not only one having all the enjoyment right here!

custom cleaning cloth

I really enjoyed

I really
enjoyed reading this post. big fan. Keep up the good work andplease tell me
when can you publish more articles or where can I read more on the
subject?

m88 มือถือ

Nice post! This is a very

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

This is just the

This is
just the information I am finding everywhere. Thanks for your blog. I just
subscribe your blog. This is a nice blog..

Dumpster Rental Austin

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.
Language of Desire Free

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!

נועם קוריס

I found this is an

I found this is an informative and interesting post so i think so it is very useful and knowledgeable. I would like to thank you for the efforts you have made in writing this article. reviews of forskolin

Hello There. I found your

Hello There. I found your blog using msn. This is an extremely well written article. I will be sure to bookmark it and return to read more of your useful information. Thanks for the post. I’ll certainly comeback.
Rinjani Trek

Hello There. I found your

Hello There. I found your blog using msn. This is an extremely well written article. I will be sure to bookmark it and return to read more of your useful information. Thanks for the post. I’ll certainly comeback.
Rinjani Trek

Love to read it,Waiting For

Love to read it,Waiting For More new Update and I Already Read your Recent Post its Great Thanks.

online computer services

Thank you for helping

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

http://www.myconsciousspirit.com/?m=0

I was looking at some

I was
looking at some of your posts on this website and I conceive this web site is
really instructive! Keep putting up..

Sugar Bowl Live Stream

(No subject)

This was really an

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

Floating

Its a great pleasure

Its a
great pleasure reading your post.Its full of information I am looking for and
I love to post a comment that "The content of your post is awesome"
Great work.

safe-medical-store.com

This is really a nice and

This is really a nice and informative, containing all information and also has a great impact on the new technology. Thanks for sharing it,

Secrets To Dog Training

Keep up the goodwork .

Keep up
the goodwork . I read few postson thisweb siteand Iconceive that your blogis veryinteresting and hassetsoffantasticinformation.

https://youtube.com/watch?v=DH5q1wiHRBM&feature=youtu.be

I’ve been searching

I’ve been searching
for some decent stuff on the subject and haven't had any luck up until this
point, You just got a new biggest fan!..

bosch dishwasher
repair

 

   I admire this article

   I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.   top5net

This is a great article

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.
Calling Men

Its a great pleasure reading

Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work.  http://www.fatburningguru.com/

Wow i can say that

Wow i
can say that this is another great article as expected of this
blog.Bookmarked this site..

http://www.enwearables.com/

I think this is an

I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.
The Venus Factor

I admire this article

I admire
this article for the well-researched content and excellent wording.I got so involved in this material that I
couldn’t stop reading.I am impressed
with your work and skill.Thank you so
much.

free iphone 6

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. Big thanks for the useful info.
تحميل لعبة زوما القديمة

i am for the first time

i am for the first time here. I found this board and I in finding It truly helpful & it helped me out a lot. I hope to present something back and help others such as you helped me.GSM Antenna

I think this is an

I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.

Obsession Phrases

Thanks so much for

Thanks
so much for this information.I have
to let you know I concur on several of the points you make here and others
may require some further review. but I can see your viewpoint.

scommesse

Powered by Drupal - Design by artinet