Hi ,

In support to proposal, I'm extending by providing use case scenario.

Consider a table student(id int, profile xml) where you are storing student id 
and their profile in xml format.
Let xml format for profile be as follow.

========profile.xml===========
<student>
    <name>
        <firstname>xyz</firstname>
        <lastname>abc</lastname>
    </name>
    <age>20</age>
    <course>DB101</course>
    <address>
        <city>bangalore</city>
        <pincode>560100</pincode>
    </address>
</student>
============================

There may a situation where course (tag) may be missing in xml file. The 
insertion of this file will not prompt any error message (even though it is one 
of important field)  because current version of postgresql only check for 
well-formedness of xml document, no provision for validation against xml 
schema. 

   Initially user has to register his schema by using our function  
REGSITER_XML_SCHEMA( “<URL OF SCHEMA>”, “<NAMESPACE>” , “<CONTENT OF SCHEMA 
.XSD FILE>") where user has to provide the URI  for the schema , Namespace to 
avoid namespace clashes and need to provide the complete schema in text and 
while creating the table user must associate the schema with column as below :

    Create table <tablename> (<col_name>  <datatype>, <col_name>  xml 
USE_SCHEMA <URL OF SCHEMA> );


eg: Create table student (id int, profile xml USE_SCHEMA 
"http://www.example.com/profile";);

 So we are providing facility  to register xml schema against a column with a 
datatype xml in a table, so that when ever an insertion in that column happens 
query processor (or which ever unit involved in this process) will first call 
our function validate_xml_schema()(as proposed in previous mail), which will 
decide to proceed or abort the insertion.

  In this way we can ensure that all the documents in the xml column are valid 
against schema.


Thanks,
Vikrantsingh
________________________________________
From: Kodamasimham Pridhvi (MT2012066)
Sent: Thursday, August 08, 2013 10:09 PM
To: pgsql-hackers@postgresql.org
Cc: Bisen Vikrantsingh Mohansingh MT2012036
Subject: RE: [HACKERS] Proposal for XML Schema Validation

Objective: To Add XML Schema validation and xmlvalidate functions (SQL:2008)

Description:
We’ve gone through current support of xml in postgreSQL and found that there is 
a check for well-formedness of xml document while inserting and updating. We 
want to extend this feature by adding xml schema validation.
         We will be providing user with DDL commands for creating and deleting 
XML Schema, also provision of associating xml schema with table while creation 
of new table or while altering table structure, we are planning to use libxml2 
library. Proposed syntax is given below.

1. End user perspective:

1.1 DDL
1.1.1   Register xmlschema
           Syntax
             REGSITER_XML_SCHEMA( “<URL OF SCHEMA>”, “<NAMESPACE>” , “<CONTENT 
OF SCHEMA .XSD FILE>")
           We will save this information into system catalog

1.1.2   Delete xmlschema
              Syntax
                DELETE_XML_SCHEMA(  “<URL OF SCHEMA>”)

1.1.3   Modification in Create Table commands
        Syntax
            Create table <tablename> (<col_name>      <datatype>, <col_name>    
  xml USE_SCHEMA <URL OF SCHEMA> )
         We will keep a flag in catalog for xml schema validation for each 
table. If xml schema is specified then while every insert/update sql query we 
will call valdate_xml_schema() [currently built in xml_is_well_formed() is 
called while inserting/updating, we can place our function call just next to it]


1.1.4   Similarly for Alter Table commands


2. Developer perspective

2.1. C-Function for Validation of xml doc

2.1.1 Validating XML

        Syntax
           Int<err_code>  validate_xml_schema(char xml[], char xml_schema[])
        This function will return 0 if validate successfully else return 
respective error code (which we will define later)
        We are planning to use libxml2
        This function will called while insert/update sql query


________________________________________
From: Andrew Dunstan <and...@dunslane.net>
Sent: Thursday, August 08, 2013 6:54 PM
To: Kodamasimham Pridhvi (MT2012066)
Cc: pgsql-hackers@postgresql.org; Bisen Vikrantsingh Mohansingh MT2012036; 
r...@iiitb.ac.in
Subject: Re: [HACKERS] Proposal for XML Schema Validation

On 08/08/2013 12:42 AM, Kodamasimham Pridhvi (MT2012066) wrote:
> Hello pgsql-hackers  ,
>     With reference to "Add XML Schema validation and xmlvalidate
> functions (SQL:2008)" in ToDo list, we have gone through pgsql-mailing
> list  but we didn't find any significant work in this area, so we are
> proposing our own model for xml schema validation . please kindly go
> through it and let us know how can we improve it.Please find the
> attached proposal document.
>
>
>
>


Please post your proposal as text, not as a PDF attachment. That's what
is preferred on this mailing list.

cheers

andrew

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to