Extracting Metadata - Extracting Metadata from Design Tools Such As UML
(Page 6 of 22 )
I really wanted to be able to give you good tools for building metadata directly from UML. After much time and grief, I commiserated with one of my UML guru friends (who is a bit gnarly around the edges), and he said, “What? I’d fire anyone who took their UML to so much detail that you could directly build business objects from them. UML isn’t an eye chart!” That’s not an excuse. Okay, that’s an excuse, but it’s also a different perspective. I’ll admit the real reason I’m not giving you a good UML solution is that it’s a complex metadata source to work with, and databases are often a more appropriate metadata source.
TIP: UML should make an excellent metadata source. Unfortunately, technical hurdles make it a difficult metadata source to use.
Using Visio Visio provides a UML modeling tool, but it isn’t very good. (See Footnote 5) One of its many problems is that it quite successfully buries the UML metadata where it’s extremely hard to access. There are a couple of contorted approaches you can use to extract metadata from Visio UML. You can try to break up the XML save format. But that’s a storage format for a drawing program and has no understanding of UML. You can create XML Metadata Interchange (XMI) output if you download a special Dynamic Link Library (DLL) from MSDN (search the MSDN library for XMI and UML) (See Footnote 6). The XMI standard is an XML layout (defined in a schema) that allows for interchange of information between UML tools. To work with this file, you’ll also have to download a Document Type Definition (DTD) schema from the Object Management Group (OMG) Web site, which the MSDN article explains. A simple UML diagram with two classes, three attributes, and three operations was a 313-kilobyte (KB) XMI file. So, for goodness sake, translate it into friendly XML and don’t do code generation directly against this file!
(Footnote 5: Visio currently stinks for UML. I remain optimistic that Microsoft will provide a good UML product.)
(Footnote 6: You can access MSDN libraries at http://www.msdn.microsoft.com even if you aren’t an MSDN subscriber.)
Visio also offers a rudimentary code generation feature. From the perspective of real code generation, it’s useless. It’s buggy, extremely tedious to use, and from a practical perspective just builds shells. However, there’s a third approach to extracting UML metadata from Visio lurking here. You can create your UML, generate a dummy C# project, then use reflection to extract the UML structure from these classes, and finally massage problems that occur. Wow, that’s so ugly, forget I even suggested it.
Using Other UML Tools If you’re using Rational or another UML tool, you can probably create XSD schemas for the classes you define. The tool may not carry all of the information from your UML design, but it’s a start. These products generally also provide XMI support, allowing you to extract a more complete structure—if you’re willing to attack XMI’s complexities. You also may be able to export the structure to the SQL Server repository and extract it from there—again, a rather roundabout way to accomplish a simple task.
This is from Code Generation in Microsoft .NET, by Kathleen Dollard (Apress, ISBN 1590591372). Check it out at your favorite bookstore today. Buy this book now. |
Next: Extracting Metadata from Existing Applications and Source Code >>
More Database Articles
More By Apress Publishing