Upload
agnethe-heinold
View
103
Download
1
Embed Size (px)
Citation preview
Interoperable Informationssysteme - 1Klemens Böhm
Datenmodell 2: XML
('Extended Markup Language’)
Interoperable Informationssysteme - 2Klemens Böhm
Was ist XML? Motivation XML-Konzepte Einordnung und Bewertung von XML
Weitere, zu XML gehörende Gliederungs-punkte:
Zusammenfassungen semistrukturierter Datenbestände
Layout und Transformation Erweiterbarkeit Hyperlinks
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 3Klemens Böhm
XML Dokumentklassen
z.B. MathML
HTML
Homepagevon
Hans Schek
Modell
Dokumenttyp
Dokument-instanz
e i +1= 0 n f (n) = k k=1
XML SGMLE-R Modell
Schema fürMaterial-verwaltung
Datenbank,konform zumSchema
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 4Klemens Böhm
XML Syntax
<?xml version="1.0"?>
<rezept> <zutaten id="x1"> <zutat>Ei</zutat> <zutat>Mehl</zutat> </zutaten> <expertise/> <zutaten id="x2"> <zutat>Salz</zutat> </zutaten></rezept>
rezept
expertise zutaten
zutat
id=x1 id=x2
Textuelle Darstellung Graphische Darstellung"Elementbaum"
zutaten
zutat zutat
Ei Mehl Salz
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 5Klemens Böhm
Was ist XML? Syntax zur Beschreibung
von teilweise strukturierter Information: Explizite Repräsentation
der logischen Struktur von Dokumenten (Alte Version der) W3C (World Wide Web Consortium)
FAQ: "It's actually slightly misnamed.”
Kernarchitektur für Hypermedien, genormt durch das W3C, aufbauend auf der Syntax, z.B. Annotationen, Stylesheets.
Dokumenttypen und Anwendungen aufbauend auf der Kernarchitektur: Offen, unternehmensintern, kommerziell,
Norm des W3C.
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 6Klemens Böhm
Was ist XML?
Tim Bray:
"XML will be the ASCII of the Web - basic, essential, unexciting"
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 7Klemens Böhm
Kernarchitektur Verwendung des Begriffs 'Architektur'
unterscheidet sich von der gewohnten, z.B. Hardware-Architektur, Software-Architektur.
'Architektur' bezeichnet hier die Menge der Zusammenhänge zwischen XML und verwandten Standards.Beispiele für derartige Zusammenhänge: XML-Namespace Recommendation
verwendet im XML-Standard definierte Konstrukte,
XSL Formatting Vocabulary ist XML-Namespace.
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 8Klemens Böhm
Was ist HTML? HTML ist ein spezieller Dokumenttyp. Elementtypen entsprechen (weitgehend)
den Layout-Bestandteilen des Dokuments. HTML-Dokumenttypdefinition, d.h.
insbesondere zulässige Anordnung der Elemente, ist von untergeordneter Bedeutung.
Parsen und Validieren von HTML-Dokumenten ist ebenfalls zweitrangig.
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 9Klemens Böhm
Warum braucht man XML, verglichen mit HTML?
Trennung zwischen logischer und Layout-Struktur führt zu höherer Flexibilität, insbesondere unterschiedliche Darstellungsmöglichkeiten
für unterschiedliche Benutzer und unterschiedliche Anforderungen,
bessere Strukturierungsmöglichkeiten. Dokument mit logischem Markup
enthält i.a. mehr Information, leichteres kooperatives Arbeiten bzw. bessere Dokumentation eigener Arbeitsschritte.
Konsistenz der Dokumente: 'intra-document consistency', 'inter-document consistency'.
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 10Klemens Böhm
XML Entwicklung
Jul 96 "SGML-Subset" Arbeitsgruppe (ERB)Nov 96 Erster öffentlicher XML-EntwurfMär 97 Microsoft veröffentlicht CDF-DTD
(Dateiformat für Push-Technologie)Apr 97 Netscape erkennt XML anAug 97 Sun Solaris 2.6 mit XML DokumentationOkt 97 Microsoft IE 4.0 mit XML ActiveX-ControlFeb 98 XML Version 1.0Apr 98 MathML, Mozilla 5.0 mit XMLAug 98 Reorganisation der W3C-XML-WGApr 99 Microsoft IE 5.0 mit XSLQ2 99 Microsoft Office mit HTML/XMLQ1 01 XML-Schema
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 11Klemens Böhm
Ziele des XML Entwurfs (1/2)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.
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 12Klemens Böhm
Ziele des XML Entwurfs (2/2)
6 XML-Dokumente sollen für Menschen lesbar und angemessen verständlich sein.
7 Der XML-Entwurf sollte zügig abgefasst werden.(D.h. die Erstellung der XML-Spezifikation.)
8 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?
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 13Klemens Böhm
XML Konzepte Unicode, Dokument, Dokumentinstanz, DTD wohlgeformt vs. gültig, XML-Processor, XML-Applikation syntaktische Konstruktionen in XML:
Elemente, Attribute, Processing Instructions, Entitäten, Notationen,
XML Namensräume, XML-Schema Mechanismus.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- Pis
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 14Klemens Böhm
Unicode 2.1 (1/4) 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.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 15Klemens Böhm
Unicode 2.1 (2/4) Es gibt mehrere Möglichkeiten,
16-Bit Nummern zu speichern. 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.
XML Spezifikation legt fest, dass XML Unicode verwendet.'All XML processors must accept the UTF-8 and UTF-16 encodings of ISO 10646 …’.
Dokumente, die mit UTF-16 kodiert sind, müssen mit spezieller Bit-Sequenz beginnen.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 16Klemens Böhm
Unicode 2.1 (3/4) http://www.unicode.org/unicode/standard/principles.html 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.
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.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 17Klemens Böhm
Unicode 2.1 (4/4)
Verwendung anderer Character Encodings ist möglich, XML Processor muss sie aber nicht unterstützen.
Spezifikation erfolgt mit dem encoding-Attribut.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 18Klemens Böhm
Übersicht: XML Dokument
XML DokumentKommentar, Arbeitsanweisung, Zeichenreferenz
Prolog mit Dokument Typ-Deklaration
Dokument Element mit Namensraumdeklaration
Dokument Typ-Definition (DTD)Element, Attribut,Entität, Parameterentität, Parameterentitätsreferenz
Externe DTD TeilmengeKonditionale Abschnitte, beliebige Parameterentitätsreferenz
DokumentStart-Tag, Ende-Tag, leeres-Element-Tag, PCDATA,CDATA Abschnitte, Entitätsreferenzen
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 19Klemens Böhm
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><fm> <p>SGML markup by Jon Bosak, 1992-1994.</p>
<p>XML version by Jon Bosak, 1996-1997.</p><p>This work may be freely copied and distributed worldwide.</p>
</fm><personae>
<title>Dramatis Personae</title><persona>CLAUDIUS, king of Denmark. </persona><persona>HAMLET, son to the late, and nephew to the present king.
</persona></personae><scndescr>SCENE Denmark.</scndescr><playsubt>HAMLET</playsubt><act> <title>ACT I</title>
<scene><title>SCENE I. Elsinore. A platform before the castle.</title><stagedir>FRANCISCO at his post. Enter to him BERNARDO</stagedir><speech><speaker>BERNARDO</speaker><line>Who's there?</line></speech>...
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 20Klemens Böhm
Hamlet: Elementbaum
Dokument-Element
Element"act" ist enthalten in "play"
Pfad
scene
...play
fm acttitle personae
DramatisPersona
The Tragedy of Hamlet,
Prince of Denmarkacttitle
Act I
stagedirp . . . p
...worldwide
SGML markup...
title
persona persona
CLAUDIUS HAMLET
scenedescr playsubt
Scene Denmark
hamlet
scenetitle
Scene I ...
FRANCISCO ...
speech
speaker line
BERNARDOWho's
there?
Visual Pattern Builder
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 21Klemens Böhm
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)> <!ELEMENT fm (p+)> <!ELEMENT personae (title, (persona | pgroup)+)> <!ELEMENT pgroup (persona+, grpdescr)> <!ELEMENT induct (title, subtitle*,
scene+|(speech|stagedir|subhead)+))> <!ELEMENT act (title, subtitle*, prologue?, scene+,
epilogue?)> <!ELEMENT scene (title, subtitle*,
(speech | stagedir | subhead)+)> <!ELEMENT prologue (title, subtitle*, (stagedir | speech)+)> <!ELEMENT epilogue (title, subtitle*, (stagedir | speech)+)> <!ELEMENT speech (speaker+, (line | stagedir | subhead)+)> <!ELEMENT line (stagedir | #PCDATA)+> ...
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 22Klemens Böhm
Well-Formed vs. Valid wohlgeformt (well-formed) -
ein Dokument besitzt geordnete syntaktische Eigenschaften,die im folgenden vorgestellt werden,
gültig (valid) -Ein Dokument ist wohlgeformt und folgt einem a priori gegebenen Schema, formalisiert in einer Dokumenttypdefinition (DTD).
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 23Klemens Böhm
Well-Formedness
Illustration, dass Dokumente, die well-formed sind, vollständig markiert sein müssen:
Nicht vollständig markiertes Dokumentfragment:<A><B>pipapo<C>hello world</C></A>
Zwei mögliche Strukturen:
pipapo hello world pipapo
hello world
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 24Klemens Böhm
XML Processor, Application XML Processor - Modul, das Zugriff auf
Inhalt und Struktur von XML-Dokumenten ermöglicht.
Applikation - Modul, das den XML Processor verwendet.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 25Klemens Böhm
XML Processor, Application
Application
XML-Processor(XML-Engine)
Callback-Methoden("User Exits”)
DOM-Methoden
Aufruf fürXML-Dok.
MM-Tool 1 MM-Tool 2
...
Bsp. fuer diese Aufteilung: Workflow aus Bestellungz:\users\boehm\Windows\temp\Samples\expat\elements.c… xmlparse.h
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 26Klemens Böhm
Darstellung der logischen Dokumentstruktur
PCDATA= parseable character data,Kein anderer terminaler Typ fuer Contentfuer Strings in Attributen gibt es nur den Typ CDATA
Tags begrenzen Elemente, hierarchisch oberstes Element
heisst Dokumentelement, Syntaktisch zulässige Tag-Namen
haben die Struktur [letter][letter0-9.:-_]*
Tags sind "case-sensitive", Jedes geöffnete Tag
muss wieder geschlossen werden. Tags dürfen einander nicht
überlappen; nicht erlaubt z.B.:<A>…<B>…</A>…</B>
Tags leerer Elementehaben besondere Syntax.
<paper> <abstract> Interoperable
information systems require ...
</abstract> <body> <acknowl/> Markup such
as <keyword>, ... </body></paper>
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
LeeresElement
Interoperable Informationssysteme - 27Klemens Böhm
CDATA
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>...
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 28Klemens Böhm
DTD-Deklarationen
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE test PUBLIC "-//Test AG//DTD test V1.0//EN" SYSTEM "http://www.test-ag.de/test.dtd"><test> "test" ist das Dokumentelement </test>
<!DOCTYPE test SYSTEM "http://www.test-AG.de/test.dtd" [ <!ENTITY hallo "hallo welt">]><test>&hallo;</test>
<!DOCTYPE test [ <!ELEMENT test EMPTY> ]><test/>
Externe DTD Deklaration
Interne DTD Deklaration
Gemischte Nutzung
Internal DTD Subset
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 29Klemens Böhm
DTD-Deklarationen (2)
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Erläuterungen: Gemischte Nutzung –
externe DTD, aber proprietäre Entity-Definition encoding - Character Encoding Attribut nicht erforderlich für ASCII,
da Subset von UTF-8
Interoperable Informationssysteme - 30Klemens Böhm
Elementdeklaration Elementdeklaration legt fest,
wie der direkte Inhalt eines Elements aufgebaut ist.(SGML - Inclusions)
Inhaltsmodell - regulärer Ausdruck, der Aufbau des direkten Inhalts spezifiziert.
Syntax der Elementdeklaration:<!ELEMENT Elementname (Inhaltsmodell)>
Beispiel:<!ELEMENT aufsatz (einleit,hauptteil,schluss)>
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 31Klemens Böhm
Elementdeklaration (1/2) Elementinhalt
<!ELEMENT beispiel (a)>
Gemischter Inhalt ("mixed content") <!ELEMENT beispiel (#PCDATA)> <!ELEMENT beispiel (#PCDATA|a)*>
Leeres Element <!ELEMENT beispiel EMPTY>
Element mit beliebigem Inhalt <!ELEMENT beispiel ANY> 'beliebiger Inhalt'- muss vorher schon deklariert worden sein.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 32Klemens Böhm
Elementdeklaration (2/2) Konstruktoren:
Sequenz <!ELEMENT beispiel(a, b)>
Alternative <!ELEMENT beispiel(a | b)>
Occurrence Indicators: Optional (Null- oder einmal)
<!ELEMENT beispiel (a)?> Optional und wiederholbar (beliebig oft)
<!ELEMENT beispiel (a)*> Notwendig und wiederholbar (mindestens einmal)
<!ELEMENT beispiel (a)+> Inhaltsmodelle können mit Klammern kombiniert
werden.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 33Klemens Böhm
Attribute Jedes Element kann mit
(beliebig vielen) Attributen versehen sein, Attribut-Belegungen sind normal im Start-Tag
enthalten, Beispiel:
<!ELEMENT abstract (text)> <!ATTLIST abstract author CDATA #REQUIRED>
<abstract author='weber'>Das ganze Leben ist ein Quiz</abstract>
Attribute sind eine von mehreren Möglichkeiten, zusätzliche Information mit Elementen in Verbindung zu bringen. Bsp.: <!ELEMENT abstract (author, text)>
<!ELEMENT author (#PCDATA)>
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 34Klemens Böhm
Wozu braucht man Attribute? Es existieren Typen für Attribute. Das Dokument besteht aus weniger
Elementen. Bessere Lesbarkeit, Übersichtlichkeit.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 35Klemens Böhm
Attributdeklaration Syntax der Attributdeklaration:
<!ATTLIST ElementnameAttributname Typ VorgabeAttributname Typ Vorgabe
… >
Mögliche Vorgaben: Notwendiges Attribut: #REQUIRED Optionales Attribut: #IMPLIED Festes Attribut: #FIXED "wert"
(d.h. DTD legt den Attributwert bereits fest).
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 36Klemens Böhm
Attribute: Typen (1/5) CDATA
Zeichenkette (mit Entitätsersetzung) <!ATTLIST beispiel HREF CDATA #REQUIRED>
Aufzählungstyp Token aus vorgegebener Menge, evtl. Defaultwert <!ATTLIST beispiel
auswahl (ja|nein|vielleicht) "ja">
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
AttributnameElementname
Interoperable Informationssysteme - 37Klemens Böhm
Attribute: Typen (2/5) ID, IDREF
Attribut vom Typ ID ist innerhalb eines Dokuments eindeutig,
IDREF ist eine Referenz auf eine ID, Parser prüft referentielle Integrität, keine Einschränkung des Typs, kein reftype, <!ATTLIST beispiel indent ID #IMPLIED referenz IDREFS #IMPLIED>
NAME, NAMESName bzw. Namen, beginnend mit Letter, _ oder :
NMTOKEN, NMTOKENS Name bzw. Namen, ausschliesslich NAME-Chars <!ATTLIST variablen
beispiel NMTOKENS #REQUIRED>
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 38Klemens Böhm
Arbeitsanweisung/Processing Instruction (PI)
PI sind nicht Teil des Dokumenttextes.
PIs werden an Applikation durchgereicht.
PI beginnt mit Target, d.h. Identifier der Applikation,
z.B. php PI-Targets werden mit dem
XML Notation Mechanismus deklariert (wird später besprochen).
<?xml ist reserviert, <?xml erlaubt Erkennung der
Zeichenkodierung.
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
...<?php echo $title;?>...
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich z:\users\boehm\\Windows\temp\Samples\Samples\Internet\xml\xml_validator\validate.htmz:\users\boehm\\Windows\temp\Samples\xml\example_files\books.xmlz:\users\boehm\Windows\temp\Samples\expat\xmlparse.h
Interoperable Informationssysteme - 39Klemens Böhm
Zeichenreferenzen und Kommentare
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.
û û und © stehen für dasselbe Zeichen
...
<!-- Ein Kommentar darfbeliebige Zeichenfolgen wie <tagname> oder&entity; enthalten-->
...
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 40Klemens Böhm
Attribut-Normalisierung
Bevor ein Attributwert überprüft bzw. an eine Applikation weitergegeben wird, muss der XML Processor ihn normalisieren:
Character-Referenz auflösen, Replacement-Text einer Entity-Referenz
rekursiv abarbeiten.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 41Klemens Böhm
Logische vs. physische Dokumentstruktur
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.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 42Klemens Böhm
Externe Entities - Beispiel
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
…<!ENTITY chapter1 SYSTEM "http://www.boehm-ag.com/
chapters/chap1.xml">
<dissertation><intro>This work is a brilliant piece of work …</intro>&chapter1;&chapter2;<conclusion>This work isdestined to become a classic.</conclusion>…
<chapter> Das ganze Leben ist ein Quiz, und wir sind nur die Kandidaten…</chapter>
http ://www.boehm-ag.com/chapters/chap1.xml
Interoperable Informationssysteme - 43Klemens Böhm
Physische Partitionierung von Dokumenten - Motivation
Grösse des Files, organisationelle Aspekte, Nicht-XML Resourcen, z.B. Binaries, Wiederverwertung von DTD-Fragmenten.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 44Klemens Böhm
Entities - Klassifizierung Internal Entities vs. External Entities,
Beispiel für Internal Entity:<!ENTITY hallo "hallo welt">...<test>&hallo;</test>
Parsed Entities vs. Unparsed Entities, General Entities vs. Parameter Entities.
Dimensionen sind z.T. orthogonal zueinander. Z.B. kann External Entity entweder Parsed Entity oder Unparsed Entity sein.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 45Klemens Böhm
Internal Entities vs. External Entities External Entities -
physische Units im XML-Kontext;Document Entity -'Wurzel’-Entity, Hub-Dokument Einstiegspunkt für XML Processing
Internal Entities - kein separates physisches Objekt, Deklaration der Entity enthält ihren Inhalt;Motivation: Übersichtlichkeit, weniger Code, Wiederverwertbarkeit, weniger Elemente
(wird weiter hinten illustriert).
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 46Klemens Böhm
Externe Entities - Differenzierung
Differenzierung zwischen Parsed und Unparsed Entities:
Parsed Entity -Entity-Referenz wird aufgelöst, Entity-Inhalt ist Teil des Dokuments,
Unparsed Entity - muss kein XML enthalten.(Weitere Erläuterungen folgen.)
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 47Klemens Böhm
Entity Deklarationen - Beispiele Deklaration einer internen Entity:
<!ENTITY Pub-Status "This is a pre-release of the specification.">
Deklaration externer Entities: Parsed Entity:<!ENTITY oh
SYSTEM
"http://www.tty.com/bplate/OH.xml"> Unparsed Entity:<!ENTITY hatch-pic SYSTEM "../grafix/OH.gif" NDATA gif>
SYSTEM-Identifier identifiziert Position relativ zur Entity-Deklaration.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Unterschied:Interne Entityenthält Text,aber keinenSYSTEM-Identifier.
Interoperable Informationssysteme - 48Klemens Böhm
General Entities vs. Parameter Entities
General Entity - Verwendung im Dokumentinhalt,
Parameter Entities - Parsed Entity zur Verwendung in der DTD.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 49Klemens Böhm
Beispiele Character-Referenzen und Entity-Referenzen:
Type <key>less-than</key> (<) to save options.This document was prepared on &docdate; and is classified &security-level;.
Parameter-Entity Referenz: <!-- declare the param. entity "ISOLat2"... -->
<!ENTITY % ISOLat2 SYSTEM "http://www.xml.com/iso/isolat2-xml.entities" >
<!-- ... now reference it. --> %ISOLat2;
Unterschiedliche Syntax Character-Referenzen und Entity-Referenzen sowie Parameter-Entity Referenz
http://www.w3.org/TR/WD-html40-970708/sgml/entities.html
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 50Klemens Böhm
Parameter-Entitäten
Verwendbar nur innerhalb der DTD,
Namensraum unterscheidet sich von dem normaler Entitäten,
Ziele: Modularisierung
von DTDs, weniger Elemente.
<!ENTITY % firmenweit SYSTEM "http://foo.com/std.ent"
>%firmenweit;<!ENTITY % adresse "(name, strasse, plz)">
<!ELEMENT kunde%adresse;>
<!ELEMENT lieferant%adresse;>
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 51Klemens Böhm
Konditionale Abschnitte
Teile einer DTD können ein- und ausgeblendet werden
Üblicher Mechanismus hierfür: Parameter-Entitäten.
<!ENTITY % draft 'INCLUDE' ><!ENTITY % final 'IGNORE' ><![%draft;[<!ELEMENT book (comments*, title, body,
suppl?)>]]><![%final;[<!ELEMENT book (title, body, suppl?)>]]>
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 52Klemens Böhm
Well-Formedness (Fortsetzung) Zu einem Dokument muss keine DTD gehören. Dokument 'ohne DTD’ muss bestimmte Bedingungen erfüllen,
insbesondere muss die Struktur eindeutig sein: Dok. sollte 'Standalone Document Declaration’ (SDD)
enthalten:<?xml version="1.0" standalone="yes"?>
<foo> <bar>...<blort/>...</bar> </foo>
Dokument hat genau eine Wurzel, Tag Omission ist nicht erlaubt,
kein überlappender Markup,alle Attributwerte in Anführungszeichen,Attributwerte per Default vom Typ CDATA,
leere Elemente müssen als solche erkennbar sein, kein isolierter Markup, z.B. '<’ anstatt '<'.
Entitäten, d.h. die externen Files, müssen wohlgeformt sein.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 53Klemens Böhm
Notations Notationen -
Mechanismus, um mit einem Namen das Format von Unparsed Entities, das Format von Elementen
mit einem Notation-Attribut oder die Anwendung,
auf die sich eine Processing Instruction bezieht,
zu identifizieren. Beispiel für Element mit Notation-Attribut:
Element, dessen Inhalt PostScript oder VRML ist. Genaueres später.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 54Klemens Böhm
Notations Notationen können die Semantik von nicht-analysierten
Entitäten, Arbeitsanweisungen und Attributen festlegen, Beispiel:
<!NOTATION MPEG SYSTEM"c:\programme\mpeg.exe">
<!ENTITY löwe "leo.mpg"NDATA MPEG>
Anwendungen: Multimedia-Elemente, Typsysteme. Zu jeder Unparsed Entity gehört eine Notation,
identifiziert durch einen Namen. Ein XML Processor muss einer Anwendung
die Identifier der Entity und den Notationsnamen verfügbar machen.
Der Notation Identifier wird der Anwendung mit der Notation Declaration verfügbar gemacht.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Notation Identifier
Interoperable Informationssysteme - 55Klemens Böhm
Attribute: Typen (3/5) ENTITY, ENTITIES
Verwendung: Pointer auf Daten eines speziellen (Medien-)Typs ausserhalb der aktuellen Entity
Attributwert muss Name einer in der DTD deklarierten Unparsed Entity sein.
Parser versucht nicht, Entity aufzulösen. Beispiel:<!NOTATION vrml PUBLIC "VRML 2"><!ENTITY Antarctica SYSTEM "http://www.antarc.net" NDATA vrml><!ATTLIST World src ENTITY #REQUIRED>
<World src='Antarctica'>Element-typname
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Attribut-name
Interoperable Informationssysteme - 56Klemens Böhm
Attribute: Typen (4/5) NOTATION
Attribut dieses Typs ist nur sinnvoll für Elemente mit 'speziellem' Inhalt,
Attributwert muss Name einer deklarierten Notation sein.
Verwendung: Typisierte Attribute, Multimedia-Attribute,
Beispiel:<!NOTATION vrml PUBLIC "VRML 2"><!NOTATION ps PUBLIC "PostScript Level 3"><ATTLIST Rendered In
NOTATION (ps|vrml) #IMPLIED>
<Rendered In='ps'>gsave 112 75 moveto 112 300lineto showpage grestore</Rendered>
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 57Klemens Böhm
Attribute: Typen (5/5)
Was ist also der Unterschied in der Verwendung von Attributen vom Typ ENTITY und vom Typ NOTATION?Spezieller Content ausserhalb bzw. innerhalb aktueller Entity.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 58Klemens Böhm
Namespaces Motivation:
Element- und Attributnamen ("Markup Vocabulary”) mit allgemeiner Gültigkeit,Beispiel: Library of Congress Subject Headings (LCSH)
Anwendung basiert auf allgemeiner Interpretation dieser Namen,
ein XML-Dokument soll Markup Vocabulary aus mehreren 'Dictionaries’ enthalten können.(Erinnerung: XML-Dokument muss keine DTD haben.)
Namespaces zur Vermeidung von Namenskonflikten.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 59Klemens Böhm
Beispiel für die Verwendung von Namespaces (2/2)
<x xmlns:edi='http://ecommerce.org/schema'> <!-- the "edi" prefix is bound to 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 --></x>
<x xmlns:edi='http://ecommerce.org/schema'> <!-- the 'taxClass' attribute's namespace is http://ecommerce.org/schema --> <lineItem edi:taxClass="exempt">Baby food
</lineItem></x>Namespace Prefix stellt Verbindung zum Namespace her.
Namespace
QualifiedName
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 60Klemens Böhm
Namespaces - Erläuterung XML Namespace ist im wesentlichen
eine Menge von Namen. Genauer: keine Menge –
globale und lokale Variablen. Lokale Variablen: unterschiedliche Namespaces
für Attributnamen unterschiedlicher ElementtypenBeispiel: TITLE - Section, TITLE – Author
Attribut besteht aus Namespace-Präfix und lokalem Teil.
URI identifiziert Namespace. Namespace-Definition muss kein Schema
in einer formalen Sprache sein. Es kann sinnvoll sein, dass ET-Name aus Namespace,
Attributname jedoch nicht.price - brutto oder netto, keine weiteren Aspekte.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 61Klemens Böhm
Namensräume
<bestellung xmlns:B = "http://bank.de/schema/" xmlns:L = "http://buch.de/schema/">
1998-11-09
Bestellung
L:Buch
B:DatumB:SignaturB:Betrag
B:Überweisung
49,00 80X8......F915
L:Titel L:ISBN
B:Sorte="DM"
L:Autor
Gibson,William
3-8077-0309-8
Neuro-mancer
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 62Klemens Böhm
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,
Scoping - Namespace Definition kann überschrieben werden in 'innerem' Element.
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 63Klemens Böhm
XML-Dokument mit Namespace<?xml version="1.0"?><portfolio xmlns:dt="urn:schemas-microsoft-com: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>
Einleitung
Konzepte
- Unicode
- Basics
- XML Proc.
- Elemente
- Attribute
- PIs
- Entities
- Notations
- Name- spaces
- XML- Schema
Vergleich
Interoperable Informationssysteme - 64Klemens Böhm
Mängel von XML-DTDs/neue Anforderungen an XML-Schema Keine Erweiterbarkeit – wünschenswert:
Erweiterbarkeit des Inhaltsmodells, Einschränkung des Inhaltsmodells.
Möglichkeit der Validierung: Datentypen und Wertebereiche, Integritätsbedingungen, getypte Links,
Modularität, die über die von DTDs hinausgeht:Scoping.
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 65Klemens Böhm
XML-Schema Idee: Schema ist XML-Dokument. Vergleichbar mit Data Dictionary -
Relationen zur Verwaltung der Schemainformation. Aktueller Status (März 2001):
W3C Proposed Recommendation.
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 66Klemens Böhm
Inhaltsmodell mit XML-Schema Beispiel:
<xsd:complexType 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:complexType>
Erläuterungen: Typdefinition und Elementdeklaration getrennt. Lokale Typen (lokale Typen
mit gleichem Namen anderswo möglich) (Sinnvolle) Beispiele für leere Elemente.
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 67Klemens Böhm
Typdefinition und Elementdeklaration Beispiel:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> ...<xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
<xsd:element name="comment" type="xsd:string"/>
<xsd:complexType name="PurchaseOrderType"> <xsd:sequence> <xsd:element name="shipTo" type="Address"/> <xsd:element name="billTo" type="Address"/> <xsd:element ref="comment" minOccurs="0"/> <xsd:element name="items" type="Items"/> </xsd:sequence> <xsd:attribute name="orderDate" type="xsd:date"/> </xsd:complexType>
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 68Klemens Böhm
Typdefinition und Elementdeklaration (2)
Erläuterungen: Globale Elementtypen. Occurrence-Anzahl für comment
Wie ist purchaseOrder-Element aufgebaut?
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 69Klemens Böhm
Komplexes Inhaltsmodell Beispiel:
<xsd:complexType name="Items"> <xsd:element name="item" minOccurs="0"
maxOccurs="*"> <xsd:complexType> <xsd:sequence> <xsd:element name="productName"
type="xsd:string"/> <xsd:element name="price" type="xsd:decimal"/> <xsd:element ref="comment" minOccurs="0"/> <xsd:element name="shipDate" type="xsd:date"
minOccurs='0'/> <xsd:attribute name="partNum" type="Sku"/> </xsd:sequence> </xsd:complexType> </xsd:element></xsd:complexType>
Erläuterungen: Default: Genau ein Vorkommen, Implizite Typdefinition.
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 70Klemens Böhm
Definition abgeleiteter einfacher Typen
Beispiele: <xsd:simpleType name="myInteger">
<xsd:restriction base="xsd:integer"> <xsd:minInclusive value="10000"/> <xsd:maxInclusive value="99999"/> </xsd:restriction> </xsd:simpleType>
<xsd:simpleType name="Sku" base="xsd:string"> <xsd:pattern value="/d{3}-[A-Z]{2}"/> </xsd:simpleType>
<xsd:simpleType 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:simpleType>
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 71Klemens Böhm
Liste und Union Typ ‚Liste‘
Folge von Instanzen einfacher Typen. Beispiel: <xsd:simpleType name="USStateList"> <xsd:list itemType="USState"/> </xsd:simpleType>
<xsd:simpleType name="SixUSStates"> <xsd:restriction base="USStateList"> <xsd:length value="6"/> </xsd:restriction> </xsd:simpleType>
UnionBeispiel:<xsd:simpleType name="zipUnion"> <xsd:union memberTypes="USState
listOfMyIntType"/> </xsd:simpleType>
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 72Klemens Böhm
Inhaltsmodelle In etwa gleiche Konnektoren wie in DTD,
andere Syntax. Konnektoren:
Sequence, Choice, All (hat Pendant in SGML,
nicht aber XML-DTDs)
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 73Klemens Böhm
Namespaces Schema: Menge von Typdefinitionen
und Elementdeklarationen. Target Namespace eines Schemas –
Menge der dort eingeführten Namen.(Legt aber immer noch nicht die Bedeutung fest.)
Ziel: Dokument soll zu mehreren Schemata konform sein können.(Bisher noch keine Mechanismen für Beziehung Dokument – Schema.)
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 74Klemens Böhm
Inhaltsmodelle Beispiel:
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:po="http://www.example.com/PO1" targetNamespace="http://www.example.com/PO1" elementFormDefault="unqualified" attributeFormDefault="unqualified">
<element name="purchaseOrder" type="po:PurchaseOrderType"/> <element name="comment" type="string"/> ...
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 75Klemens Böhm
Inhaltsmodelle (Fortsetzung)...<complexType name="PurchaseOrderType"> <sequence> <element name="shipTo" type="po:USAddress"/> <element name="billTo" type="po:USAddress"/> <element ref="po:comment" minOccurs="0"/> <!-- etc. --> </sequence> <!-- etc. --> </complexType>
<complexType name="USAddress"> <sequence> <element name="name" type="string"/> <element name="street" type="string"/> <!-- etc. --> </sequence> </complexType> <!-- etc. --> </schema>
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 76Klemens Böhm
Inhaltsmodelle (3) Erläuterungen:
Man muss explizit angeben, auf welchen Namespace man sich bezieht.
Attributwert unqualified: Namespace der lokalen Elemente/Attribute muss explizit angegeben werden.
unqualified: Default-Wert. Beispiel für Dokument:
<?xml version="1.0"?> <apo:purchaseOrder
xmlns:apo="http://www.example.com/PO1" orderDate="1999-10-20">
<shipTo country="US"> <name>Alice Smith</name><street>12 Maple Street</street> ... </shipTo> ... <apo:comment>Hurry up!</apo:comment> ... </apo:purchaseOrder>
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 77Klemens Böhm
Schema in mehreren Dokumenten – Include
Beispiel:<include schemaLocation="http://www.example.com/schemas/address.xsd"/>
Voraussetzung: Gleicher Target Namespace
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 78Klemens Böhm
Schema in mehreren Dokumenten – Import
Jene Voraussetzung muss nicht gelten – Beispiel:<schema targetNamespace="http://www.sample.com/Report" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:r="http://www.sample.com/Report" xmlns:xipo="http://www.sample.com/IPO" elementFormDefault="qualified"> <import namespace="http://www.sample.com/IPO"/>
<element name="purchaseReport"> <complexType> <sequence> <element name="regions" type="r:RegionsType"> ...<simpleContent> <extension base="string"> <attribute name="number" type="xipo:SKU"/> </extension> </simpleContent> ...
Nur globale Schemakomponenten können importiert werden.
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 79Klemens Böhm
Abgeleitete Typen (1) Erweiterung des Inhaltsmodells –
Schema-Ausschnitt – Beispiel:<complexType name="UKAddress"> <complexContent> <extension base="ipo:Address"> <sequence> <element name="postcode"
type="ipo:UKPostcode"/> </sequence> <attribute name="exportCode"
type="positiveInteger" fixed="1"/> </extension> </complexContent> </complexType>
Erläuterung: postcode wird angehängt, Attribut exportCode kommt neu hinzu.
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 80Klemens Böhm
Abgeleitete Typen (2) Erweiterung des Inhaltsmodells –
Instanz des neuen Typs – Beispiel:<?xml version="1.0"?> <ipo:purchaseOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ipo="http://www.example.com/IPO" orderDate="1999-12-01">
<shipTo exportCode="1" xsi:type="ipo:UKAddress"> <name>Helen Zoe</name> <street>47 Eden Street</street> <city>Cambridge</city> <postcode>CB1 1JR</postcode> </shipTo>
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 81Klemens Böhm
Abgeleitete Typen (2) Restriktion des Inhaltsmodells
Beispiel:<element name="quantity"> <simpleType> <restriction base="positiveInteger"> <maxExclusive value="100"/> </restriction> </simpleType> </element>
Substitution GroupsBeispiel:<element name="shipComment" type="string" substitutionGroup="ipo:comment" /> <element name="customerComment" type="string" substitutionGroup="ipo:comment" />
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 82Klemens Böhm
Kontrolle über abgeleitete Typen Schema-Autor kann
(bestimmte oder alle) Ableitungen verbieten. Beispiel:<complexType name="Address" final="restriction"> <sequence> <element name="name" type="string"/> <element name="street" type="string"/> <element name="city" type="string"/> </sequence> </complexType>
Bedeutung des Beispiels: Keine Ableitung by restriction.
Andere Attributwerte: #all, extension
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 83Klemens Böhm
Uniqueness Man will festlegen, dass Werte – innerhalb eines bestimmten
Scopes – nur einmal vorkommen. Beispiel:
<element name="purchaseReport"> <complexType> ... <element name="regions"
type="r:RegionsType"> </element> ... </complexType>
<unique name="dummy1"> <selector xpath="r:regions/r:zip"/> <field xpath="@code"/> </unique> </element>
<complexType name="RegionsType"> <sequence> <element name="zip" maxOccurs="unbounded"> <complexType> ...<attribute name="code" type="positiveInteger"/> </complexType> </element> </sequence> </complexType>
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 84Klemens Böhm
Schlüssel und Schlüsselreferenzen Ziel: Getypte Referenzen. Beispiel:
<element name="purchaseReport"> <complexType> <sequence> <element name="regions"
type="r:RegionsType"> <keyref name="dummy2" refer="r:pNumKey"> <selector xpath="r:zip/r:part"/> <field xpath="@number"/> </keyref> </element>
<element name="parts" type="r:PartsType"/> </sequence> </complexType>
<key name="pNumKey"> <selector xpath="r:parts/r:part"/> <field xpath="@number"/> </key> </element>
Einleitung
Konzepte
…
- Name- spaces
- XML- Schema
• Einleitung
• Basics
• Neue simple Typen
• Komplexe Inhalts- modelle
• Import & Include
• Abgel. Typen
• Unique. und Keys
• XML-Data
Vergleich
Interoperable Informationssysteme - 85Klemens Böhm
Zum Vergleich: Logische Dokumentstruktur mit HTML
DIV und SPAN-Elemente sind generische Mechanismen für die Strukturierung von HTML-Dokumenten.
Beispiel:
<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>[email protected]</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>[email protected]</TR> </TABLE> </DIV>
SPAN - content is inlineDIV - block level
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 86Klemens Böhm
Unterschiede XML - SGML Zu SGML-Dokument muss es DTD geben,
nicht aber XML-Dokument.SGML erlaubt Tag-Omission, XML nicht.
Zusätzliche Konstrukte in SGML, z.B. &-Konstruktor, Inclusions und Exclusions.
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 87Klemens Böhm
Vergleich XML - OEM Gleiche Zielsetzung OEM ist (auf Modellierungsebene)
allgemeiner als XML Mehrere einlaufende Kanten eines Knotens, Zykel im Graph,
OEM-Objekt muss keine Baumstruktur haben. Unterschiedliche Diktion, insbesondere
(XML-)Elemente - (OEM-)Objekte 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.
Warum dieser Vergleich? Uebertragbarkeit DataGuides
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 88Klemens Böhm
Vergleich XML-OEM
OEM-Datenbank
z.B. MathML
HTML
Homepagevon
Hans Schek
Modell
Dokumenttyp
Dokument-instanz
e i +1= 0
n f (n) = k k=1
XML SGMLE-R Modell
Schema fürMaterial-verwaltung
Datenbank,konform zumSchema
OEM
<hier nichtsKonkretes,wäre aberdenkbar>
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 89Klemens Böhm
Abläufe
Patient:Hans Schek
Patient:Hans Schek
Papier
HTML
XMLPatient:
Hans Schek
Anfrage Bearbeitung
HTTP
Cut / Paste
Drag / Drop
HTTP/CGI
Papier
Anwendungs-oberfläche
XML Dokument
Ausdrucken
Bsp. Krankenakte
Einleitung
Konzepte
Vergleich
Interoperable Informationssysteme - 90Klemens Böhm
XML - Perspektive Weiterentwicklung des Internet:
Neue W3C-Standards setzen auf XML (und RDF) auf, clientseitige Verarbeitung und Sichten von Webdaten, Individualisierung durch vielfältige Services,
E-Commerce -handelbare Information,
Datenaustausch -Konvertierung von Datenbank-Inhalten in Dokumente u.u.,
Verwaltung von Dokumentkollektionen; Suchmaschinen: präzisere Anfragen, bessere Ergebnisqualität,
Publishing - erst im Web, dann mit anderen Medien (oder nur im Web).
Einleitung
Konzepte
Vergleich