<!--
 -  
 -  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
 -  project.
 -  
 -  Copyright (C) 1998-2018 OpenLink Software
 -  
 -  This project is free software; you can redistribute it and/or modify it
 -  under the terms of the GNU General Public License as published by the
 -  Free Software Foundation; only version 2 of the License, dated June 1991.
 -  
 -  This program is distributed in the hope that it will be useful, but
 -  WITHOUT ANY WARRANTY; without even the implied warranty of
 -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 -  General Public License for more details.
 -  
 -  You should have received a copy of the GNU General Public License along
 -  with this program; if not, write to the Free Software Foundation, Inc.,
 -  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 -  
 -  
-->
<?xml version="1.0" encoding="ISO-8859-1"?>
<refentry id="MS-A-1">
  <refmeta>
    <refentrytitle>Using Annotated XSD Schemas for Creating XML Views</refentrytitle>
    <refmiscinfo>tutorial</refmiscinfo>
  </refmeta>
  <refnamediv>
    <refname>Overview</refname>
    <refpurpose>Mapping Schemas</refpurpose>
  </refnamediv>

<refsect1 id="MS-A-1a">
<title>Mapping Schemas as XML views.</title>

<para>
XML views of relational data is similar to creating views by using CREATE VIEW statements.
XML views can be created by using the XML Schema Definition (XSD) language, and then can be queried by using XML Path 
language (XPATH) queries or XML Query (XQUERY) queries with using <function>xmlview</function> function.
</para>
<para> 
An XSD schema with the special set of annotations is referred to as a mapping schema. These annotations are used 
within the XSD schema to specify XML data to relational store mapping. This includes mapping between elements and 
attributes in the XSD schema to tables (views) and columns in the databases. If you do not specify the annotations, 
default mapping takes place. By default, an XSD element with complex type maps to a table (view) name in the 
specified database and an element or attribute with a simple type maps to the column with the same name as 
the element/attribute.
These annotations can also be used to specify the hierarchical relationships in XML 
(thus, representing the relationships in the database because XSD schemas are simply an XML view of relational data).
</para>
<para>
A file containg a mapping schema may be loaded by calling the 
<function>xml_load_mapping_schema_decl</function> 
function. A name (without extension .xsd) of the file containg a mapping schema is considered to be the name of 
the xml view, defined by a given mapping schema.
</para>
</refsect1>
</refentry>
