http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
Strukturierung von Inhalten
• eXtensible Markup Language• Metasprache• erlaubt die Definition eigener Markupsprachen zur Strukturierung
von Informationen• World Wide Web Consortium (W3C) Standard• Basiert auf ISO Standard SGML• Lizenzfrei, Plattform-unabhängig und gut unterstützt
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
Strukturierung von Inhalten
Von der Instanz zur DTD• Ein XML-Dokument ähnelt HTML
XML Instanz
• DOCTYPE-Angabe verbindet Instanz und DTD
<?xml version=“1.0“ encoding=“UTF-8”?><!DOCTYPE LearningObject SYSTEM "lo_aktuell.dtd"><LearningObject> <MetaData> <General Identifier="A-5" Structure="Linear"
AggregationLevel="3"><Title>XML</Title> <Language>de</Language> <Description>eXtensible Markup Language (XML)</Description><Keywords>XML</Keywords>
</General> </MetaData> <Content> <LearningObject> <MetaData> <General Identifier="A-5-1" Structure="Linear“
AggregationLevel="2"> <Title>Einführung in (XML)</Title><Language>de</Language> <Description>Einführung in XML</Description> <Keywords>XML</Keywords>
</General> </MetaData> <LayoutInformation CSS-URL="milca.css"/> <Content><Text><Paragraph>Dies ist ein Text.</Paragraph>
</Text></Content>
</LearningObject></Content>
</LearningObject>
<!DOCTYPE Wurzelelement SYSTEM "filename.dtd">
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
Strukturierung von Inhalten
XML zeichnet sich durch folgende Merkmale aus:• Hierarchischer Zusammenhang Teil-Ganzes-Beziehung• Selbstbeschreibende Daten• Text (ASCII, Unicode, oder anderer Zeichensatz)
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
Strukturierung von Inhalten
XML-Instanzen können• wohlgeformt sein
sie genügen der XML-Syntax
- jedes Element besteht aus Start- und Endtag
- Groß- und Kleinschreibung wird unterschieden
• valide sein
sie entsprechen einem Schema (DTD, XML Schema Beschreibung, RELAX NG Schema, Schematron Schema o. a.)
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
Strukturierung von Inhalten
Bisher haben wir uns nur mit (XHTML-) Instanzen beschäftigt, jetzt werden wir eigene
Markupsprachen entwerfen
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
• Grammatik zur Beschreibung einer Markup-sprache
• Elemente
• Attribute
• Liste aller erlaubten Elemente und Attribute
• Gewährleistung struktureller Validität
• Formalisierung der Idee eines Dokumenttyps
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
DTDs sind wie XML-Instanzen Textdateienaber
sie gehorchen einer eigenen Syntax!
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
Eine einfache XML-DTD"visitenkarte.dtd"
<?xml version="1.0"?><!ELEMENT Visitenkarte (Logo, Name, Fachgebiet, Adresse, Telefon_und_Fax, eMail)>
<!ELEMENT Logo EMPTY><!ATTLIST Logo src CDATA #REQUIRED>
<!ELEMENT Name (#PCDATA)>
<!ELEMENT Fachgebiet (#PCDATA)>
<!ELEMENT Adresse (#PCDATA)>
<!ELEMENT Telefon_und_Fax (#PCDATA)>
<!ELEMENT eMail (#PCDATA)>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
Einheiten der Informationsmodellierung• Elemente
• Daten-Elemente
• Container-Elemente
• leere Elemente
• Attribute
• Zeichenketten
• Tokentyp
• Aufzählungen
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
Daten-Elemente• Ebene der konkreten Daten
<!ELEMENT Keyword (#PCDATA)>Deklarationsbeginn
Element-Name
Element-Deklaration
Inhaltsmodell: Zeichenkette
Deklarationsende
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
Beispiel-Instanz
<Keyword>Schifffahrt</Keyword>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
Container-Elemente• Ebene der abstrakten Einheiten
<!ELEMENT Glossary (Keyword+)>
Inhaltsmodell: Container-Element
Okkurenzindikator
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
Beispiel-Instanz
<Glossary><Keyword>Schifffahrt</Keyword>
</Glossary >
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
• Okkurenzindikatoren:
• + 1..n Vorkommen dieses Elements• * 0..n Vorkommen dieses Elements• ? 0..1 Vorkommen dieses Elements• 1 Vorkommen dieses Elements
• Konnektoren:
• , a , b b folgt a• | a | b b oder a
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
Mit Hilfe von Klammern können komplexe Inhaltsmodelle erstellt werden:
<!ELEMENT Glossary (Keyword+)><!ELEMENT Dictionary (Entry+)><!ELEMENT Entry (Keyword+, Gender, Decl?, Definition+)><!ELEMENT Entry ((Keyword+, Gender) |
(Gender, Keyword+)), Decl?, Definition+)>
<!ELEMENT Entry ((Keyword+, Gender) | (Gender, Keyword+)), (Decl, Definition)?)>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
• Das Inhaltsmodell darf nicht ambig sein:
<!ELEMENT a ((b, c) | (b, d))>• ist per definitionem verboten
• führt zum Abbruch der Verarbeitung durch XML-Software
• Ambige Inhaltsmodelle können oft umformuliert werden:
<!ELEMENT a (b, (c | d))>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
Leere Elemente• Als Träger von Attributen
<!ELEMENT Metadata EMPTY>
Inhaltsmodell: leer
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
Beispiel-Instanz
<Metadata/>
<Metadata></Metadata>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
Elemente mit gemischten Inhaltsmodell• Sowohl Daten- als auch Container-Element
<!ELEMENT Keyword (#PCDATA | Gender)*>
Inhaltsmodell: Zeichenkette, Element
Okkurenzindikator: *
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
Elemente mit gemischten Inhaltsmodell• Sowohl Daten- als auch Container-Element
<!ELEMENT Keyword (#PCDATA | Gender)*>
• nur | als Konnektor erlaubt
• nur * als Operator zulässig• PCDATA zuerst
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
DTD – Document Type Definition
Beispiel-Instanz
<Keyword><Gender>m</Gender>Mann.
</Keyword>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Names
Namen in XML (Qualified XML Names)
beginnen mit • einem Buchstaben
• „:“
• „_“
Anschließend folgen• Buchstaben, Zahlen
• „_“, „-“, „.“, „:“
Achtung!• „:“ dient zur Trennung von Präfix und
Element-/Attributnamen (XML Namespaces)
• „xml“ darf nicht Namensbestandteil sein
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Attribute• Informationen über das Element
• Informationen über den Inhalt des Elements
Metadaten
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Attribute in der Instanz• Werte eines Attributs müssen in Anführungszeichen "…" oder '…' stehen
bekannt aus XHTML
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Attribute in der DTD• Attributlistendeklaration sind an eine Element-deklaration gebunden
• Attribute werden immer nur für ein Element deklariert
• es ist möglich (aber nicht ratsam), ein Attribut a für ein Element x und ein anderes Attribut a für y zu deklarieren
• Mehrere Attribute werden in einer Attributlisten-deklaration deklariert
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Attribute in der DTD• Eine Attributlistendeklaration besteht aus:
• dem Namen des Elements, zu dem das Attribut gehört
• dem Namen des Attributs
• dem Attributtyp
• der Vorgabedeklaration
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Ein Beispiel:
<!ELEMENT meaning (#PCDATA)><!ATTLIST meaning style CDATA #IMPLIED >
Element, dem das Attribut zugeordnet ist
Attributname
Inhaltsmodell
Vorgabedeklaration
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Vorgabedeklaration• #IMPLIED• #REQUIRED• Attributwert
• #FIXED Attributwert
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Zeichenketten-Attribut• Inhaltsmodell analog zu Daten-Elementen
• CDATA statt PCDATA Inhalt
<!ELEMENT meaning (#PCDATA)><!ATTLIST meaning style CDATA #IMPLIED >
Deklarationsbeginn
Element, dem das Attribut zugeordnet ist
Attributlisten-Deklaration
Attributname
Inhaltsmodell: CDATAVorgabedeklaration
Deklarationsende
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Beispiel-Instanz
<meaning style="Slang">Cool, ey!
</meaning>Nicht erlaubte Werte:• < (durch < "less than" ersetzen)
• & (durch & ersetzen)
• ' falls Attributwerte mit ' umschlossen werden
• " falls Attributwerte mit " umschlossen werden
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Token-Attribute• ID• IDREF, IDREFS• ENTITY, ENTITIES• NMTKON, NMTOKENS• Aufzählungen
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
ID-Attribut• Speicherung einer dokumentweit eindeutigen ID
• IDs sind aufgebaut wie XML Names
<!ELEMENT keyword (#PCDATA)><!ATTLIST keywordid ID #REQUIRED >
Inhaltsmodell: ID
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Beispiel-Instanz
<keyword id="Schifffahrt">Schifffahrt</keyword>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
IDREF-Attribut• Herstellung einer Referenz zwischen Knoten im Baum
<!ELEMENT variant EMPTY><!ATTLIST variant keyword IDREF #IMPLIED >
Inhaltsmodell: IDREF
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Beispiel-Instanz
<variant keyword="Schifffahrt">Schiffahrt</variant >
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
IDREFS-Attribut• Herstellung einer Referenz zwischen mehreren Knoten im Baum (1:n)
<!ELEMENT variant EMPTY><!ATTLIST variant keyword IDREFS #IMPLIED>
Inhaltsmodell: IDREFS
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Beispiel-Instanz
<variant keyword="Schifffahrt Schiff-Fahrt">Schiffahrt</variant>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Andere Token-Attribute:
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
ENTITY-Attribut• Referenz auf eine generelle Entitität
• Die Entität muss in der DTD deklariert sein
<!ELEMENT logo EMPTY><!ATTLIST logosource ENTITY #IMPLIED>
Inhaltsmodell: ENTITY
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Beispiel-Instanz
<logo source="LogoUB"/>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
ENTITIES-Attribut• Referenz auf mehrere generelle Entititäten
• Die Entitäten müssen in der DTD deklariert sein
<!ELEMENT logo EMPTY><!ATTLIST logosource ENTITIES #IMPLIED>
Inhaltsmodell: ENTITIES
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Beispiel-Instanz
<logo source="LogoUB LogoTT"/>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
NMTOKEN-Attribut• Einschränkung gegenüber Zeichenkettenattributen• XML Names statt CDATA Inhalt (keine Leerzeichen, keine Zahlen an
erster Stelle)
<!ELEMENT file EMPTY><!ATTLIST file name NMTOKEN #IMPLIED>
Inhaltsmodell: NMTOKEN
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Beispiel-Instanz
<file name="readme.txt"/>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
NMTOKENS-Attribut• Auflistung mehrerer NMTOKEN
<!ELEMENT files EMPTY><!ATTLIST files names NMTOKENS #IMPLIED>
Inhaltsmodell: NMTOKEN
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Beispiel-Instanz
<files names="readme.txt liesmich.txt"/>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Aufzählung• Vokabular möglicher Werte (NMTOKEN)
• Vorgabedeklaration kann durch Standardwert ersetzt werden
<!ELEMENT spelling (#PCDATA)><!ATTLIST spelling orthography (old | new) "new">
Inhaltsmodell: Wertevokabular
Vorgabedeklaration oder Standardwert
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Beispiel-Instanz
<spelling orthography="old">Schiffahrt </spelling>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Elemente oder Attribute?+ Elemente strukturieren Informationen
+ Elementinhalt direkt prozessierbar
- Elementinhalt nur PCDATA, keine weiteren Restriktionen möglich
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Attribute
Elemente oder Attribute?+ Attributinhalt CDATA+ Attribute können Vorgabewerte enthalten
+ ID/IDREF-Attribute sind unverzichtbar zur Herstellung von Beziehungen
- Attribute können nicht strukturieren
- Attribute speichern Informationen über Elemente
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
Entitäten
Entitäten• Platzhalter für Daten
• Generelle Entitäten (general entities) als Platzhalter in Instanzen
• Parameter-Entitäten (parameter entities) als Platzhalter in DTDs
• Interne und externe Entitäten
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
Entitäten
Entitäten• HTML enthält einige vordefinierte interne general entities:
• < „<“• > „>“• ü „ü“• & „&“
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Namespaces
XML Namespaces• Namespaces kennzeichnen eine Markupsprache als einem Namensraum
zugehörig
• Sie erlauben die Kombination verschiedener Markupsprachen (z.B. XHTML inkl. SVG)
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Namespaces
Aufbau eines Namespaces
Präfix:Element-/Attributname
Beispiel
<mml:math>…</mml:math>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Namespaces
Definition eines Namespaces mit Hilfe des Attributs
xmlns
xmlns:Präfix="URL"
Beispielxmlns:mml="http://www.w3.org/1998/Math/MathML"
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Namespaces
Beispiel Instanz<paragraph>
Dies ist ein Satz mit einer <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML">…</mml:math> Formel, die in MathML dargestellt wird.
</paragraph>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Namespaces
Namespaces müssen in der DTD deklariert werden
<!ELEMENT Formula (%math.qname;)*><!ATTLIST Formula
xmlns:mml CDATA #FIXED "http://www.w3.org/1998/Math/MathML"xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Namespaces
Standard (default) Namespaces benötigen kein Präfix und gelten für alle Kindelemente
<html xmlns=http://www.w3.org/1999/xhtml><head><title>Eine XHTML-Seite</title></head><body>…</body></html>
Default Namespace von XHTML
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
XML Software Tools
XML Software-Tools• XML Parser
• freie Parser: XML Validator, Schematron Validator, xmllint
• Editoren
• freie Editoren: Notepad, XML Mind XML Editor, Treebeard, jEdit
• kommerzielle Editoren: XMetaL, XMLSpy, <oXygen>
http://www.text-technology.de/projects/sekimo.html
Text TechnologicalModelling of Information
Übungsaufgaben
Praxis• Erstellen Sie eine DTD analog zur HTML-Seite• Erstellen Sie eine Instanz, die valide zur DTD ist
Top Related