I am going to put my xml-schema explorations here:
(good thing needs time)
Will be heavily based on tutorial on xfront.com by Costello. Found this best ressource on this topic. Better than skonnard-chapters or wrox.xml.pro2 or even xml-schema 0-spec (this is 2nd best).
schema vs. dtd: more datatypes: 44+ vs. 10, can create your own datatypes xml syntax. Object-oriented'ish (extend or restrict a type) specify element content as being unique (keys on content) and uniqueness within a region multiple elements with the same name, but with different content define elements with nil content define substitutable elements schema can be used for, cause its xml
validate xml documents Automatic GUI generation Semantic Web??? Smart editor Automatic API generation elements:An element declaration can have a type attribute, or a anonymous complexType child element inlined, but it cannot have both a type attribute and a complexType child element.Facets: and or or? Patterns, enumerations => "or" them together All other facets => "and" them togetherElements with simple content can be declared using: build in type named user defined simple type anonymous, inlined user defined simple typeElements with child elements as content can be declared using: define child elements inlinedefine named complex type and use this in elementextend another complex typerestrict another complex type annotations<annotation> element is used for documenting the schema. <documentation> for humans <appinfo> for programs. <annotation> has no effect on Schema validation.global component: annotations may occur before and after any non-global components: annotations may occur only at the beginning non-global componentswe can put <annotation> allways after opening <xsd:element> in <xsd:element><xsd:annotation/></xsd:element>parameters of annotation-element: source (url for aditional documentation) and xml:lang, appinfo-element: only source regular expressions, too much
overviewtest applet subclassing complexType definitionsderive by extension -> extend the parent complexType with more elements. Uses <xsd:extension base="theBase"> elementderive by restriction -> create a type which is a subset of the base type. Uses <xsd:restriction base="theBase"> elementwith derive by restriction all elements of base type must be repeated, except of course when element should be omited !with derive by restriction number of occurences of element can be changed. (e.g. author element should appear maxOccurs 1 time, not unbounded.with derive by restriction element can only be omited if minOccurs in base complexType is 0 derive by restriction makes sense in context of type substitutability derivations of type can be prohibited. Uses attribute final=(#all|extension|restriction)[\list]
Terminology[list]Declaration vs. Definition declared components have a representation in an XML instance document (like elements and attributes)defined components have no representation in XML instance document, just in schema. (like type (simple, complex), attribute group definitions, model group definitions Global versus Localglobal element declarations/type definitions that are immediate children of <schema>local element declarations/type definitions are nested within other elements/typesonly global elements/types can be referenced (i.e., reused) element substitutionsubstitutionGroup: example: <xsd:element name="subway" type="xsd:string"/><xsd:element name="T" substitutionGroup="subway" type="xsd:string"/>. First element is head of substitution group. Note that existing elements does not have to be changed. Just a new element added. Its possible to use derived types(!) of type of head element in the substitution group elements. If type is the same as in head element, type attribute may be omited. Example above: type="xsd:string" can be omited. elements in the substitution group must be declared as global elementselement substitution can be blocked with block="substitution" attribute. Error does not pop up, when declaring substitution group in schema. It does pop up, when you try to substitute in instance document. <out_of_topic>WSAD.5-beta-xml tools does not support substitutionGroup in code completion. Tool is usefull.</out_of_topic> Attributesattributes can only have simple types (derived or build in). That's pretty clear: They can have no child elements.attributes of attribute element: name, type, use=(required|optional|prohibited), default or fixed.use attribute must be optional, if we use default or fixed attribute. attributes can be inlined as local components inside an element declaration or separately defined in an global attributeGroup. The attribute declarations always come last, after the element declarations.Elements with simple content and attribute must be declared as complex type. group elementfor grouping together element declarations, no attribute declarations groups must be defined (or declared) as global components. Can be referenced by local elements. syntax: <xsd:group (name|ref)/> Creating Listsuse xsd:list typenumber of items of list, datatype, data-range of list can be restricted (xsd:length value="?")we cannot create a list of lists or a list of complexTypesin instance document list-items are to be separated by whitespace further details about elementsxsd:choice is an exclusive-orelements with fixed/default parameter can be left empty. Validating parser will insert value.xsd:all means that included elements can appear in any order. maxOccurs value inside xsd:all elements must be "1". minOccurs can be "0" or "1"If a complexType uses <all> and it extends another type, then that parent type must have empty content.The <all> element cannot be nested within either <sequence>, <choice>, or another <all>The contents of <all> must be just elements. It cannot contain <sequence> or <choice>Union of simple types can be archieved with xsd:unionThe <any> element enables the instance document author to extend document with elements not specified by the schemaschemas which contain <xsd:any> are called extensible, other are called fixed.The <anyAttribute> element enables the instance document author to extend document with attributes not specified by the schema. schemas which contain <xsd:any> or <xsd:anyAttribute> are called extensible, other are called fixed. {*]Another term for extensible schemas is open content model. Flexibility is added with extensibility. Might have good or bad effects. There is a range of openness that a schema may support - anywhere from having instance documents where new elements can be inserted anywhere (global openness), to instance documents where new elements can be inserted only at specific locations (localized openness). In rapid changing market place there might be an urgent need for open schemas. Open schemas enable schema user to add innovative elements to their instance documents. Those changes can be included in next version of schema
xsd:any and xsd:anyAttribute have attribute namespace for restricting elements to be extended to certain namespaces. Default is ##any. Possible values: ##local or ##some_namespace. [ March 02, 2003: Message edited by: Axel Janssen ]
[ March 02, 2003: Message edited by: Axel Janssen ]