Datenspeicherung mit XML Ulf Schaper Kulturerbe digital Methoden der Informatik zur Erschließung der kulturellen Überlieferung (Sommerakademie Greifswald 2008) 25. August 2008
Was euch erwartet: Übersicht Dateiformate im Wandel anno 1998 anno 2008 Eine XML-Datei zum Anfassen Kurzbesuch bei XSL Was sind Namespaces? Standards setzen: XML Schema
Dateiformate 1998 ein paar Negativbeispiele Fette Schrift in Word (.doc ) Spielstände im Hexeditor (.sav ) Messfahrt im BMW 335i (.mdf ) Fotos bestaunen (.bmp )
Dateiformate 2008 weitere schlechte Beispiele Frames in Filmen (.avi ) Dokumente (.pdf ) gute Beispiele Vektorgrafiken (.svg ) Office-Dateien (.odt ) Messfahrt im Mini Cooper S Clubman (.xml )
XML: Textbasierte Datenspeicherung Extensible Markup Language viele abgeleitete Dateiformate breites Spektrum zwischen Maschinen- und Menschenlesbarkeit Was gibt es darin? Kopfzeile/Prolog Elemente (in einer Baumstruktur) Attribute Kommentare
XML: Ein Beispiel zu unserer Arbeitsgruppe <? xml v e r s i o n= 1. 0 e n c o d i n g= UTF 8 s t a n d a l o n e= y e s?> <sommerakademie ort= Greifswald j a h r= 2008 > <person typ= Akademieleiter >Thomas Ludwig</ person> <p e r s o n typ= A k a d e m i e l e i t e r >C h r i s t i n e Schade</ p e r s o n> <person typ= Gastwirt /> <a r b e i t s g r u p p e nr= 3 > < t i t e l>w a s s e r w e l l e n : Phaenomene und Seemannsgarn</ t i t e l> <p e r s o n typ= G r u p p e n l e i t e r >N o r b e r t Hoffmann</ p e r s o n> <p e r s o n typ= G r u p p e n l e i t e r >N i k o l a y V i t a n o v</ p e r s o n> <! to do: Teilnehmer nachtragen! > </ a r b e i t s g r u p p e> <a r b e i t s g r u p p e nr= 4 > < t i t e l>k u l t u r e r b e d i g i t a l</ t i t e l> <p e r s o n typ= G r u p p e n l e i t e r >Guenther Goerz</ p e r s o n> <p e r s o n typ= G r u p p e n l e i t e r >J o s e f S c h n e e b e r g e r</ p e r s o n> <p e r s o n>sandro Bauer</ p e r s o n> <p e r s o n>s a s k i a Becker</ p e r s o n> <p e r s o n>p h i l i p Heck</ p e r s o n> <p e r s o n>rick Hegewald</ p e r s o n> <p e r s o n>benjamin H o l f e l d</ p e r s o n> <p e r s o n>reha B a r i s I n c e s u</ p e r s o n> <p e r s o n>c h r i s t i n a K r i e g l s t e i n</ p e r s o n> <person>j u l i a Kuehne</ person> <p e r s o n>helen Maucher</ p e r s o n> <p e r s o n>k a t j a Monika Poellmann</ p e r s o n> <p e r s o n>soeren P r e i b u s c h</ p e r s o n> <p e r s o n>j u l i a n Raschke</ p e r s o n> <p e r s o n>rebecca Rosenlund</ p e r s o n> <p e r s o n>u l f Schaper</ p e r s o n> <p e r s o n>karen Schewina</ p e r s o n> <p e r s o n>o l a f W i t t e n s t e i n</ p e r s o n> </ a r b e i t s g r u p p e> </ sommerakademie>
XSL: Transformationen von XML zu *.* Extensible Stylesheet Language Ziele: HTML, XML, PDF,... Datenbank-ähnliche Abfragen möglich Beispiele Liste aller Arbeitsgruppen anzeigen Liste aller Personen mit Status Gruppenleiter...
XSL: Arbeitsgruppenleiter herausfiltern <? xml v e r s i o n= 1. 0 e n c o d i n g= UTF 8?> <x s l : s t y l e s h e e t v e r s i o n= 1. 0 x m l n s : x s l= h t t p : //www. w3. org /1999/XSL/ Transform > <x s l : o u t p u t method= html i n d e n t= y e s e n c o d i n g= UTF 8 /> <x s l : t e m p l a t e match= sommerakademie > <html><body><h1>g r u p p e n l e i t e r i n <x s l : v a l u e o f s e l e c t= @ort /></h1><u l> <x s l : f o r each s e l e c t= / p e r s o n > < x s l : i f t e s t= @typ= G r u p p e n l e i t e r > < l i><x s l : v a l u e o f s e l e c t=. /></ l i> </ x s l : i f> </ x s l : f o r each> </ u l></ body></ html> </ x s l : t e m p l a t e> </ x s l : s t y l e s h e e t> <? xml v e r s i o n= 1. 0 e n c o d i n g= UTF 8?> <? xml s t y l e s h e e t t y p e= t e x t / x s l h r e f= s o m m e r a k a d e m i e g r e i f s w a l d. x s l?> <sommerakademie ort= Greifswald j a h r= 2008 > <a r b e i t s g r u p p e nr= 1 > <p e r s o n typ= G r u p p e n l e i t e r > Stephan G i e l e n</ p e r s o n> <p e r s o n typ= G r u p p e n l e i t e r > V o l k e r Adams</ p e r s o n>... </ a rbei tsg ruppe nr= 1 >...
Namespaces: Verschiedene XML-Formate kombinieren Beispiele SVG in XHTML einbinden MathML in SVG einbinden Umsetzung entweder immer mit angeben: <svg xmlns="http://www.w3.org/2000/svg">... </svg> oder Präfix definieren: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:m="http://www.w3.org/1999/math/mathml"> <m:math>... </m:math> </html>
Namespaces: Eine Vektorgrafik in einer HTML-Datei <html xmlns= h t t p : //www. w3. org /1999/ xhtml > <body> <p>dies i s t HTML Code. Es f o l g t e i n SVG B i l d :</p> <svg xmlns= h t t p : //www. w3. org /2000/ svg > <g t r a n s f o r m= t r a n s l a t e ( 131, 141) > <path d= M 386,268 A 127,127 0 1 1 131,268 A 127,127 0 1 1 385,268 z s t y l e= f i l l : #f f e b 0 0 ; /> <path d= M 251,229 A 30,28 0 1 1 191,229 A 30,28 0 1 1 251,229 z t r a n s f o r m= t r a n s l a t e ( 12, 2) /> <path d= M 251,229 A 30,28 0 1 1 191,229 A 30,28 0 1 1 251,229 z t r a n s f o r m= t r a n s l a t e (87, 2) /> <path d= M 270,572 A 80,68 0 0 1 119,572 t r a n s f o r m= t r a n s l a t e (68, 271) s t y l e= f i l l : n o n e ; s t r o k e : #000000; s t r o k e w i d t h : 3 0 ; /> </g></ svg> </ body></ html>
XML Schema XML diktiert nur die Syntax SVG, XHTML, MathML,... sind eigene Dateiformate! Mit einem Schema werden diese Formate spezifiziert. Beispiele In einer SVG-Datei dürfen Pfade gruppiert werden, indem ihnen ein <g>...</g>-element übergeordnet wird. Eine Sommerakademie besteht aus einer oder mehr Arbeitsgruppen.
Schema für das Sommerakademie-Beispiel I <xsd:schema xmlns: xsd= h t t p : //www. w3. org /2001/XMLSchema > <x s d : a n n o t a t i o n> <x s d : d o c u m e n t a t i o n x m l : l a n g= de > Schema f u e r Sommerakademie Daten. E r s t e l l t von U l f Schaper, u l f s c h a p e r @ g m x. de, August 2008 </ x s d : d o c u m e n t a t i o n> </ x s d : a n n o t a t i o n> <x s d : e l e m e n t name= sommerakademie t y p e= SommerakademieTyp /> <xsd:complextype name= SommerakademieTyp > <x s d : s e q u e n c e> <xsd: element name= person minoccurs= 0 maxoccurs= unbounded t y p e= PersonTyp /> <xsd: element name= arbeitsgruppe minoccurs= 0 maxoccurs= unbounded type= ArbeitsgruppeTyp /> </ x s d : s e q u e n c e> <x s d : a t t r i b u t e name= o r t t y p e= x s d : s t r i n g /> <x s d : a t t r i b u t e name= j a h r t y p e= x s d : d e c i m a l /> </ xsd:complextype>...
Schema für das Sommerakademie-Beispiel II... <xsd:complextype name= ArbeitsgruppeTyp > <x s d : s e q u e n c e> <x s d : e l e m e n t name= t i t e l minoccurs= 0 t y p e= x s d : s t r i n g /> <xsd: element name= person minoccurs= 0 maxoccurs= unbounded t y p e= PersonTyp /> </ x s d : s e q u e n c e> <x s d : a t t r i b u t e name= nr t y p e= x s d : d e c i m a l /> </ xsd:complextype> <xsd:complextype name= PersonTyp mixed= true > <x s d : a t t r i b u t e name= typ t y p e= P e r s o n e n T y p A t t r i b u t d e f a u l t= T e i l n e h m e r /> </ xsd:complextype> <xsd: simpletype name= PersonenTypAttribut > <x s d : r e s t r i c t i o n base= x s d : s t r i n g > <xsd: enumeration value= Akademieleiter /> <xsd: enumeration value= Gastwirt /> <x s d : e n u m e r a t i o n v a l u e= G r u p p e n l e i t e r /> <xsd: enumeration value= Teilnehmer /> </ x s d : r e s t r i c t i o n> </ x s d : s i m p l e T y p e> </ xsd:schema>
Vielen Dank für Eure Aufmerksamkeit!
Die Siedler im Hexeditor (vorher)
Die Siedler im Hexeditor (nachher) anno 1998
Eine Messfahrt im BMW 335i bei ca. 400Nm anno 1998
test.doc Dateigröße unverändert 52224 Bytes, davon ändern sich 404 Bytes durch Fettschrift,... nur nicht dort wo man sucht.
test.doc, jetzt mit Fettschrift Dateigröße unverändert 52224 Bytes, davon ändern sich 404 Bytes durch Fettschrift,... nur nicht dort wo man sucht. anno 1998
Ein Schachbrett als 8x8-BMP-Bild 0000000 4d42 00f6 0000 0000 0000 00b6 0000 0028 0000010 0000 0008 0000 0008 0000 0001 0008 0000 0000020 0000 0040 0000 0b13 0000 0b13 0000 0020 0000030 0000 0020 0000 0000 0000 0707 0007 0f0f 0000040 000f 1717 0017 1f1f 001f 2727 0027 2f2f 0000050 002f 3737 0037 3f3f 003f 4747 0047 4f4f 0000060 004f 5757 0057 5f5f 005f 6767 0067 6f6f 0000070 006f 7777 0077 7f7f 007f 8787 0087 8f8f 0000080 008f 9797 0097 9f9f 009f a7a7 00a7 afaf 0000090 00af b7b7 00b7 bfbf 00bf c7c7 00c7 cfcf 00000a0 00cf d7d7 00d7 dfdf 00df e7e7 00e7 efef 00000b0 00ef f7f7 00f7 001f 001f 001f 001f 1f00 00000c0 1f00 1f00 1f00 001f 001f 001f 001f 1f00 00000d0 1f00 1f00 1f00 001f 001f 001f 001f 1f00 00000e0 1f00 1f00 1f00 001f 001f 001f 001f 1f00 00000f0 1f00 1f00 1f00 Das Schachbrettmuster ist in der Datei wieder zu erkennen. anno 1998
Ein.avi-Video mit zwei Frames 0001fc0 0000 0000 0000 0000 0000 0000 0000 0000 0001fd0 0000 0000 0000 0000 0000 0000 0000 0000 0001fe0 0000 0000 0000 0000 0000 0000 0000 0000 0001ff0 0000 0000 0000 0000 0000 0000 0000 0000 0002000 494c 5453 0194 0000 6f6d 6976 3030 6264 0002010 00c0 0000 f7f7 00f7 0000 f7f7 00f7 0000 0002020 f7f7 00f7 0000 f7f7 00f7 0000 0000 f700 0002030 f7f7 0000 f700 f7f7 0000 f700 f7f7 0000 0002040 f700 f7f7 f7f7 00f7 0000 f7f7 00f7 0000 0002050 f7f7 00f7 0000 f7f7 00f7 0000 0000 f700 0002060 f7f7 0000 f700 f7f7 0000 f700 f7f7 0000 0002070 f700 f7f7 f7f7 00f7 0000 f7f7 00f7 0000 0002080 f7f7 00f7 0000 f7f7 00f7 0000 0000 f700 0002090 f7f7 0000 f700 f7f7 0000 f700 f7f7 0000 00020a0 f700 f7f7 f7f7 00f7 0000 f7f7 00f7 0000 00020b0 f7f7 00f7 0000 f7f7 00f7 0000 0000 f700 00020c0 f7f7 0000 f700 f7f7 0000 f700 f7f7 0000 00020d0 f700 f7f7 3030 6264 00c0 0000 f7f7 7ff7 00020e0 0000 f7f7 7ff7 0000 f7f7 7ff7 0000 f7f7 00020f0 7ff7 0000 007f f700 f7f7 007f f700 f7f7 0002100 007f f700 f7f7 007f f700 f7f7 f7f7 7ff7 0002110 0000 f7f7 7ff7 0000 f7f7 7ff7 0000 f7f7 0002120 7ff7 0000 007f f700 f7f7 007f f700 f7f7 0002130 007f f700 f7f7 007f f700 f7f7 f7f7 7ff7 0002140 0000 f7f7 7ff7 0000 f7f7 7ff7 0000 f7f7 0002150 7ff7 0000 007f f700 f7f7 007f f700 f7f7 0002160 007f f700 f7f7 007f f700 f7f7 f7f7 7ff7 0002170 0000 f7f7 7ff7 0000 f7f7 7ff7 0000 f7f7 0002180 7ff7 0000 007f f700 f7f7 007f f700 f7f7 0002190 007f f700 f7f7 007f f700 f7f7 6469 3178 00021a0 0020 0000 3030 6264 0010 0000 0004 0000 00021b0 00c0 0000 3030 6264 0010 0000 00cc 0000 00021c0 00c0 0000 Der Übergang zwischen beiden Frames ist kaum zu erkennen. anno 2008
Eine kleine PDF-Datei Test! anno 2008
Vektorgrafik (.svg) mit Smiley <? xml v e r s i o n= 1.0 encoding= UTF 8 standalone= no?> <! Created with Inkscape ( h t t p : //www. inkscape. org /) > <svg xmlns= h t t p : //www. w3. org /2000/ svg > <g t r a n s f o r m= t r a n s l a t e ( 131, 141) > <path d= M 386,268 A 127,127 0 1 1 131,268 A 127, 127 0 1 1 385,268 z s t y l e= f i l l : #f f e b 0 0 ; /> <path d= M 251,229 A 30,28 0 1 1 191,229 A 30,28 0 1 1 251,229 z t r a n s f o r m= t r a n s l a t e ( 12, 2) /> <path d= M 251,229 A 30,28 0 1 1 191,229 A 30,28 0 1 1 251,229 z t r a n s f o r m= t r a n s l a t e (87, 2) /> <path d= M 270,572 A 80,68 0 0 1 119,572 t r a n s f o r m= t r a n s l a t e (68, 271) s t y l e= f i l l : n o n e ; s t r o k e : #000000; s t r o k e w i d t h : 3 0 ; /> </g> </ svg> anno 2008
Textdatei (.odt) mal näher untersucht Test! Archive:../textdatei_word_normal.odt extracting: mimetype creating: Configurations2/statusbar/ inflating: Configurations2/accelerator/current.xml creating: Configurations2/floater/ creating: Configurations2/popupmenu/ creating: Configurations2/progressbar/ creating: Configurations2/menubar/ creating: Configurations2/toolbar/ creating: Configurations2/images/Bitmaps/ inflating: content.xml inflating: styles.xml extracting: meta.xml inflating: Thumbnails/thumbnail.png inflating: settings.xml inflating: META-INF/manifest.xml
.odt: Was steht in der content.xml? <?xml version="1.0" encoding="utf-8"?> <office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer"... <office:automatic-styles><style:style style:name="p1" style:family="paragraph" style:parent-style-name="standard" style:master-page-name="standard"> <style:paragraph-properties style:page-number="auto"/><style:text-properties fo:font-size="60pt" style:font-size-asian="60pt" style:font-size-complex="60pt"/> </style:style></office:automatic-styles> <office:body><office:text> <text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="illustration"/><text:sequence-decl text:display-outline-level="0" text:name="table"/><text:sequence-decl text:display-outline-level="0" text:name="text"/><text:sequence-decl text:display-outline-level="0" text:name="drawing"/></text:sequence-decls> <text:p text:style-name="p1">test!</text:p> </office:text></office:body></office:document-content> anno 2008
Messfahrt im Mini Cooper S Clubman <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet type="text/xsl" href="auswertung_verbrauch.xsl"?> <resultlist counter="104" complete="false" this="auswertung_verbrauch.xml"> <result num="1"> <data> <name>20080411_democar_attest_01.dat</name> </data> <date>02.07.2008</date> <time>10:45:03</time> <file num="0" filefilter="mdf"> <description>errechnung des Verbrauchs in g/kwh</description> <event cred="1.0" id="1"> <extradata> <Messdauer>0.09</Messdauer> <Motordrehzahl>2401.3026315789475</Motordrehzahl> <Moment>117.36842105263158</Moment> <Verbrauch_lph>10.68</Verbrauch_lph> <Verbrauch_gkWh>277.2395477586155</Verbrauch_gkWh> <Leistung_avg>29508.344195983384</Leistung_avg> <momentaner_verbrauch_start>28431.0</momentaner_verbrauch_start> <momentaner_verbrauch_ende>28698.0</momentaner_verbrauch_ende> <StartTime>21.984231490041438</StartTime> <n_motor_diff>1.0</n_motor_diff> <Moment_diff>0.0</Moment_diff> </extradata> </event> </file> </result>... </resultlist> anno 2008