<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified" attributeFormDefault="unqualified">
    <!-- Define the root element, 'bookstore' -->
    <xs:element name="bookstore">
        <xs:complexType>
            <!-- 'bookstore' contains a sequence of 'book' elements -->
            <xs:sequence>
                <xs:element ref="book" maxOccurs="unbounded" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <!-- Define the 'book' element -->
    <xs:element name="book">
        <xs:complexType>
            <!-- A 'book' contains a sequence of 'title', 'author', 'year', and 'price' -->
            <xs:sequence>
                <xs:element name="title">
                    <xs:complexType>
                        <xs:simpleContent>
                            <xs:extension base="xs:string">
                                <!-- 'title' has a required 'lang' attribute -->
                                <xs:attribute name="lang" type="xs:string" use="required" />
                            </xs:extension>
                        </xs:simpleContent>
                    </xs:complexType>
                </xs:element>
                <xs:element name="author" type="xs:string" />
                <xs:element name="year" type="xs:integer" />
                <xs:element name="price" type="xs:decimal" />
            </xs:sequence>
            <!-- 'book' has a required 'category' attribute -->
            <xs:attribute name="category" type="xs:string" use="required" />
        </xs:complexType>
    </xs:element>

</xs:schema>