XSD summary

Posted by Monik, 21 October 2010.
XSD Semantic Web XML
Based on XSD: http://www.w3schools.com/Schema/default.asp

* example:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="note">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="to" type="xs:string"/>
                <xs:element name="from" type="xs:string"/>
                <xs:element name="heading" type="xs:string"/>
                <xs:element name="body" type="xs:string"/>
           </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
* elementFormDefault="qualified" indicates that all elements in the XML must be namespace qualified

* to reference an XSD in an XML document the main node has to have the following attributes:
Elements in XSD schema:
Facets (restrictions):
Indicators:
  1. elements after "<xs:complexType>:
    * All - kazde dziecko musi sie pojawic przynajmniej raz, w dowolnej kolejnosci;
    * Choice - jedno z dzieci ma sie pojawic;
    * Sequence - wszystkie dzieci w podanej kolejnosci
  2. attributes in element's definition:
    * maxOccurs
    * minOccurs
    * "For all "Order" and "Group" indicators (any, all, choice, sequence, group name, and group reference) the default value for maxOccurs and minOccurs is 1"
    * you can use maxOccurs="unbounded" to have the element appearing unlimited number of times
  3. element groups and attribute groups (can be used among other elements/attributes):
    - this is a reference to groups of elements: <xs:group ref="persongroup"/>
    - and this is a reference to a group of attributes:
    <xs:element name="person">
    <xs:complexType>
    <xs:attributeGroup ref="personattrgroup"/>
    </xs:complexType>
    </xs:element>
    read more here: http://www.w3schools.com/Schema/schema_complex_indicators.asp
Other elements:
Element substitution:
Dividing and organizing the schema: http://www.w3schools.com/Schema/schema_example.asp (this is quite important...)

More about data types - read here: http://www.w3schools.com/Schema/schema_dtypes_string.asp

Comments


Comments: