Re: Proposal for XML Schema Validation - Mailing list pgsql-hackers
From | Bisen Vikrantsingh Mohansingh MT2012036 |
---|---|
Subject | Re: Proposal for XML Schema Validation |
Date | |
Msg-id | 278c3407cf634697bce8e18ed43d843f@HKXPR01MB055.apcprd01.prod.exchangelabs.com Whole thread Raw |
In response to | Re: Proposal for XML Schema Validation ("Kodamasimham Pridhvi (MT2012066)" <Pridhvi.Kodamasimham@iiitb.org>) |
List | pgsql-hackers |
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 errormessage (even though it is one of important field) because current version of postgresql only check for well-formednessof 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 namespaceclashes and need to provide the complete schema in text and while creating the table user must associate the schemawith 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 aninsertion in that column happens query processor (or which ever unit involved in this process) will first call our functionvalidate_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 documentwhile inserting and updating. We want to extend this feature by adding xml schema validation. We will be providinguser with DDL commands for creating and deleting XML Schema, also provision of associating xml schema with tablewhile creation of new table or while altering table structure, we are planning to use libxml2 library. Proposed syntaxis given below. 1. End user perspective: 1.1 DDL 1.1.1 Register xmlschema Syntax REGSITER_XML_SCHEMA( “<URL OF SCHEMA>”, “<NAMESPACE>” , “<CONTENT OFSCHEMA .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 validationfor 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 functioncall 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 return0 if validate successfully else return respective error code (which we will define later) We are planning touse libxml2 This function will called while insert/update sql query ________________________________________ From: Andrew Dunstan <andrew@dunslane.net> Sent: Thursday, August 08, 2013 6:54 PM To: Kodamasimham Pridhvi (MT2012066) Cc: pgsql-hackers@postgresql.org; Bisen Vikrantsingh Mohansingh MT2012036; rc@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
pgsql-hackers by date: