Articles → XSD → Introduction To XSD

Introduction To XSD

What Is XSD?

Back To Basics - Types Of XML Element

  1. Simple element – Simple elements are those XML elements which don’t have child elements or attributes.
  2. <element_name>text</element_name>

  3. Complex element – Complex elements are those XML elements which contain child elements or attributes.
  4. <element_name attribute1=”attribute_value”>
    .. Child nodes or text

Validate XML Against XSD

  1. Open query analyzer
  2. Write following code
  3. -- 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

  4. Run the query.

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

  1. string
  2. decimal
  3. integer
  4. boolean
  5. date
  6. time


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

	<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