MS SQL Server
  Home arrow MS SQL Server arrow Page 2 - XML and the SQL 2000 Server part 3: XML Da...
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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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? 
MS SQL SERVER

XML and the SQL 2000 Server part 3: XML Data with XPath Queries
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 12
    2005-05-25

    Table of Contents:
  • XML and the SQL 2000 Server part 3: XML Data with XPath Queries
  • Xpath Queries
  • XDR Schema and XML View Mapper
  • Adding an SQL Module
  • Generating and Mapping an XDR Schema
  • Testing an Xpath Query Using the Internal Tester
  • Exporting Schema and Query in URL
  • Xpath Query With a Template File

  • 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


    XML and the SQL 2000 Server part 3: XML Data with XPath Queries - Xpath Queries


    (Page 2 of 8 )

    The XML View allows production of XML content from relational data and queries of relational data as if it were XML, without converting it to XML. XML view is an XML document with additional information added to it called the annotations. This is a construct that allows the SQL Server to determine the tables to use when presented with an Xpath query that uses the XDR Schema. Microsoft's XDR schema is a subset of the more comprehensive w3c's XPath specification [XDR antedates W3C's version]. In the previous article, I showed that of all the T-SQL extensions, the for xml Explicit provides by far the finest control over the XML produced. However, creating for xml explicit queries is not straight forward, and that is where XDR annotated schemas comes to the rescue. Xpath query is not supported directly by the SQL 2000 Server, but using the OleDB Provider. The OleDB Provider converts XPath queries into SQL statements and appends the forXML Explicit clause to them. SQL Server 2000 operates on this SQL formatted statements.

    In XPath queries, Tables and views in SQL Server are represented(mapped to) as <elements> and Columns as "attributes" of the <elements>. The annotations mentioned earlier are the mappings between relational database objects to the XML documents. The next picture shows a table stored in the relational database. The picture that follows is the XML view of the same table created using the XML View Mapper. The XML View Mapper will be discussed in detail later in the tutorial. The authors table is mapped to the <ElementType> with name attribute set to the name of the table, namely authors. The various column names are mapped to the different attributes with the Data Type in the table mapped to dt:type in the XML View. Column names go over to AttributeType names exactly. This is implied mapping-when the SQL item and the XDR item have the same name.

    Table Design
     
    XML View

    Example with Two Tables Having A Relationship

    This next picture shows two tables previously considered in parts 1 and 2 of this series. The picture that follows is the XMLView created using the XML View Mapper. Some features of the XDR Schema and the relationship of the relational tables to vis-a-vis the XML View will be explained.


    More MS SQL Server Articles
    More By Jayaram Krishnaswamy


     

    MS SQL SERVER ARTICLES

    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services
    - Building a Multi-table Report with SQL 2005 ...
    - A Secure Way of Building Connection Strings
    - Transferring a Database Using the SSIS Desig...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT