<?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 qualifiedxmlns="http://www.w3schools.com"
- default namespace declarationxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- make XML Schema Instance namespace available
xsi:schemaLocation="http://www.w3schools.com location_of_your_schema.xsd"
- location of the schema to be used with given namespace
<xs:element name="to" type="xs:string"/>
) - can contain only text (i.e. boolean, string, date, etc.), you can also restrict its type; the most common types:<xs:attribute name="xxx" type="yyy"/>
) - you can specify a default or a fixed (cannot be changed) value of an attribute; to make an attribute required you have to specify it, by using
use="required"
attribute;
<xs:element name="employee"> <xs:element name="firstname"
type="xs:string"/> type="xs:string"/> </xs:complexType> |
<xs:element name="employee" type="xs:string"/> type="xs:string"/> |
<xs:complexType name="fullpersoninfo">
<xs:complexContent>
<xs:extension base="personinfo">
<xs:sequence>
... new elements ...
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="product">* there are special ways to define a complex element: with text only, with other elements only, with both text and other elements - i nie widze w tym zadnej logiki; for more information on this see: http://www.w3schools.com/Schema/schema_complex_elements.asp
<xs:complexType>
</xs:complexType>
</xs:element>
<xs:element name="car">(more here: http://www.w3schools.com/Schema/schema_facets.asp)
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:restriction_type value="..."/>
...
<xs:restriction>
</xs:simpleType>
</xs:element>
"<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
maxOccurs
minOccurs
maxOccurs="unbounded"
to have the element appearing unlimited number of times
xs:group ref="persongroup"/>
<xs:element name="person">read more here: http://www.w3schools.com/Schema/schema_complex_indicators.asp
<xs:complexType>
<xs:attributeGroup ref="personattrgroup"/>
</xs:complexType>
</xs:element>
xs:any minOccurs="0"/>
xs:anyAttribute/>
<xs:element name="name" type="xs:string">- now "navn" can be used instead of "name"; we can also block an element from others substituting it, by using:
<xs:element name="navn" substitutiongroup="name">
block="substitution"
attribute within the original element; read more here: http://www.w3schools.com/Schema/schema_complex_subst.asp
Comments: