XML ist eine standardisierte, erweiterbare Auszeichnungssprache zur Erstellung maschinen- und menschenlesbarer Dokumente.
XML wird als universelles Datenformat bezeichnet, das insbesondere nicht auf Webdokumente beschränkt ist.
Ein XML-Dokument wird üblicherweise von einer Software(komponente) verarbeitet. Diese bezeichnet man üblicherweise als den XML-Parser.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Recipe name="bread" prep_time="5 mins" cook_time="3 hours"> <title>Basic bread</title> <ingredient amount="3" unit="cups">Flour</ingredient> <ingredient amount="0.25" unit="ounce">Yeast</ingredient> <ingredient amount="1.5" unit="cups">Warm Water</ingredient> <ingredient amount="1" unit="teaspoon">Salt</ingredient> <Instructions> <step>Mix all ingredients together, and knead thoroughly.</step> <step>Cover with a cloth, and leave for one hour in warm room.</step> <step>Knead again, place in a tin, and then bake in the oven.</step> </Instructions> </Recipe>
[Quelle: Wikipedia]
Muss immer am Anfang eines XML-Dokuments stehen
<?xml version="1.0" [encoding="{Zeichensatz}"] [standalone="{yes|no}"] ?>
Verarbeitungsanweisungen (Processing Instructions) sind Direktiven an den XML-Parser, spezielle Verarbeitungsschritte an bestimmte Programme/-komponenten zu delegieren.
Syntax
<?pi-name [attribute1] ... [attributeN]?>
Beispiele
<?xml-stylesheet type="text/css" href="print.css"?> <?xml-stylesheet type="text/xsl" href="sample.xsl" ?> <?xul-overlay href="chrome://test/content/myOverlayxul"?>
Obwohl die XML-Deklaration dieselbe Syntax besitzt, ist diese keine Verarbeitungsanweisung.
Kommentare sind Notizen für den Autor des XML-Dokuments oder für andere menschliche Leser (in Ausnahmefällen für verarbeitende Software), die vom XML-Parser überlesen wird.
Syntax
<!-- Kommentar Text -->
CDATA-Anweisungen werden vom XML-Parser als nicht weiter zu untersuchender Block von Zeichendaten (character data) gehandhabt.
Syntax
<![CDATA[ Zeichenfolge ]]>
Beispiel
<raw-data> <![CDATA[ a > b && c < d ]]> </raw-data>
Gewisse Zeichen, die in XML-Dokumenten eine besondere Bedeutung haben, müssen etwas anders geschrieben werden:
Zeichen | Notation in XML |
< | < |
> | > |
& | & |
" | " |
' | ' |
Ein XML-Dokument besteht aus genau einem Wurzelelement (root element).
Syntax
<element [attr1="value1"] ... [attrN="valueN"]> content </element>
XML-Elemente bestehen aus …
Der Inhalt von Elementen kann …
Syntax: <Name [Attribut]*>PCDATA</Name>
Beispiel
<paragraph id="p5"> some text. some text. some text. some text. some text. some text. some text. some text. some text. some text. </paragraph>
Syntax: <Name [Attribut]*>Element+</Name>
Beispiel
<section level="2"> <subsection> some text. some text. </subsection> <subsection> some other text. </subsection> </section>
Syntax: <Name [Attribut]*>[PCDATA|Element]+</Name>
Beispiel
<paragraph> some text. some text. some text. some text. some text. some text. some text. some text. some text. some text.<section> <section> <subsection> inner text. inner text. </subsection> <subsection> more inner text. </subsection> </section> some other text. some other text. some other text. </paragraph>
Syntax: <Name [Attribut]* />
Beispiel
<br/> <image src="smiley.png" /> <date y="2005" m="feb" d="23" />
name="wert"
oder name='wert'
.winkel="12°45\'23\""
Wann also Attribute und wann Elemente verwenden?
<student name="smith" firstname="eric" matnr="123456789" />
oder
<student> <name>smith</name> <firstname>eric</firstname> <matnr>123456789</matnr> </student>
Ein nichtvalidierender Parser prüft ein XML-Dokument auf Wohlgeformtheit (wellformed document).
_
: z.B. first, First oder _First
-
und .
erlaubt: z.B. _1st-name oder _1st.name
.:
.xml
, unabhängig davon, ob die einzelnen Buchstaben groß- oder kleingeschrieben sind.XML ist die Mutter einer Familie standardisierter Markup Sprachen.
XHTML ist eine Neuformulierung von HTML auf der Basis von XML.
Vorteile
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Titel</title> <meta name="herkunft" content="fh lippe & höxter"/> <link rel="stylesheet" type="text/css" href="/css/main.css" media="all" /> </head> <body> Inhalt </body> </html>
<body/>
statt <BODY>
).<br/>
statt <br>
).<br/>
statt <br>
).checked="checked"
statt checked
).id
-Attribut statt des name
-Attributes.CSS ist …
Syntax
<link rel="stylesheet" media="{target}" href="{url}" />
Beispiel
<html> <head> <title>Webdokument</title> <link rel="stylesheet" media="screen" href="seite.css" /> <link rel="stylesheet" media="print" href="druck.css" /> <link rel="stylesheet" media="projection" href="slides.css" /> </head> <body> </body> </html>
Syntax
<style type="text/css"> <![CDATA[ /* Formatinformation */ ]]>
Beispiel
<html> <head> <title>Webdokument</title> <style type="text/css"> <![CDATA[ @media print { /* Drucken ... */ /* ... */ } @media screen { /* Bildschirm */ /* ... */ } ]]> </style> </head> <body> </body> </html>
Syntax
<Name style=" /* ... */ "> [Inhalt]</Name>
Beispiel
<html> <head> <title>Webdokument</title> </head> <body style="/* ... */"> <h1 style="/* ... */">...</h1> </body> </html>
Selector {property1: value1; ...; propertyN: valueN; }
Pattern | Meaning |
* | Matches any element. |
E | Matches any E element (i.e., an element of type E). |
E F | Matches any F element that is a descendant of an E element. |
E > F | Matches any F element that is a child of an element E. |
E:first-child | Matches element E when E is the first child of its parent. |
E:link E:visited | Matches element E if E is the source anchor of a hyperlink of which the target is not yet visited (:link) or already visited (:visited). |
E:active E:hover E:focus | Matches E during certain user actions. |
E:lang(c) | Matches element of type E if it is in (human) language c (the document language specifies how language is determined). |
E + F | Matches any F element immediately preceded by an element E. |
E[foo] | Matches any E element with the "foo" attribute set (whatever the value). |
E[foo="warning" ] | Matches any E element whose "foo" attribute value is exactly equal to "warning". |
E[foo~="warning" ] | Matches any E element whose "foo" attribute value is a list of space-separated values, one of which is exactly equal to "warning". |
E[lang|="en" ] | Matches any E element whose "lang" attribute has a hyphen-separated list of values beginning (from the left) with "en". |
DIV.warning | HTML only. The same as DIV[class~="warning" ]. |
E#myid | Matches any E element ID equal to "myid". |
[Quelle: W3C]
SelfHTML bietet eine gute Übersicht über alle CSS 2.1 Eigenschaften.