Attributes
Attributes are always of SimpleType (since tehy don't contain otherelements or attributes)
Attributes always appear in ComplexType elements
Declared in an XML Schema like:
<xs:attribute name="coverType" type="xs:string" use="required"/>
Attributes default to OPTIONAL if you don't specify use="required"
Pre-define an attribute's value using value="blah"
Occurence Constructs
Define the number of times an element can occur - correlates to + or * or ? in DTDs
maxOccurs - specifies the maximum number of times an element can occur
- can be 1 to 'unbounded' (no limit)
minOccurs - specifies teh minimum number of tiems an element can occur
- can be 0 (optional) or some other integer
Custom Simple Types
Allow a developer to define their own rules for a type declaration - zip code or phone number are great examples
<xs:simpleType name="phoneNumberType">
<xs:restriction base="xs:string">
<xs:pattern value="\d{3}-\d{3}-\d{4}"/>
</xs:restriction>
</xs:simpleType>
Patterns - RegEx
Used to match patterns in strings
XML uses Perl's regular expression dialect. For more details see: https://perldoc.perl.org/perlre.html#Regular-Expressions
Range Constructs
Range constructs limit the range of simple tyoes that are numerically and date based
- maxInclusive - used to set an upper limit that INCLUDES the value that it is set to
- maxExclusive - used to set an upper limit that EXCLUDES the value that it is set to
- minInclusive - used to set an lower limit that INCLUDES the value that it is set to
- minExclusive - used to set an lower limit that EXCLUDES the value that it is set to
Annotations
Annotations are simply a special type of comment that software programs can read
Used for documenting web services and other public APIs
Declared like:
<xs:annotation>
<xs:documentation>blah, blah, blah...</xs:documentation>
</xs:annotation>
Scope
Local scope is simply defined as having everything nested
Global scope allows the developer to 'name' a complexType or simpleType so that the type can be reused in the XSD
Global scope element types should be direct child elements of <xs:schema>
Define a global scope for an element by:
<xs:schema>
// 1. Giving it a name
<xs:element name="address" type="addressType"/>
// 2. Creating a definition as a child under <xs:schema>
<xs:complexType name="addressType">
<xs:sequence>
...
</xs:sequence>
</xs:schema>