Articles → XSD → Introduction to xsd

Introduction to xsd

What is XSD?

Back to basics - types of XML element


<element_name attribute1=”attribute_value”>
.. Child nodes or text

Validate XML against XSD

-- Create a XML schema collection
Create XML schema collection TestSchemaCollection As '
XSD ' -- XSD against which XML will be validated 

--  Create a table with a single column of data type XML
Create table TestTable
	MyXMLSample XML (TestSchemaCollection) 

-- Insert a XML into the table
-- Insertion will be success if XML is valid
-- else insert statement will throw an error.
Insert into TestTable values('XML')

-- Finally drop a table and XML schema collection
drop table TestTable
drop xml schema collection TestSchemaCollection

Schema element in XSD

<schema xmlns="">

Simple XML element in XSD

<element name="element_name" type="data_type" />

Complex XML element in XSD

<element name="name_of_complex_element">
        List of simple types of xml elements
     </ group_indicator>

XML attributes in XSD

<attribute name="" type=""/>

Data types supported by XSD


   <blog category="Technical">
     <title>Code Project</title>

<schema xmlns="">
   <element name="Blogs">
	<element name="blog">
		<element name="title" type="string" />
		<element name="URL" type="string" />
	        <attribute name="category" type="string"/>

Posted By  -  Karan Gupta
Posted On  -  Sunday, January 4, 2015


Your Email Id  
Query/FeedbackCharacters remaining 250