Schema Mapping Tool

Schema Mapping Tool

In order to relate the data in XML forms to fields in the SQL Server database a mapping schema (annotated XSD schema) is required. In addition to defining the format of the XML document, annotations in this schema relate elements and attributes of the XML form to corresponding fields in the database. To aid developers in the generation of SQLXML annotated XSD schemas, a utility is provided to generate a mapping schema based on the tables a specified SQL Server 2000 database. A point and click interface allows the developer to select the tables and fields to be used. The tool then creates an XML view of this data using the XML Schema Definition (XSD) language, and saves it in an XSD file that can be used by the SQLXML Adapter FPC or other programs to query or update the database using XPath queries and XML documents.

Note that this tool will provide a good starting point for a mapping schema, but there may be more work required to customize the schema to meet your exact requirements. Developers are encouraged to familiarize themselves with the mechanics of mapped schemas by reading the Creating XML Views by Using Annotated XSD Schemas article on MSDN for more information.

The Schema Mapping tool is located at C:\Program Files\FabriKam\bin\SchemaTool.exe on the FabriKam virtual machine. To create a mapping schema, follow these steps:

  1. Open the tool by double clicking SchemaTool.exe.

  2. Log on to the SQL Server by typing the server name and selecting an authentication method. If you select SQL Authentication, enter your User Name and Password. Click Connect to complete the login.

  3. Once connected, select a database from the database list. A hierarchical data grid displays a list of tables in the selected database.

  4. Click on the "+" sign next to a table name to expand the list and display all the fields in that table. Click the check box next to each field you want to appear in the mapping schema. If the table you selected stands in one-to-many relationship with other tables in the database, you may also select fields from the child tables to include in the schema. This allows you to easily map hierarchical relationships such as orders and order items within a single schema.

  5. Click Generate to create the schema. A preview of the generated XSD file appears in the preview window. If you need to make changes, you can modify your selections and click Generate again to update the schema.

  6. When you are satisfied that the displayed schema accurately maps the database information into an XML view that fits your application's needs, click Save to File and specify a file name and path. The new XSD schema is written to the hard disk and may be incorporated directly into your application.

Note that your XML data form must directly match this schema. If your application uses an XML form (such as an InfoPath form) that contains different or additional fields from the ones mapped by the XSD schema, the easiest solution is to convert the form to match the schema file by using an XSLT style sheet, as shown in the following deployment example.

 

© 2005 Microsoft Corporation. All rights reserved.