Datenmodell 2 XML Extended Markup Language Klemens Bhm
Datenmodell 2: XML ('Extended Markup Language’) Klemens Böhm Interoperable Informationssysteme - 1
Was ist XML? Motivation l XML-Konzepte l Einordnung und Bewertung von XML l Einleitung Konzepte Vergleich Weitere, zu XML gehörende Gliederungspunkte: l Zusammenfassungen semistrukturierter Datenbestände l Layout und Transformation l Erweiterbarkeit l Hyperlinks Klemens Böhm Interoperable Informationssysteme - 2
XML Dokumentklassen Einleitung Konzepte E-R Modell XML SGML Modell HTML Dokumenttyp Vergleich Schema für Materialverwaltung Datenbank, konform zum Schema Klemens Böhm z. B. Math. ML e ip +1= 0 n f (n) = S k Homepage von Hans Schek Dokumentinstanz k=1 Interoperable Informationssysteme - 3
XML Syntax <? xml version="1. 0"? > Einleitung Konzepte Vergleich <rezept> <zutaten id="x 1"> <zutat>Ei</zutat> <zutat>Mehl</zutat> </zutaten> <expertise/> <zutaten id="x 2"> <zutat>Salz</zutat> </zutaten> </rezept> Textuelle Darstellung Klemens Böhm rezept id=x 2 id=x 1 zutaten expertise zutaten zutat Ei Mehl Salz Graphische Darstellung "Elementbaum" Interoperable Informationssysteme - 4
Syntax zur Beschreibung von teilweise strukturierter Information: u Explizite Repräsentation der logischen Struktur von Dokumenten u (Alte Version der) W 3 C (World Wide Web Consortium) FAQ: "It's actually slightly misnamed. ” l Kernarchitektur für Hypermedien, genormt durch das W 3 C, aufbauend auf der Syntax, z. B. Annotationen, Stylesheets. l Dokumenttypen und Anwendungen aufbauend auf der Kernarchitektur: u Offen, u unternehmensintern, u kommerziell, l Norm des W 3 C. l Einleitung Konzepte Vergleich Was ist XML? Klemens Böhm Interoperable Informationssysteme - 5
Was ist XML? Tim Bray: "XML will be the ASCII of the Web basic, essential, unexciting" Einleitung Konzepte Vergleich Klemens Böhm Interoperable Informationssysteme - 6
Kernarchitektur Verwendung des Begriffs 'Architektur' unterscheidet sich von der gewohnten, z. B. Hardware-Architektur, Software-Architektur. l 'Architektur' bezeichnet hier die Menge der Zusammenhänge zwischen XML und verwandten Standards. Beispiele für derartige Zusammenhänge: u. XML-Namespace Recommendation verwendet im XML-Standard definierte Konstrukte, u. XSL Formatting Vocabulary ist XML-Namespace. l Einleitung Konzepte Vergleich Klemens Böhm Interoperable Informationssysteme - 7
Was ist HTML? HTML ist ein spezieller Dokumenttyp. l Elementtypen entsprechen (weitgehend) den Layout-Bestandteilen des Dokuments. l HTML-Dokumenttypdefinition, d. h. insbesondere zulässige Anordnung der Elemente, ist von untergeordneter Bedeutung. l Parsen und Validieren von HTMLDokumenten ist ebenfalls zweitrangig. l Einleitung Konzepte Vergleich Klemens Böhm Interoperable Informationssysteme - 8
Warum braucht man XML, verglichen mit HTML? Trennung zwischen logischer und Layout-Struktur führt zu höherer Flexibilität, insbesondere u unterschiedliche Darstellungsmöglichkeiten für unterschiedliche Benutzer und unterschiedliche Anforderungen, u bessere Strukturierungsmöglichkeiten. l Dokument mit logischem Markup enthält i. a. mehr Information, leichteres kooperatives Arbeiten bzw. bessere Dokumentation eigener Arbeitsschritte. l Konsistenz der Dokumente: u 'intra-document consistency', u 'inter-document consistency'. l Einleitung Konzepte Vergleich Klemens Böhm Interoperable Informationssysteme - 9
XML Entwicklung Einleitung Konzepte Jul Nov Mär 96 96 97 Apr Aug Okt Feb Apr Aug Apr Q 2 Q 1 97 97 97 98 98 98 99 99 01 Vergleich Klemens Böhm "SGML-Subset" Arbeitsgruppe (ERB) Erster öffentlicher XML-Entwurf Microsoft veröffentlicht CDF-DTD (Dateiformat für Push-Technologie) Netscape erkennt XML an Sun Solaris 2. 6 mit XML Dokumentation Microsoft IE 4. 0 mit XML Active. X-Control XML Version 1. 0 Math. ML, Mozilla 5. 0 mit XML Reorganisation der W 3 C-XML-WG Microsoft IE 5. 0 mit XSL Microsoft Office mit HTML/XML XML-Schema Interoperable Informationssysteme - 10
Ziele des XML Entwurfs (1/2) Einleitung Konzepte Vergleich Ziele beim Entwurf von XML, nicht Ziele der Modellierung mit XML. 1 XML soll sich im Internet auf einfache Art und Weise nutzen lassen. 2 XML soll ein breites Spektrum von Anwendungen unterstützen. 3 XML soll zu SGML kompatibel sein. 4 Es soll einfach sein, Programme zu schreiben, die XML-Dokumente verarbeiten. 5 Die Zahl optionaler Merkmale in XML soll minimal sein, idealerweise Null. Klemens Böhm Interoperable Informationssysteme - 11
Ziele des XML Entwurfs (2/2) XML-Dokumente sollen für Menschen lesbar und angemessen verständlich sein. 7 Der XML-Entwurf sollte zügig abgefasst werden. 6 Einleitung Konzepte Vergleich (D. h. die Erstellung der XML-Spezifikation. ) Der Entwurf von XML soll formal und präzise sein. 9 XML-Dokumente sollen leicht zu erstellen sein. 10 Knappheit von XML-Markup ist von minimaler Bedeutung. Wie wird Ziel X von XML berücksichtigt? 8 Klemens Böhm Interoperable Informationssysteme - 12
XML Konzepte l l Einleitung Konzepte - Unicode - Basics l l l - XML Proc. - Elemente - Attribute - Pis - Entities - Notations - Namespaces - XMLSchema Vergleich l l Unicode, Dokumentinstanz, DTD wohlgeformt vs. gültig, XML-Processor, XML-Applikation syntaktische Konstruktionen in XML: u Elemente, u Attribute, u Processing Instructions, u Entitäten, u Notationen, XML Namensräume, XML-Schema Mechanismus. Klemens Böhm Interoperable Informationssysteme - 13
Unicode 2. 1 (1/4) l l Einleitung l Konzepte - Unicode - Basics l - XML Proc. l - Elemente l - Attribute - PIs l - Entities l - Notations l - Namespaces l - XMLSchema l Characters in XML sind Nummern. Festlegung der Abb. von Nummern auf Chars: Unicode, Unicode ist Teilmenge des ISO-Standards ISO/IEC 10646 -1: 1993 (Universal Multiple-Octet Coded Character Set (UCS)) ca. 65. 000 mögliche Zeichen in 16 Bit 38. 887 belegte, ca. 18. 000 unbelegte Zeichenpositionen untere 127 Zeichen binärkompatibel zu ASCII jedes Zeichen ist auf genau eine Weise kodiert Erweiterung um 917. 504 Zeichen möglich unterstützt 25 lebende Sprachen Unicode kodiert keine Fonts. Jede konforme Anwendung von XML ist eine Anwendung von Unicode. Vergleich Klemens Böhm Interoperable Informationssysteme - 14
Unicode 2. 1 (2/4) Es gibt mehrere Möglichkeiten, 16 -Bit Nummern zu speichern. l UTF-16 speichert jede 16 -Bit Zahl unter Verwendung von 16 Bits. UTF-8 speichert die ersten 127 Characters (ASCII-Zeichen) mit 7 Bits und verwendet zwei bis fünf Bytes für die restlichen Characters. l XML Spezifikation legt fest, dass XML Unicode verwendet. 'All XML processors must accept the UTF-8 and UTF-16 encodings of ISO 10646 …’. l Dokumente, die mit UTF-16 kodiert sind, müssen mit spezieller Bit-Sequenz beginnen. l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 15
Unicode 2. 1 (3/4) http: //www. unicode. org/unicode/standard/principles. html l The Unicode Standard defines codes for characters used in the major languages written today. Scripts include Latin, Greek, Cyrillic, Armenian, Hebrew, Arabic, Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada, Malayalam, Thai, Lao, Georgian, Tibetan, Japanese Kana, the complete set of modern Korean Hangul, and a unified set of Chinese/Japanese/Korean (CJK) ideographs. Many more scripts and characters are to be added shortly, including Ethiopic, Canadian Syllabics, Cherokee, additional rare ideographs, Sinhala, Syriac, Burmese, Khmer, and Braille. l The Unicode Standard also includes punctuation marks, diacritics, mathematical symbols, technical symbols, arrows, dingbats, etc. It provides codes for diacritics, which are modifying character marks such as the tilde (~), that are used in conjunction with base characters to encode accented or vocalized letters (ñ, for example). In all, the Unicode Standard provides codes for nearly 39, 000 characters from the world's alphabets, ideograph sets, and symbol collections. l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 16
Unicode 2. 1 (4/4) Verwendung anderer Character Encodings ist möglich, XML Processor muss sie aber nicht unterstützen. l Spezifikation erfolgt mit dem encoding. Attribut. l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 17
Übersicht: XML Dokument Kommentar, Arbeitsanweisung, Zeichenreferenz Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente Prolog mit Dokument Typ-Deklaration Dokument Typ-Definition (DTD) Element, Attribut, Entität, Parameterentitätsreferenz Externe DTD Teilmenge Konditionale Abschnitte, beliebige Parameterentitätsreferenz - Attribute - PIs - Entities - Notations - Namespaces Dokument Element Dokument mit Namensraumdeklaration Start-Tag, Ende-Tag, leeres-Element-Tag, PCDATA, CDATA Abschnitte, Entitätsreferenzen - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 18
Hamlet: Dokumentinstanz <? xml version="1. 0"? encoding="ISO-8859 -1"? > <!DOCTYPE play PUBLIC "-//Free Text Project//DTD Play//EN" SYSTEM "http: //www. shakespeare. org/hamlet. dtd"> <play> <title>The Tragedy of Hamlet, Prince of Denmark</title> Einleitung <fm> <p>SGML markup by Jon Bosak, 1992 -1994. </p> Konzepte <p>XML version by Jon Bosak, 1996 -1997. </p> <p>This work may be freely copied and distributed worldwide. </p> - Unicode </fm> - Basics <personae> - XML Proc. <title>Dramatis Personae</title> <persona>CLAUDIUS, king of Denmark. </persona> - Elemente <persona>HAMLET, son to the late, and nephew to the present king. - Attribute </persona> </personae> - PIs <scndescr>SCENE Denmark. </scndescr> - Entities <playsubt>HAMLET</playsubt> - Notations <act> <title>ACT I</title> <scene> - Name<title>SCENE I. Elsinore. A platform before the castle. </title> spaces <stagedir>FRANCISCO at his post. Enter to him BERNARDO</stagedir> - XML<speech><speaker>BERNARDO</speaker> Schema <line>Who's there? </line></speech>. . . Vergleich Klemens Böhm Interoperable Informationssysteme - 19
Hamlet: Elementbaum Dokument. Element Einleitung Konzepte title - Basics - Elemente "act" ist enthalten in "play" Element - Unicode - XML Proc. play fm The Tragedy of Hamlet, Prince of Denmark personae Dramatis Persona p. . . - Namespaces SGML markup. . . persona p . . . worldwide acttitle Scene Denmark Act I CLAUDIUS HAMLET scene Pfad scenetitl e stagedir Scene I. . . - Entities - Notations playsubt hamlet title - Attribute - PIs scenedescr . . . speech speaker FRANCISCO. . . BERNARDO line Who's there? - XMLSchema Vergleich Visual Pattern Builder Klemens Böhm Interoperable Informationssysteme - 20
Hamlet: DTD <!-- DTD for Shakespeare Jon Bosak 1994. 03. 01, 1997. 01. 02 --> <!ELEMENT play (title, fm, personae, scndescr, playsubt, induct? , prologue? , act+, epilogue? )> <!ELEMENT title (#PCDATA)> Einleitung <!ELEMENT fm (p+)> Konzepte <!ELEMENT personae (title, (persona | pgroup)+)> - Unicode <!ELEMENT pgroup (persona+, grpdescr)> - Basics <!ELEMENT induct (title, subtitle*, - XML Proc. scene+|(speech|stagedir|subhead)+))> - Elemente <!ELEMENT act (title, subtitle*, prologue? , scene+, epilogue? )> - Attribute <!ELEMENT scene (title, subtitle*, - PIs (speech | stagedir | subhead)+)> - Entities <!ELEMENT prologue (title, subtitle*, (stagedir | speech)+)> - Notations <!ELEMENT epilogue (title, subtitle*, (stagedir | speech)+)> - Name<!ELEMENT speech (speaker+, (line | stagedir | subhead)+)> spaces <!ELEMENT line (stagedir | #PCDATA)+> - XML. . . Schema Vergleich Klemens Böhm Interoperable Informationssysteme - 21
Well-Formed vs. Valid wohlgeformt (well-formed) ein Dokument besitzt geordnete syntaktische Eigenschaften, die im folgenden vorgestellt werden, l gültig (valid) Ein Dokument ist wohlgeformt und folgt einem a priori gegebenen Schema, formalisiert in einer Dokumenttypdefinition (DTD). l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 22
Well-Formedness Einleitung Konzepte - Unicode Illustration, dass Dokumente, die well-formed sind, vollständig markiert sein müssen: l Nicht vollständig markiertes Dokumentfragment: <A><B>pipapo<C>hello world</C></A> - Basics - XML Proc. - Elemente l Zwei mögliche Strukturen: - Attribute - PIs - Entities - Notations - Namespaces pipapo hello world - XMLSchema pipapo hello world Vergleich Klemens Böhm Interoperable Informationssysteme - 23
XML Processor, Application XML Processor - Modul, das Zugriff auf Inhalt und Struktur von XML-Dokumenten ermöglicht. l Applikation Modul, das den XML Processor verwendet. l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 24
XML Processor, Application Einleitung Konzepte - Unicode Aufruf für XML-Dok. - Basics - XML Proc. - Elemente - Attribute XML-Processor (XML-Engine) - PIs - Entities - Notations Callback. Methoden ("User Exits”) DOMMethoden - Namespaces . . . - XMLSchema Vergleich Bsp. fuer diese Aufteilung: Workflow aus Bestellung z: usersboehmWindowstempSamplesexpatelements. c … xmlparse. h Klemens Böhm MM-Tool 1 MM-Tool 2 Interoperable Informationssysteme - 25
l Darstellung der logischen Dokumentstruktur PCDATA = parseable character data, Kein anderer terminaler Typ fuer Content fuer Strings in Attributen gibt es nur den Typ CDATA Einleitung Konzepte - Unicode - Basics - XML Proc. l l l - Elemente - Attribute - PIs l - Entities l - Notations - Namespaces l - XMLSchema Vergleich l Tags begrenzen Elemente, <paper> hierarchisch oberstes Element <abstract> heisst Dokumentelement, Interoperable Syntaktisch zulässige Tag-Namen information haben die Struktur systems require [letter][letter 0 -9. : -_]*. . . Tags sind "case-sensitive", </abstract> Jedes geöffnete Tag <body> muss wieder geschlossen werden. <acknowl/> Leeres Element Tags dürfen einander nicht Markup such überlappen; nicht erlaubt z. B. : as <keyword>, . . . <A>…<B>…</A>…</B> </body> </paper> Tags leerer Elemente haben besondere Syntax. Klemens Böhm Interoperable Informationssysteme - 26
CDATA l Einleitung Konzepte - Unicode - Basics l - XML Proc. - Elemente - Attribute - PIs - Entities l l - Notations - Namespaces - XMLSchema l CDATA-Abschnitte dürfen überall vorkommen, wo Character Data vorkommen darf, CDATA wird nicht vom Parser bearbeitet, Entitäten und Tags werden nicht erkannt, ]]> beendet den Abschnitt, oft verwendet für Codebeispiele, z. B. XML-in-XML. . <script> <![CDATA[ if ( a < b ) { &subroutine(a, b) } else { &subroutine(b, a) } ]]> </script>. . . Vergleich Klemens Böhm Interoperable Informationssysteme - 27
DTD-Deklarationen Externe DTD Deklaration Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema <? xml version="1. 0" encoding="ISO-8859 -1"? > <!DOCTYPE test PUBLIC "-//Test AG//DTD test V 1. 0//EN" SYSTEM "http: //www. test-ag. de/test. dtd"> <test> "test" ist das Dokumentelement </test> Interne DTD Deklaration <!DOCTYPE test [ <!ELEMENT test EMPTY> ]> <test/> Gemischte Nutzung <!DOCTYPE test SYSTEM "http: //www. test-AG. de/test. dtd" [ <!ENTITY hallo "hallo welt"> ]> Internal DTD Subset <test>&hallo; </test> Vergleich Klemens Böhm Interoperable Informationssysteme - 28
DTD-Deklarationen (2) Einleitung Konzepte - Unicode - Basics - XML Proc. Erläuterungen: l Gemischte Nutzung – externe DTD, aber proprietäre Entity-Definition l encoding - Character Encoding l Attribut nicht erforderlich für ASCII, da Subset von UTF-8 - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 29
Elementdeklaration l Einleitung (SGML - Inclusions) Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute Inhaltsmodell - regulärer Ausdruck, der Aufbau des direkten Inhalts spezifiziert. l Syntax der Elementdeklaration: l <!ELEMENT Elementname (Inhaltsmodell)> - PIs - Entities - Notations - Namespaces Elementdeklaration legt fest, wie der direkte Inhalt eines Elements aufgebaut ist. l Beispiel: <!ELEMENT aufsatz (einleit, hauptteil, schluss)> - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 30
Elementdeklaration (1/2) l Elementinhalt <!ELEMENT beispiel (a)> Einleitung Konzepte l <!ELEMENT beispiel (#PCDATA)> <!ELEMENT beispiel (#PCDATA|a)*> - Unicode - Basics - XML Proc. - Elemente l - Attribute - Notations - Namespaces Leeres Element <!ELEMENT beispiel EMPTY> - PIs - Entities Gemischter Inhalt ("mixed content") l Element mit beliebigem Inhalt <!ELEMENT beispiel ANY> 'beliebiger Inhalt'- muss vorher schon deklariert worden sein. - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 31
Elementdeklaration (2/2) l Einleitung Konstruktoren: u Sequenz <!ELEMENT beispiel u Alternative Konzepte <!ELEMENT beispiel - Unicode - Basics - XML Proc. l - Elemente - Attribute - PIs Occurrence Indicators: u Optional (Null- oder einmal) <!ELEMENT beispiel (a)? > und wiederholbar (beliebig oft) <!ELEMENT beispiel (a)*> - Notations u Notwendig und wiederholbar (mindestens einmal) <!ELEMENT beispiel (a)+> - Namespaces Vergleich (a | b)> u Optional - Entities - XMLSchema (a, b)> l Inhaltsmodelle können mit Klammern kombiniert werden. Klemens Böhm Interoperable Informationssysteme - 32
Attribute Jedes Element kann mit (beliebig vielen) Attributen versehen sein, l Attribut-Belegungen sind normal im Start-Tag enthalten, l Beispiel: l Einleitung Konzepte - Unicode <!ELEMENT abstract (text)> <!ATTLIST abstract author #REQUIRED> - Basics - XML Proc. - Elemente - Attribute <abstract author='weber'> Das ganze Leben ist ein Quiz</abstract> - PIs - Entities - Notations - Namespaces - XMLSchema CDATA l Attribute sind eine von mehreren Möglichkeiten, zusätzliche Information mit Elementen in Verbindung zu bringen. Bsp. : <!ELEMENT abstract (author, text)> <!ELEMENT author (#PCDATA)> Vergleich Klemens Böhm Interoperable Informationssysteme - 33
Wozu braucht man Attribute? Es existieren Typen für Attribute. l Das Dokument besteht aus weniger Elementen. l Bessere Lesbarkeit, Übersichtlichkeit. l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 34
Attributdeklaration l Syntax der Attributdeklaration: <!ATTLIST Elementname Attributname Typ Vorgabe …> l Mögliche Vorgaben: u Notwendiges Attribut: u Optionales Attribut: u Festes Attribut: (d. h. DTD legt den Attributwert bereits fest). Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema #REQUIRED #IMPLIED #FIXED "wert" Vergleich Klemens Böhm Interoperable Informationssysteme - 35
Attribute: Typen (1/5) Einleitung Konzepte - Unicode - Basics - XML Proc. l CDATA u Zeichenkette (mit Entitätsersetzung) u <!ATTLIST beispiel HREF CDATA #REQUIRED> l Aufzählungstyp u Token aus vorgegebener Menge, evtl. Defaultwert u <!ATTLIST beispiel auswahl (ja|nein|vielleicht) "ja"> - Elemente - Attribute Elementname Attributname - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 36
Attribute: Typen (2/5) ID, IDREF u Attribut vom Typ ID ist innerhalb eines Dokuments eindeutig, u IDREF ist eine Referenz auf eine ID, u Parser prüft referentielle Integrität, u keine Einschränkung des Typs, kein reftype, u <!ATTLIST beispiel indent ID #IMPLIED referenz IDREFS #IMPLIED> l NAME, NAMES Name bzw. Namen, beginnend mit Letter, _ oder : l NMTOKEN, NMTOKENS u Name bzw. Namen, ausschliesslich NAME-Chars u <!ATTLIST variablen beispiel NMTOKENS #REQUIRED> l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 37
Arbeitsanweisung/ Processing Instruction (PI) - Attribute PI sind nicht Teil des Dokumenttextes. l PIs werden an Applikation durchgereicht. l PI beginnt mit Target, d. h. Identifier der Applikation, z. B. php - PIs l l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Entities - Notations - Namespaces - XMLSchema Vergleich <? xml version="1. 0" encoding="ISO-8859 -1" standalone="no" ? >. . . <? php echo $title; ? >. . . PI-Targets werden mit dem XML Notation Mechanismus deklariert (wird später besprochen). l <? xml ist reserviert, l <? xml erlaubt Erkennung der Zeichenkodierung. z: usersboehm\WindowstempSamplesInternetxml_validatorvalidate. htm z: usersboehm\WindowstempSamplesxmlexample_filesbooks. xml z: usersboehmWindowstempSamplesexpatxmlparse. h Klemens Böhm Interoperable Informationssysteme - 38
Zeichenreferenzen und Kommentare l Einleitung Konzepte - Unicode l - Basics - XML Proc. l - Elemente - Attribute l - PIs - Entities - Notations - Namespaces - XMLSchema l Zeichenreferenzen können beliebige Unicode-Zeichen identifizieren, Beispiel: Zeichen, die auf der Tastatur fehlen, Zeichenreferenzen werden sofort expandiert, Kommentare sind überall erlaubt, nicht aber vor der XML-Processing Instruction (<? xml. . . ) Kommentare dürfen keine "--" enthalten. û &#x. FB; und © stehen für dasselbe Zeichen. . . <!-Ein Kommentar darf beliebige Zeichenfolgen wie <tagname> oder &entity; enthalten -->. . . Vergleich Klemens Böhm Interoperable Informationssysteme - 39
Attribut-Normalisierung Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs Bevor ein Attributwert überprüft bzw. an eine Applikation weitergegeben wird, muss der XML Processor ihn normalisieren: l Character-Referenz auflösen, l Replacement-Text einer Entity-Referenz rekursiv abarbeiten. - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 40
Logische vs. physische Dokumentstruktur l Einleitung l Konzepte - Unicode - Basics l - XML Proc. - Elemente l - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich l l Logische Dokumentstruktur ist die Struktur, die mit Hilfe von Markup explizit gemacht wird, physische Dokumentstruktur Verteilung des Dokuments auf Files, physische Units heissen im XML-Kontext externe Entities. Eine Entity wird anhand ihres Namens identifiziert, Entity-Name hat gleichen Aufbau wie Attribut vom Typ NAME. physische Dokumentstruktur ist i. a. weitgehend orthogonal zur logischen. Entities: Wichtig zum Verstehen der Standards, die auf XML aufsetzen, z. B. verwendet XLink Parameter Entities. Klemens Böhm Interoperable Informationssysteme - 41
Externe Entities - Beispiel Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces … <!ENTITY chapter 1 SYSTEM "http: //www. boehm-ag. com/ chapters/chap 1. xml"> <dissertation> <intro>This work is a brilliant piece of work …</intro> &chapter 1; &chapter 2; <conclusion>This work is destined to become a classic. </conclusion> … http : //www. boehm-ag. com/ chapters/chap 1. xml <chapter> Das ganze Leben ist ein Quiz, und wir sind nur die Kandidaten… </chapter> - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 42
Physische Partitionierung von Dokumenten - Motivation Grösse des Files, l organisationelle Aspekte, l Nicht-XML Resourcen, z. B. Binaries, l Wiederverwertung von DTD-Fragmenten. l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 43
Entities - Klassifizierung l <!ENTITY hallo "hallo welt">. . . <test>&hallo; </test> Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente Internal Entities vs. External Entities, Beispiel für Internal Entity: Parsed Entities vs. Unparsed Entities, l General Entities vs. Parameter Entities. l - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Dimensionen sind z. T. orthogonal zueinander. Z. B. kann External Entity entweder Parsed Entity oder Unparsed Entity sein. Vergleich Klemens Böhm Interoperable Informationssysteme - 44
Internal Entities vs. External Entities physische Units im XML-Kontext; Document Entity 'Wurzel’-Entity, Hub-Dokument Einstiegspunkt für XML Processing l Internal Entities kein separates physisches Objekt, Deklaration der Entity enthält ihren Inhalt; Motivation: u Übersichtlichkeit, u weniger Code, Wiederverwertbarkeit, u weniger Elemente (wird weiter hinten illustriert). l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 45
Externe Entities - Differenzierung Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities Differenzierung zwischen Parsed und Unparsed Entities: l Parsed Entity-Referenz wird aufgelöst, Entity-Inhalt ist Teil des Dokuments, l Unparsed Entity muss kein XML enthalten. (Weitere Erläuterungen folgen. ) - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 46
Entity Deklarationen - Beispiele l Einleitung Konzepte - Unicode - Basics - XML Proc. Deklaration einer internen Entity: <!ENTITY Pub-Status "This is a pre-release of the specification. "> Unterschied: Interne Entity l Deklaration externer Entities: enthält Text, aber keinen u. Parsed Entity: SYSTEM-Identifier. <!ENTITY oh - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich SYSTEM "http: //www. tty. com/bplate/OH. xml"> u. Unparsed Entity: <!ENTITY hatch-pic SYSTEM ". . /grafix/OH. gif" NDATA gif> SYSTEM-Identifier identifiziert Position relativ zur Entity-Deklaration. Klemens Böhm Interoperable Informationssysteme - 47
General Entities vs. Parameter Entities General Entity Verwendung im Dokumentinhalt, l Parameter Entities Parsed Entity zur Verwendung in der DTD. l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 48
Beispiele l Type <key>less-than</key> (&#x 3 C; ) to save options. This document was prepared on &docdate; and is classified &security-level; . Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations Character-Referenzen und Entity-Referenzen: l Parameter-Entity Referenz: <!-- declare the param. entity "ISOLat 2". . . --> <!ENTITY % ISOLat 2 SYSTEM "http: //www. xml. com/isolat 2 -xml. entities" > <!--. . . now reference it. --> %ISOLat 2; Unterschiedliche Syntax Character-Referenzen und Entity-Referenzen sowie Parameter-Entity Referenz http: //www. w 3. org/TR/WD-html 40 -970708/sgml/entities. html - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 49
Parameter-Entitäten Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations Verwendbar nur innerhalb der DTD, l Namensraum unterscheidet sich von dem normaler Entitäten, l Ziele: u Modularisierung von DTDs, u weniger Elemente. l - Namespaces <!ENTITY % firmenweit SYSTEM "http: //foo. com/std. ent" > %firmenweit; <!ENTITY % adresse "(name, strasse, plz)" > <!ELEMENT kunde %adresse; > <!ELEMENT lieferant %adresse; > - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 50
Konditionale Abschnitte Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute Teile einer DTD können ein- und ausgeblendet werden l Üblicher Mechanismus hierfür: Parameter. Entitäten. l - PIs - Entities - Notations - Namespaces - XMLSchema <!ENTITY % draft 'INCLUDE' > <!ENTITY % final 'IGNORE' > <![%draft; [ <!ELEMENT book (comments*, title, body, suppl? )> ]]> <![%final; [ <!ELEMENT book (title, body, suppl? )> ]]> Vergleich Klemens Böhm Interoperable Informationssysteme - 51
Well-Formedness (Fortsetzung) Zu einem Dokument muss keine DTD gehören. l Dokument 'ohne DTD’ muss bestimmte Bedingungen erfüllen, insbesondere muss die Struktur eindeutig sein: u Dok. sollte 'Standalone Document Declaration’ (SDD) enthalten: <? xml version="1. 0" standalone="yes"? > <foo> <bar>. . . <blort/>. . . </bar> </foo> u Dokument hat genau eine Wurzel, u Tag Omission ist nicht erlaubt, kein überlappender Markup, alle Attributwerte in Anführungszeichen, Attributwerte per Default vom Typ CDATA, u leere Elemente müssen als solche erkennbar sein, u kein isolierter Markup, z. B. '<’ anstatt '<'. l Entitäten, d. h. die externen Files, müssen wohlgeformt sein. l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 52
Notations Notationen Mechanismus, um mit einem Namen u das Format von Unparsed Entities, u das Format von Elementen mit einem Notation-Attribut oder u die Anwendung, auf die sich eine Processing Instruction bezieht, zu identifizieren. l Beispiel für Element mit Notation-Attribut: Element, dessen Inhalt Post. Script oder VRML ist. Genaueres später. l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 53
Notations Notationen können die Semantik von nicht-analysierten Entitäten, Arbeitsanweisungen und Attributen festlegen, l Beispiel: <!NOTATION MPEG SYSTEM "c: programmempeg. exe"> Notation Identifier l Einleitung Konzepte - Unicode - Basics <!ENTITY löwe "leo. mpg" NDATA MPEG> - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Anwendungen: Multimedia-Elemente, Typsysteme. l Zu jeder Unparsed Entity gehört eine Notation, identifiziert durch einen Namen. l Ein XML Processor muss einer Anwendung die Identifier der Entity und den Notationsnamen verfügbar machen. l Der Notation Identifier wird der Anwendung mit der Notation Declaration verfügbar gemacht. l Klemens Böhm Interoperable Informationssysteme - 54
Attribute: Typen (3/5) l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich ENTITY, ENTITIES u Verwendung: Pointer auf Daten eines speziellen (Medien-)Typs ausserhalb der aktuellen Entity u Attributwert muss Name einer in der DTD deklarierten Unparsed Entity sein. u Parser versucht nicht, Entity aufzulösen. u Beispiel: <!NOTATION vrml PUBLIC "VRML 2"> <!ENTITY Antarctica SYSTEM "http: //www. antarc. net" NDATA vrml> <!ATTLIST World src ENTITY #REQUIRED> <World src='Antarctica'> Element- Attributtypname Klemens Böhm Interoperable Informationssysteme - 55
Attribute: Typen (4/5) l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich NOTATION u Attribut dieses Typs ist nur sinnvoll für Elemente mit 'speziellem' Inhalt, u Attributwert muss Name einer deklarierten Notation sein. u Verwendung: Typisierte Attribute, Multimedia-Attribute, u Beispiel: <!NOTATION vrml PUBLIC "VRML 2"> <!NOTATION ps PUBLIC "Post. Script Level 3"> <ATTLIST Rendered In NOTATION (ps|vrml) #IMPLIED> <Rendered In='ps'> gsave 112 75 moveto 112 300 lineto showpage grestore </Rendered> Klemens Böhm Interoperable Informationssysteme - 56
Attribute: Typen (5/5) Einleitung Konzepte - Unicode - Basics - XML Proc. Was ist also der Unterschied in der Verwendung von Attributen vom Typ ENTITY und vom Typ NOTATION? Spezieller Content ausserhalb bzw. innerhalb aktueller Entity. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 57
Namespaces Motivation: u Element- und Attributnamen ("Markup Vocabulary”) mit allgemeiner Gültigkeit, Beispiel: Library of Congress Subject Headings (LCSH) u Anwendung basiert auf allgemeiner Interpretation dieser Namen, u ein XML-Dokument soll Markup Vocabulary aus mehreren 'Dictionaries’ enthalten können. (Erinnerung: XML-Dokument muss keine DTD haben. ) l Namespaces zur Vermeidung von Namenskonflikten. l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 58
Beispiel für die Verwendung von Namespaces (2/2) <x xmlns: edi='http: //ecommerce. org/schema'> <!-- the "edi" prefix is bound to Namespace http: //ecommerce. org/schema for the "x" element and contents --> <edi: price units='Euro'>32. 18</edi: price> <!-- the 'price' element's namespace is http: //ecommerce. org/schema --> Qualified </x> Name l <x xmlns: edi='http: //ecommerce. org/schema'> <!-- the 'tax. Class' attribute's namespace is http: //ecommerce. org/schema --> <line. Item edi: tax. Class="exempt">Baby food </line. Item> </x> l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Namespace Prefix stellt Verbindung zum Namespace her. Klemens Böhm Interoperable Informationssysteme - 59
Namespaces - Erläuterung XML Namespace ist im wesentlichen eine Menge von Namen. u Genauer: keine Menge – globale und lokale Variablen. u Lokale Variablen: unterschiedliche Namespaces für Attributnamen unterschiedlicher Elementtypen Beispiel: TITLE - Section, TITLE – Author Attribut besteht aus Namespace-Präfix und lokalem Teil. l URI identifiziert Namespace. l Namespace-Definition muss kein Schema in einer formalen Sprache sein. l Es kann sinnvoll sein, dass ET-Name aus Namespace, Attributname jedoch nicht. price - brutto oder netto, keine weiteren Aspekte. l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 60
Namensräume Bestellung Einleitung B: Überweisung L: Buch Konzepte B: Sorte="DM" - Unicode - Basics - XML Proc. L: Titel L: ISBN L: Autor Neuromancer 3 -80770309 -8 Gibson, William B: Betrag B: Signatur B: Datum 49, 00 80 X 8. . . F 915 1998 -11 -09 - Elemente - Attribute - PIs - Entities - Notations - Namespaces <bestellung - XMLSchema xmlns: B xmlns: L = = "http: //bank. de/schema/" "http: //buch. de/schema/"> Vergleich Klemens Böhm Interoperable Informationssysteme - 61
Namespaces – Erläuterung (2) Namespace Defaulting Default Namespace gibt für alle Elemente ohne Präfix im Teilbaum und für Element, das Namespace Deklaration enthält, l Scoping - Namespace Definition kann überschrieben werden in 'innerem' Element. l Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema Vergleich Klemens Böhm Interoperable Informationssysteme - 62
XML-Dokument mit Namespace Einleitung Konzepte - Unicode - Basics - XML Proc. - Elemente - Attribute - PIs - Entities - Notations - Namespaces - XMLSchema <? xml version="1. 0"? > <portfolio xmlns: dt="urn: schemas-microsoftcom: datatypes"> <stock exchange="nyse"> <name>zacx corp</name> <symbol>ZCXM</symbol> <price dt: dt="number">28. 875</price> </stock> <stock exchange="nasdaq"> <name>zaffymat inc</name> <symbol>ZFFX</symbol> <price dt: dt="number">92. 250</price> </stock> <stock exchange="nasdaq">. . . </stock> </portfolio> Vergleich Klemens Böhm Interoperable Informationssysteme - 63
Einleitung Konzepte … - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include Mängel von XML-DTDs/ neue Anforderungen an XML-Schema Keine Erweiterbarkeit – wünschenswert: u Erweiterbarkeit des Inhaltsmodells, u Einschränkung des Inhaltsmodells. l Möglichkeit der Validierung: u Datentypen und Wertebereiche, u Integritätsbedingungen, u getypte Links, l Modularität, die über die von DTDs hinausgeht: Scoping. l • Abgel. Typen • Unique. und Keys • XML-Data Vergleich Klemens Böhm Interoperable Informationssysteme - 64
XML-Schema Einleitung Konzepte … - Namespaces - XMLSchema • Einleitung • Basics Idee: Schema ist XML-Dokument. l Vergleichbar mit Data Dictionary Relationen zur Verwaltung der Schemainformation. l Aktueller Status (März 2001): W 3 C Proposed Recommendation. l • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Vergleich Klemens Böhm Interoperable Informationssysteme - 65
Inhaltsmodell mit XML-Schema Einleitung Konzepte … l <xsd: complex. Type name="Address"> <xsd: sequence> <xsd: element name="name" type="xsd: string"/> <xsd: element name="street" type="xsd: string"/> <xsd: element name="city" type="xsd: string"/> <xsd: element name="state" type="xsd: string"/> <xsd: element name="zip" type="xsd: decimal"/> </xsd: sequence> <xsd: attribute name="country" type="xsd: NMTOKEN" fixed="US"/> </xsd: complex. Type> - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Vergleich Beispiel: l Erläuterungen: u Typdefinition und Elementdeklaration getrennt. u Lokale Typen (lokale Typen mit gleichem Namen anderswo möglich) u (Sinnvolle) Beispiele für leere Elemente. Klemens Böhm Interoperable Informationssysteme - 66
Einleitung Konzepte … - Namespaces - XMLSchema Typdefinition und Elementdeklaration l Beispiel: <xsd: schema xmlns: xsd="http: //www. w 3. org/2001/XMLSchema">. . . <xsd: element name="purchase. Order" type="Purchase. Order. Type"/> • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys <xsd: element name="comment" type="xsd: string"/> <xsd: complex. Type name="Purchase. Order. Type"> <xsd: sequence> <xsd: element name="ship. To" type="Address"/> <xsd: element name="bill. To" type="Address"/> <xsd: element ref="comment" min. Occurs="0"/> <xsd: element name="items" type="Items"/> </xsd: sequence> <xsd: attribute name="order. Date" type="xsd: date"/> </xsd: complex. Type> • XML-Data Vergleich Klemens Böhm Interoperable Informationssysteme - 67
Konzepte Typdefinition und Elementdeklaration (2) … l Einleitung - Namespaces - XMLSchema • Einleitung Erläuterungen: u Globale Elementtypen. u Occurrence-Anzahl für comment l Wie ist purchase. Order-Element aufgebaut? • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Vergleich Klemens Böhm Interoperable Informationssysteme - 68
Komplexes Inhaltsmodell Einleitung Konzepte … l <xsd: complex. Type name="Items"> <xsd: element name="item" min. Occurs="0" max. Occurs="*"> <xsd: complex. Type> <xsd: sequence> <xsd: element name="product. Name" type="xsd: string"/> <xsd: element name="price" type="xsd: decimal"/> <xsd: element ref="comment" min. Occurs="0"/> <xsd: element name="ship. Date" type="xsd: date" min. Occurs='0'/> <xsd: attribute name="part. Num" type="Sku"/> </xsd: sequence> </xsd: complex. Type> </xsd: element> </xsd: complex. Type> - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys Beispiel: l Erläuterungen: u Default: Genau ein Vorkommen, u Implizite Typdefinition. • XML-Data Vergleich Klemens Böhm Interoperable Informationssysteme - 69
Definition abgeleiteter einfacher Typen Einleitung Konzepte … - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Vergleich Beispiele: l <xsd: simple. Type name="my. Integer"> <xsd: restriction base="xsd: integer"> <xsd: min. Inclusive value="10000"/> <xsd: max. Inclusive value="99999"/> </xsd: restriction> </xsd: simple. Type> l <xsd: simple. Type name="Sku" base="xsd: string"> <xsd: pattern value="/d{3}-[A-Z]{2}"/> </xsd: simple. Type> l <xsd: simple. Type name="USState"> <xsd: restriction base="xsd: string"> <xsd: enumeration value="AK"/> <xsd: enumeration value="AL"/> <xsd: enumeration value="AR"/> <!-- and so on. . . --> </xsd: restriction> </xsd: simple. Type> Klemens Böhm Interoperable Informationssysteme - 70
Liste und Union Einleitung Konzepte … l - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen <xsd: simple. Type name="Six. USStates"> <xsd: restriction base="USState. List"> <xsd: length value="6"/> </xsd: restriction> </xsd: simple. Type> • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Typ ‚Liste‘ u Folge von Instanzen einfacher Typen. u Beispiel: <xsd: simple. Type name="USState. List"> <xsd: list item. Type="USState"/> </xsd: simple. Type> l Union Beispiel: <xsd: simple. Type name="zip. Union"> <xsd: union member. Types="USState list. Of. My. Int. Type"/> </xsd: simple. Type> Vergleich Klemens Böhm Interoperable Informationssysteme - 71
Inhaltsmodelle Einleitung Konzepte … - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle In etwa gleiche Konnektoren wie in DTD, andere Syntax. l Konnektoren: u Sequence, u Choice, u All (hat Pendant in SGML, nicht aber XML-DTDs) l • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Vergleich Klemens Böhm Interoperable Informationssysteme - 72
Namespaces Einleitung Konzepte … - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle Schema: Menge von Typdefinitionen und Elementdeklarationen. l Target Namespace eines Schemas – Menge der dort eingeführten Namen. (Legt aber immer noch nicht die Bedeutung fest. ) l Ziel: Dokument soll zu mehreren Schemata konform sein können. (Bisher noch keine Mechanismen für Beziehung Dokument – Schema. ) l • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Vergleich Klemens Böhm Interoperable Informationssysteme - 73
Inhaltsmodelle Einleitung Konzepte … - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include l Beispiel: <schema xmlns="http: //www. w 3. org/2001/XMLSchema" xmlns: po="http: //www. example. com/PO 1" target. Namespace="http: //www. example. com/P O 1" element. Form. Default="unqualified" attribute. Form. Default="unqualified"> <element name="purchase. Order" type="po: Purchase. Order. Type"/> <element name="comment" type="string"/>. . . • Abgel. Typen • Unique. und Keys • XML-Data Vergleich Klemens Böhm Interoperable Informationssysteme - 74
Inhaltsmodelle (Fortsetzung) Einleitung Konzepte … - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen . . . <complex. Type name="Purchase. Order. Type"> <sequence> <element name="ship. To" type="po: USAddress"/> <element name="bill. To" type="po: USAddress"/> <element ref="po: comment" min. Occurs="0"/> <!-- etc. --> </sequence> <!-- etc. --> </complex. Type> <complex. Type name="USAddress"> <sequence> <element name="name" type="string"/> <element name="street" type="string"/> <!-- etc. --> </sequence> </complex. Type> <!-- etc. --> </schema> • Unique. und Keys • XML-Data Vergleich Klemens Böhm Interoperable Informationssysteme - 75
Inhaltsmodelle (3) Einleitung Konzepte … l Erläuterungen: u Man muss explizit angeben, auf welchen Namespace man sich bezieht. u Attributwert unqualified: Namespace der lokalen Elemente/Attribute muss explizit angegeben werden. u unqualified: Default-Wert. l Beispiel für Dokument: <? xml version="1. 0"? > <apo: purchase. Order xmlns: apo="http: //www. example. com/PO 1" order. Date="1999 -10 -20"> <ship. To country="US"> <name>Alice Smith</name><street>12 Maple Street</street>. . . </ship. To>. . . <apo: comment>Hurry up!</apo: comment>. . . </apo: purchase. Order> - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Vergleich Klemens Böhm Interoperable Informationssysteme - 76
Schema in mehreren Dokumenten – Include Einleitung Konzepte … l Beispiel: <include schema. Location="http: //www. example. com /schemas/address. xsd"/> l Voraussetzung: Gleicher Target Namespace - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Vergleich Klemens Böhm Interoperable Informationssysteme - 77
Schema in mehreren Dokumenten – Import Einleitung Konzepte … l - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen <element name="purchase. Report"> <complex. Type> <sequence> <element name="regions" type="r: Regions. Type">. . . <simple. Content> <extension base="string"> <attribute name="number" type="xipo: SKU"/> </extension> </simple. Content>. . . • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Jene Voraussetzung muss nicht gelten – Beispiel: <schema target. Namespace="http: //www. sample. com/Report" xmlns="http: //www. w 3. org/2001/XMLSchema" xmlns: r="http: //www. sample. com/Report" xmlns: xipo="http: //www. sample. com/IPO" element. Form. Default="qualified"> <import namespace="http: //www. sample. com/IPO"/> l Nur globale Schemakomponenten können importiert werden. Vergleich Klemens Böhm Interoperable Informationssysteme - 78
Abgeleitete Typen (1) Einleitung Konzepte … l - Namespaces <complex. Type name="UKAddress"> <complex. Content> <extension base="ipo: Address"> <sequence> <element name="postcode" type="ipo: UKPostcode"/> </sequence> <attribute name="export. Code" type="positive. Integer" fixed="1"/> </extension> </complex. Content> </complex. Type> - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Erweiterung des Inhaltsmodells – Schema-Ausschnitt – Beispiel: l Erläuterung: postcode wird angehängt, Attribut export. Code kommt neu hinzu. Vergleich Klemens Böhm Interoperable Informationssysteme - 79
Abgeleitete Typen (2) Einleitung Konzepte … - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data l Erweiterung des Inhaltsmodells – Instanz des neuen Typs – Beispiel: <? xml version="1. 0"? > <ipo: purchase. Order xmlns: xsi="http: //www. w 3. org/2001/XMLS chema-instance" xmlns: ipo="http: //www. example. com/IPO" order. Date="1999 -12 -01"> <ship. To export. Code="1" xsi: type="ipo: UKAddress"> <name>Helen Zoe</name> <street>47 Eden Street</street> <city>Cambridge</city> <postcode>CB 1 1 JR</postcode> </ship. To> Vergleich Klemens Böhm Interoperable Informationssysteme - 80
Abgeleitete Typen (2) Einleitung Konzepte … - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Restriktion des Inhaltsmodells Beispiel: <element name="quantity"> <simple. Type> <restriction base="positive. Integer"> <max. Exclusive value="100"/> </restriction> </simple. Type> </element> l Substitution Groups Beispiel: <element name="ship. Comment" type="string" substitution. Group="ipo: comment" /> <element name="customer. Comment" type="string" substitution. Group="ipo: comment" /> l Vergleich Klemens Böhm Interoperable Informationssysteme - 81
Kontrolle über abgeleitete Typen Einleitung Konzepte … - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Schema-Autor kann (bestimmte oder alle) Ableitungen verbieten. l Beispiel: <complex. Type name="Address" final="restriction"> <sequence> <element name="name" type="string"/> <element name="street" type="string"/> <element name="city" type="string"/> </sequence> </complex. Type> l Bedeutung des Beispiels: Keine Ableitung by restriction. l Andere Attributwerte: #all, extension l Vergleich Klemens Böhm Interoperable Informationssysteme - 82
Uniqueness Einleitung Konzepte … - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Vergleich Man will festlegen, dass Werte – innerhalb eines bestimmten Scopes – nur einmal vorkommen. l Beispiel: <element name="purchase. Report"> <complex. Type>. . . <element name="regions" type="r: Regions. Type"> </element>. . . </complex. Type> l <unique name="dummy 1"> <selector xpath="r: regions/r: zip"/> <field xpath="@code"/> </unique> </element> <complex. Type name="Regions. Type"> <sequence> <element name="zip" max. Occurs="unbounded"> <complex. Type>. . . <attribute name="code" type="positive. Integer"/> </complex. Type> </element> </sequence> </complex. Type> Klemens Böhm Interoperable Informationssysteme - 83
Schlüssel und Schlüsselreferenzen Einleitung Konzepte … - Namespaces - XMLSchema • Einleitung • Basics • Neue simple Typen • Komplexe Inhaltsmodelle • Import & Include • Abgel. Typen • Unique. und Keys • XML-Data Vergleich Ziel: Getypte Referenzen. l Beispiel: <element name="purchase. Report"> <complex. Type> <sequence> <element name="regions" type="r: Regions. Type"> <keyref name="dummy 2" refer="r: p. Num. Key"> <selector xpath="r: zip/r: part"/> <field xpath="@number"/> </keyref> </element> l <element name="parts" type="r: Parts. Type"/> </sequence> </complex. Type> <key name="p. Num. Key"> <selector xpath="r: parts/r: part"/> <field xpath="@number"/> </key> </element> Klemens Böhm Interoperable Informationssysteme - 84
Zum Vergleich: Logische Dokumentstruktur mit HTML DIV und SPAN-Elemente sind generische Mechanismen für die Strukturierung von HTML-Dokumenten. l Beispiel: l Einleitung Konzepte Vergleich <DIV id="client-boyera" class="client"> <P><SPAN class="client-title">Client information: </SPAN> <TABLE class="client-data"> <TR><TH>Last name: <TD>Boyera</TR> <TR><TH>First name: <TD>Stephane</TR> <TR><TH>Tel: <TD>(212) 555 -1212</TR> <TR><TH>Email: <TD>sb@foo. org</TR> </TABLE> </DIV> <DIV id="client-lafon" class="client"> <P><SPAN class="client-title">Client information: </SPAN> <TABLE class="client-data"> <TR><TH>Last name: <TD>Lafon</TR> <TR><TH>First name: <TD>Yves</TR> <TR><TH>Tel: <TD>(617) 555 -1212</TR> <TR><TH>Email: <TD>yves@coucou. com</TR> SPAN - content is inline </TABLE> DIV - block level </DIV> Klemens Böhm Interoperable Informationssysteme - 85
Unterschiede XML - SGML Zu SGML-Dokument muss es DTD geben, nicht aber XML-Dokument. SGML erlaubt Tag-Omission, XML nicht. l Zusätzliche Konstrukte in SGML, z. B. u&-Konstruktor, u. Inclusions und Exclusions. l Einleitung Konzepte Vergleich Klemens Böhm Interoperable Informationssysteme - 86
Vergleich XML - OEM Gleiche Zielsetzung l OEM ist (auf Modellierungsebene) allgemeiner als XML u Mehrere einlaufende Kanten eines Knotens, u Zykel im Graph, OEM-Objekt muss keine Baumstruktur haben. l Unterschiedliche Diktion, insbesondere (XML-)Elemente - (OEM-)Objekte l Vielfalt der XML-Features, z. B. Entities, DTDs, nicht Teil von OEM; OEM ist im Gegensatz zu XML proprietäre Entwicklung/Forschungsarbeit; es gibt keine Produkte. l Einleitung Konzepte Vergleich Warum dieser Vergleich? Uebertragbarkeit Data. Guides Klemens Böhm Interoperable Informationssysteme - 87
Vergleich XML-OEM Einleitung Konzepte OEM E-R Modell XML SGML Modell <hier nichts Konkretes, wäre aber denkbar> Schema für Materialverwaltung z. B. Math. ML HTML Dokumenttyp e ip +1= 0 Homepage von Hans Schek Vergleich OEMDatenbank Klemens Böhm Datenbank, konform zum Schema n f (n) = S k Dokumentinstanz k=1 Interoperable Informationssysteme - 88
Abläufe Anfrage Einleitung Konzepte Patient: Hans Schek Bearbeitung Papier Vergleich HTTP/CGI Patient: Hans Schek HTML Cut / Paste Ausdrucken Anwendungsoberfläche XML Drag / Drop HTTP Patient: Hans Schek XML Dokument Bsp. Krankenakte Klemens Böhm Interoperable Informationssysteme - 89
XML - Perspektive l Einleitung Konzepte Vergleich l l Weiterentwicklung des Internet: u Neue W 3 C-Standards setzen auf XML (und RDF) auf, u clientseitige Verarbeitung und Sichten von Webdaten, u Individualisierung durch vielfältige Services, E-Commerce handelbare Information, Datenaustausch Konvertierung von Datenbank-Inhalten in Dokumente u. u. , Verwaltung von Dokumentkollektionen; Suchmaschinen: u präzisere Anfragen, u bessere Ergebnisqualität, Publishing - erst im Web, dann mit anderen Medien (oder nur im Web). Klemens Böhm Interoperable Informationssysteme - 90
- Slides: 90