XML and the SQL 2000 Server part 3: XML Data with XPath Queries - XDR Schema and XML View Mapper
(Page 3 of 8 )
XDR Schema, Annotated XDR Schema, and XML View
First of all the XML View is an XML document and therefore the first line is the reference to an XML document of the current version and encoding. The root element of the XDR schema is always Schema as shown in the picture derived from the namespace urn:schemas-microsoft-com:xml-data . This is followed by three name spaces, for data, datatype and SQL that provide the annotations. This is followed by the elements[which is analogous to tables in the relational database] and the columns contained represented as attributes. For each of the columns, the datatype of the column is also specified. Finally since the tables are joined by a parent-child relationship, the annotation regarding this is also present in the XML View. Although there are 3 kinds of annotations in this,
there are several others[ please refer to documentation, In the SQL 2000 Server's Book on line look under the Active subset SQL 2000:XML] defined in the xml-sql namespace.
SQL:relation
SQL:field
SQL:relationship with attributes, key-relation, key, foreign-relation, foreign-key
From these two examples, if you get an impression that you can manually[with a text editor] write an XML View or an annotated XDR schema, you are not wrong in that assumption. But for more than 2 tables with relationships between them, manual crafting will be both tedious and error prone. This is where the XML View Mapper, a GUI steps in.
XML View Mapper
Simply stated the XML View Mapper takes in a SQL Data's Schema and produce an XML View that can be used in not only posing queries that do not violate Xpath query rules, but also provides a means to test the Xpath queries. XML View Mapper can import an SQL Schema by connecting to an SQL Server 2000 and accessing the tables and columns in the database together with any defined relationships. Using this schema, it can produce an XDR annotated Schema / XML View. It also has inbuilt programs to validate a schema, edit a schema and run Xpath queries. It can also import an annotated XDR schema that produces an SQL Schema as well. XML View Mapper may be down loaded from several places,this is one of them. The installation is fast and easy and you can choose either a complete install, or a custom install. For documenting this tutorial a complete install was chosen. This installs the XMLMapper.exe and several ActiveX controls and dll's into the install directory with a couple of samples. The installation also adds a short cut to All Programs as shown in this picture as well as documentation. The tool can be activated by double clicking this shortcut.
XML View Mapper Project
When the XML Viw Mapper program starts up, you will be presented with this screen wherein you may choose to create a new XML View Mapper project, or highlight one that is all ready present and open it up. Project files have the extension .smp.
The Map Editor form is where the mappings between the SQL objects on the left panel and the XML elements/attributes on the right panel is implemented. When the mapping is being made lines will be connecting from the SQL side to the XML side crossing the middle panel as will be seen later. In an empty [now it is empty] area in either of these panels, clicking inside the panel, allows us to import an SQL schema or an XDR schema. If such schemas already exist in the SQL Module, or the XDR module then they can be dragged and dropped into these panels.
Next: Adding an SQL Module >>
More MS SQL Server Articles
More By Jayaram Krishnaswamy