Database
  Home arrow Database arrow Page 3 - Extracting Metadata
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE

Extracting Metadata
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 18
    2004-09-08

    Table of Contents:
  • Extracting Metadata
  • Introducing the Process
  • Using Schema Definitions Such As XSD
  • Extracting Metadata from Databases Such As SQL Server
  • Retrieving Metadata from External Sources
  • Extracting Metadata from Design Tools Such As UML
  • Extracting Metadata from Existing Applications and Source Code
  • Why Extract Metadata?
  • Establishing Your Own XML Design Guidelines
  • Introducing the Tools for Metadata Extraction
  • Understanding XSD’s Role in Code Generation
  • Exploring the Structure of an XSD
  • Working with SQL-92 Databases (SQL Server)
  • Understanding the Tool Architecture
  • Working with Information Schema Views
  • Using Constraints
  • Modifying Mappings
  • Retrieving Stored Procedure Recordsets
  • Retrieving Identity Columns
  • Creating Freeform Metadata
  • Using Skip Attributes
  • Merging Metadata

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Extracting Metadata - Using Schema Definitions Such As XSD


    (Page 3 of 22 )

    Schemas explicitly describe the structure of data. Schemas often describe the structure of XML files. Schemas offer a fallback position for finding metadata sources. You can describe almost any data with an XML schema, and you can generally create these schemas via a tool such as XSD.EXE that’s part of Visual Studio .NET. (See Footnote 2.) This gives you a good route to creating metadata when there isn’t a more obvious route, such as the programmatic interface of the SQL-92 standard.

    (Footnote 2: You can access XSD.EXE within Visual Studio by adding a DataSet or XML Schema to your project.)

    TIP: Use schemas such as XSD as a metadata source when your data source is an XML file or a database that’s supported by ADO.NET but doesn’t support the SQL-92 standard.

    Several styles of schemas are available—including three styles for XML. (See Footnote 3.) The most important of these is XSD. XSDs are generally created via an inference tool that finds patterns within an XML document and expresses these patterns and rules in XSD. You’ll rarely need to create an XSD manually, but you need to know a bit about how XSD files are structured to read and understand them.

    (Footnote 3: The three major schemas for describing XML data are External Data Representation (XDR), Document Type Definition (DTD), and XML Schema Definition (XSD).)

    TIP: Appendix A’s section on XSD gives a detailed breakdown of an XSD file.

    Schemas are useful anytime you need information about a data structure. XSDs are important in validating that the structure of an XML file is correct. Visual Studio also uses them for IntelliSense, autocompletion, and ToolTips. I use them for the data-driven XML editor of the code generation harness you’ll see in Chapter 3.

    NOTE:  You’ll see XSD schemas used two different ways in this book. XSD can itself be a metadata source. It can also be used to describe other XML files, including the individual metadata files and the scripting XML used in Chapter 3. Appendix A covers XSD basics. Later in this chapter you’ll see more details about working with XSD as a metadata source.

      

    Because all ADO.NET data can be expressed as XML, all ADO.NET data can be described by an XSD. This isn’t particularly profound because the XSD specification is sufficiently flexible to describe just about anything. Anything you perceive as data is likely to fit in XML that you can describe with XSD. XSD is itself XML, allowing it to be manipulated with any tool that supports XML.

    Directly using XSD as metadata turns out to be really ugly. XSD describes tables and columns in terms of complex types and simple types. The result is that the XPath to access the tables in an XSD looks like this:

    <xsl:apply-templates select=   "xs:schema/xs:element/xs:complexType/xs:choice/xs:element"/>

    NOTE:  This is XSLT usage, but the same XPath expression (the quoted part of the previous XSLT fragment) would also be used in a SelectNodes expression in brute-force or CodeDOM generation.

    I don’t know about you, but I’m more likely to look at that line and go “Huh?” than think, “Okay, looping through tables here.” Translating this to a friendly XML metadata format first allows you to write and maintain code templates that use simpler XPath expressions, which are immediately comprehensible, such as the following:

    <xsl:apply-templates select="Tables/Table"/>

    Because the conversion translates the XML of the XSD schema to the XML of the friendly format, XSLT is a good tool for the conversion. You can find an XSDToFriendlyXML.xslt file in the Downloads section of the Apress Web site (http://www.apress.com); it’s discussed in Appendix B. This chapter’s “Understanding XSD’s Roles in Code Generation” section further discusses creating friendly metadata.

    TIP Use metadata that’s friendly to code generation with as much preprocessing, such as data type translations, as possible.

    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.

    More Database Articles
    More By Apress Publishing


     

    DATABASE ARTICLES

    - Building Applications with Anonymous Types
    - A Closer Look at Anonymous Types
    - Programming with Anonymous Types
    - Converting Your Excel Worksheet into a Worki...
    - Excel Reference
    - Database Programming in C# with MySQL : Usin...
    - Formatting Techniques for Data Access from E...
    - Data Access from Excel VBA
    - Generating a Multiple Table Crystal Report u...
    - ADO and the Command Object
    - On Wiring Up an ADO Data Control
    - Reading and Writing to Files on the Intranet
    - Using ADO Record to Create and Navigate Intr...
    - Using Data Access Pages to Access Data on a ...
    - Using ADO with the SQL Native Client





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek