Extensible Markup Language (XML)

XML definiert ein Datenformat für hierarchisch gegliederte Informationen.

Beispiel

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="transformer.xsl"?>
<!DOCTYPE root [ … ]>
<root xmlns:xlink="http://www.w3.org/1999/xlink">
  <message xlink:href="http://www.illusioni.de/~phrank#xpointer(/body)">
    Hello, World!
  </message>
</root>

XML Core Syntax

Nicht-Terminal Terminale Kommentar
document = declaration *misc [ doctype ] element *misc
Vorspann
declaration = <?xml version [ encoding ] [ standalone ] ?>
version = version= DQUOTE 1.0 DQUOTE
encoding = encoding= DQUOTE ( UTF-8 / ISO-8859-1 / ... ) DQUOTE
standalone = standalone= DQUOTE ( yes / no ) DQUOTE
misc = comment / pi / stylesheet
stylesheet = <?xml-stylesheet type href [ title ] [media ] [ charset ] [ alternate ] ?>
type = type= DQUOTE text/xsl DQUOTE
href = href= uri
title = title= qstring
media = media= DQUOTE ( screen / print / ... ) DQUOTE
charset = charset= DQUOTE ( UTF-8 / ISO-8859-1 / ... ) DQUOTE
alternate = alternate= DQUOTE ( yes / no ) DQUOTE
doctype = <!DOCTYPE name ( PUBLIC identifier uri / SYSTEM uri / [ dtd ] ) >Wurzelelement
identifier = qstring / DQUOTE -//W3C//DTD XHTML 1.1//EN DQUOTEKatalogschluessel
uri = qstring / DQUOTE http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd DQUOTEDokumenttyp-Definition
Inhalt
element = emptytag / starttag content endtag
emptytag = < name *attribute />
starttag = < name *attribute >
endtag = </ name >
attribute = xlink / name = qstring
content = *( *CHAR / cdata / entityref / comment / pi / element )
cdata = <![CDATA[ *CHAR ]]>
entityref = & name ;
comment = <!-- *CHAR -->
pi = <? *CHAR ?>
Immer
qstring = DQUOTE *CHAR DQUOTE
name = ALPHA *( ALPHA / DIGIT / _ / - / : )

XLink Syntax

Mit XLink kann man Dokumente zueinander in Beziehung setzen

Nicht-Terminal Terminale Kommentar
=href / role / title / type / show / actuate
href =xlink:href = uri
role =xlink:role = uri
title =xlink:title = string
type =xlink:type = ...
DQUOTE simple DQUOTE
/DQUOTE extended DQUOTE
/DQUOTE locator DQUOTE
/DQUOTE arc DQUOTE
/DQUOTE title DQUOTE
/DQUOTE resource DQUOTE
show =xlink:show = ...
DQUOTE new DQUOTE Zieldokument in Neuem Fenster öffnen
/DQUOTE replace DQUOTE Zieldokument ins aktuellen Fesnter laden
/DQUOTE embed DQUOTE Zieldokumenet einbetten
/DQUOTE other DQUOTE Verhalten wird durch andere Elemente gesteuert
/DQUOTE none DQUOTE Anwendung entscheidet
actuate =xlink:actuate = ...
DQUOTE onLoad DQUOTE Link beim Laden folgen
/DQUOTE onRequest DQUOTE Link auf Anfrage folgen
/DQUOTE other DQUOTE Verhalten wird durch andere Elemente gesteuert
/DQUOTE none DQUOTE Anwendung entscheidet

Werkzeuge

Prüfe Validität gegen die im Dokument angegebene Dokumettyp-Definition
xmllint --noout data.xml
Prüfe Validität gegen RelaxNG-Schema
xmllint --noout --relaxng schema.rng data.xml
Formatiere neu und rücke ein
XMLLINT_INDENT=" " xmllint --format data.xml
Konvertiere HTML nach XML
xmllint --html --xmlout page.html > page.xhtml
Transformiere mit dem im Dokument angegebenen Stylesheet
xsltproc data.xml
Transformiere mit externem Stylesheet
xsltproc style.xsl data.xml
Extrahiere einen Knotensatz mit XPath
xpath -e expression data.xml
Flache Hierarchie aller Knoten in XPath-Ausdrücke ab
xml2 < data.xml

Literatur