XML — Schema Reference
Data Types
| Type | Description | Example |
|---|---|---|
| xs:string | Text | "Hello" |
| xs:integer | Whole number | 42 |
| xs:decimal | Decimal number | 3.14 |
| xs:boolean | True/false | true |
| xs:date | Date | 2025-01-01 |
| xs:dateTime | Date+time | 2025-01-01T12:00:00 |
| xs:time | Time | 12:00:00 |
| xs:duration | Duration | P1Y2M |
| xs:anyURI | URL | https://example.com |
Restrictions
| Restriction | Description |
|---|---|
| minInclusive | Minimum value (inclusive) |
| maxInclusive | Maximum value (inclusive) |
| minExclusive | Minimum value (exclusive) |
| maxExclusive | Maximum value (exclusive) |
| minLength | Minimum length |
| maxLength | Maximum length |
| length | Exact length |
| pattern | Regex pattern |
| enumeration | List of values |
Complex Types
<xs:complexType name="PersonType">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="age" type="xs:integer"/>
</xs:sequence>
<xs:attribute name="id" type="xs:integer"/>
</xs:complexType>
Occurrence Indicators
| Indicator | Description |
|---|---|
| minOccurs | Minimum occurrences |
| maxOccurs | Maximum occurrences |
Mini Practice
- Use different data types
- Add restrictions
- Create complex types
- Set occurrence indicators
Up Next
Continue with XPath Reference — XPath expression reference.
Related Topics
Frequently Asked Questions about Schema Reference
What is Schema Reference in XML?
Schema Reference is a fundamental concept in XML. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Schema Reference?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Schema Reference.
Why is Schema Reference important in XML?
Schema Reference is essential for XML development. Understanding this concept will help you write better code and solve real-world problems more effectively.