Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Xsd Example in XML

Xsd Example in XML

? XSD Example in XML

Here’s a complete working example of an XML document and its corresponding XSD schema. This demonstrates how an XML document is structured and how the XSD defines rules for validation.


? 1. XML Example

<?xml version="1.0" encoding="UTF-8"?><bookstore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"           xsi:noNamespaceSchemaLocation="bookstore.xsd">  <book>    <title>XML Fundamentals</title>    <author>Jane Doe</author>    <year>2025</year>    <price>29.99</price>  </book></bookstore>

? 2. XSD File (bookstore.xsd)

<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">  <xs:element name="bookstore">    <xs:complexType>      <xs:sequence>        <xs:element name="book" maxOccurs="unbounded">          <xs:complexType>            <xs:sequence>              <xs:element name="title" type="xs:string"/>              <xs:element name="author" type="xs:string"/>              <xs:element name="year" type="xs:gYear"/>              <xs:element name="price" type="xs:decimal"/>            </xs:sequence>          </xs:complexType>        </xs:element>      </xs:sequence>    </xs:complexType>  </xs:element></xs:schema>

? Explanation

ElementDescription
<bookstore>Root element containing one or more <book>s
<book>Has child elements like title, author, year, price
typeUses built-in types: xs:string, xs:gYear, etc.
maxOccursAllows multiple <book> entries

? How to Use It

  1. Save the XML file as bookstore.xml

  2. Save the XSD file as bookstore.xsd in the same folder

  3. Use an XML validator (like in Visual Studio Code, Notepad++, or an online tool) to validate


Would you like a downloadable .zip with these two files, or an example with attributes or restrictions next?

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql