xml schema kurzpräsentation von herbert schlechta
TRANSCRIPT
XML Schema
Kurzpräsentation von Herbert Schlechta
DTD und die Nachteile
• keine Einschränkung auf den Inhalt• hoher Programmieraufwand um die korrekte
Dateneingabe zu erzwingen• DTDs sind nicht in XML definiert• kein Zugriff auf Schnittstellen wie DOM
XML Schema Aufgabe
Ein Schema beschreibt und definiert• die Bedeutung• die mögliche Verwendung• die Beziehungder Teile innerhalb eines XML-Dokuments.
Teile eines XML-Dokuments
• Datentypen• Elemente und deren Inhalte• Attribute und deren mögliche Werte• Entitäten und ihr Inhalt und Notation
Datentypenbaum
Einfache Datentypen
• xsd:string• xsd:boolean• xsd:dateTime• xsd:integer
Einfacher Datentype selbst erstellt
<xsd:element name=“preis”><xsd:simpleType>
<xsd:restriction base=“xsd:decimal”/><xsd:minExclusive value=“0”/><xsd:maxExclusive value=“100”/>
</xsd:restriction></xsd:simpleType>
</xsd:element>
Komplexer Datentyp<xsd:element name=“adresse”>
<xsd:complexType><xsd:sequence>
<xsd:element name=“strasse” type=“xsd:string”/>
<xsd:element name=“hausnummer” type=“xsd:string”/>
<xsd:element name=“plz” type=“xsd:string”/>
<xsd:element name=“ort” type=“xsd:string”/>
</xsd:sequence><xsd:attribute name=“vorhanden”
type=“xsd:boolean”/></xsd:complexType>
</xsd:element>
Benannte Datentype
<xsd:schema xmlns…….>…<xsd:element name=“preis”>
<xsd:simpleType><xsd:restriction base=“xsd:decimal”/>
<xsd:minExclusive value=“0”/><xsd:maxExclusive value=“100”/>
</xsd:restriction></xsd:simpleType>
</xsd:element>…</xsd:schema>
<xsd:element name=“neuerPreis” type=“preis”/>
Aufbau eines XML-Schemas<?xml version=“1.0” encoding=“ISO-8859-1”?><xsd:schema xmlns:xsd=http://www.w3.org/2001/XMLSchema>
<xsd:element name=“adresse”><xsd:complexType>
<xsd:sequence><xsd:element name=“strasse”
type=“xsd:string”/><xsd:element name=“hausnummer”
type=“xsd:string”/><xsd:element name=“plz”
type=“xsd:string”/><xsd:element name=“ort”
type=“xsd:string”/></xsd:sequence><xsd:attribute name=“vorhanden”
type=“xsd:boolean”/></xsd:complexType>
</xsd:element></xsd:schema>
Einfache Elemente
• hat kein Kindelement• hat keine Attribute
Komplexe Elemente
• alles was kein einfaches Element ist!!!
Kompositor 1
<xsd:complexType name=“adresse”><xsd:sequence>
<xsd:element name=“strasse” type=“xsd:string”/><xsd:element name=“hausnummer” type=“xsd:string”/><xsd:element name=“plz” type=“xsd:string”/><xsd:element name=“ort” type=“xsd:string”/>
</xsd:sequence></xsd:complexType>
Kompositor 2
<xsd:complexType name=“erreichbarkeit”><xsd:all>
<xsd:element name=“festnetz” type=“xsd:string”/><xsd:element name=“handy” type=“xsd:string”/><xsd:element name=“e-mail” type=“xsd:string”/><xsd:element name=“fax” type=“xsd:string”/>
</xsd:all></xsd:complexType>
Kompositor 3
<xsd:complexType name=“familienstand”><xsd:choice>
<xsd:element name=“ledig”/><xsd:element name=“verheiratet”/><xsd:element name=“geschieden”/><xsd:element name=“verwitwet”/>
</xsd:choice></xsd:complexType>
Wildcards
<xsd:complexType name=“notizen”><xsd:sequence>
<xsd:element name=“uhrzeit” type=“xsd:time”/>
<xsd:element name=“datum” type=“xsd:date”/>
<xsd:any processContents=“skip”></xsd:sequence><xsd:anyAttribute/>
</xsd:complexType>
Attribute 1
<xsd:complexType name=“notizen”><xsd:sequence>
<xsd:element name=“uhrzeit” type=“xsd:time”/>
<xsd:element name=“datum” type=“xsd:date”/>
</xsd:sequence><xsd:attribute name=“eingangszeit”
type=“xsd:string”/></xsd:complexType>
Attribute 2
<xsd:element name=“einband”><xsd:simpleType>
<xsd:restriction base=“xsd:string”/><xsd:enumeration value=“Gebundene
Ausgabe”/><xsd:enumeration
value=“Taschenbuch”/><xsd:enumeration
value=“Broschüre”/></xsd:restriction>
</xsd:simpleType></xsd:element>
Attribute 3
<xsd:element name=“ISBN”><xsd:simpleType>
<xsd:restriction base=“xsd:string”/><xsd:pattern value=“\d{1}-\d{4}-d{4}-\
d{1}”/></xsd:restriction>
</xsd:simpleType></xsd:element>
Attribute 4
<xsd:complexType name=“notizen”><xsd:sequence>
<xsd:element name=“uhrzeit” type=“xsd:time”/><xsd:element name=“datum” type=“xsd:date”/>
</xsd:sequence><xsd:attribute name=“vorhanden” type=“xsd:boolean”
use=“required”/></xsd:complexType>
Namensraum
Namensraum:www.verein.at
namebeitragadresse…
Namensraum:www.planung.at
projektbeitragleitung…
Namensraum:www.medien.at
zeitschriftbeitragverlag…
Namensraumdeklaration 1
Namensraum:www.verein.at
namebeitragadresse…
<xsd:schemaxmlns:ve=“www.verein.at”>xmlns:me=“www.medien.at”>
<ve.element name=“name”/><ve.element name=“beitrag”/>…<me.element name=“beitrag”/>
Namensraum:www.medien.at
zeitschriftbeitragverlag…
Namensraumdeklaration 2
Namensraum:www.verein.at
namebeitragadresse…
xsd:schema xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns:ve=“www.verein.at”>xmlns:me=“www.medien.at”>
<ve.element name=“name” type=“xsd:string”/><ve.element name=“beitrag” type=“xsd:integer/>…<me.element name=“beitrag” type=“xsd:string”/>
Namensraum:www.medien.at
zeitschriftbeitragverlag…