XML |
<?xml version=1.0?> <p:part xmlns:p="http://www.mywebsite.com/PartSchema" xsi:schemaLocation = "http://www.mywebsite.com/PartSchema http://www.mywebsite.com/PartSchema" name="nutbolt"> <mfg>Acme</mfg> <price>10.50</price> </p:part> |
Zugehöriges Schema |
<xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema" targetNamespace="http://www.mywebsite.com/PartSchema"> <xsd:element name="part" type="part_type"> <xsd:complexType name="part_type"> <xsd:element name = "mfg" type="xsd:string"/> <xsd:element name = "price" type="xsd:decimal"/> <xsd:attribute name = "name" type="xsd:string"/> </xsd:complexType> </xsd:element> </xsd:schema> |
XSLT Anweisungen (Templates) für
die Formatierung eines Textes wie
<?xml version="1.0" encoding="utf-8"?> <buch> <chapter> <title>Preface</title> <para>This is a simple test document. It shows a <emphasis>partial</emphasis> fo-result tree (page layout missing). </para> </chapter> </buch> |
Das resultierenden Dokument wird durch einen "Formatierer" in eine Darstellung (Druck, Browser) übersetzt. |
<xsl:template match="chapter"> <fo:flow> <xsl:apply-templates/> </fo:flow> </xsl:template> <xsl:template match="chapter/title"> <fo:block font-size="18pt" font-weight="bold" text-align="centered"> <xsl:apply-templates/> </fo:block> </xsl:template> <xsl:template match="para"> <fo:block font-size="12pt" space-before="1pc" text-align="justified"> <xsl:apply-templates/> </fo:block> </xsl:template> <xsl:template match="emphasis"> <fo:inline font-style="italic"> <xsl:apply-templates/> </fo:inline> </xsl:template> |
<?xml version="1.0" encoding="utf-8"?> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> ... <fo:page-sequence> <fo:flow> <fo:block font-size="18pt" font-weight="bold" text-align="centered"> Preface </fo:block> <fo:block font-size="12pt" space-before="1pc" text-align="justified"> This is a simple test document. It shows a <fo:inline font-style="italic">partial</fo:inline> fo-result tree (page layout missing). </fo:block> </fo:flow> </fo:page-sequence> ... </fo:root> |
H1 {
font-size: 12pt;
font-weight: bold;
color: blue;
}
Beispiel:
XML | Stylesheet buch.css | |
<?xml version="1.0" encoding="utf-8"?> <?xml:stylesheet type="text/css" href="buch.css"?> <buch> <chapter> <title>Preface</title> <para>This is a simple test document. It shows a <emphasis>partial</emphasis> fo-result tree (page layout missing). </para> </chapter> </buch> |
title, para { display: block } emphasis { display: inline } title { color:blue; font-size: 30pt } para { color:red; font-size: 15pt } emphasis { font-weight:bold; color:green } |
Ergebnis |
Es gibt mehrere Level des DOM, Level 0 ist das in Netscape Navigator
3.0 und Microsoft Internet Explorer 3.0 implementierte.
Level 1: der obige Standard
Level 2: zur Zeit "Candidate Recommendation": "style sheet object model",
Manipulation von "style information", "event model", "XML namespaces".
Level 3: (Zukunft) Laden und Speichern von Dokumenten und Inhlatsmodellen
(DTDs und Schemata). Anzeige und Formatierung, "key events", "event groups".
"Further levels. These may specify some interface with the possibly
underlying window system, including some ways to prompt the user. They
may also contain a query language interface, and address multithreading
and synchronization, security, and repository."