transformations-mechanismen für semistrukturierte daten
DESCRIPTION
Transformations-mechanismen für semistrukturierte Daten. Transformation - Gliederung. Einleitung Cascading Stylesheets (CSS) Extensible Stylesheet Language (XSL) Transformation XSLT – XSL Transformations Formatobjekte YAT. Einleitung CSS XSL XSLT Formating Objects YAT. - PowerPoint PPT PresentationTRANSCRIPT
Interoperable Informationssysteme - 1Klemens Böhm
Transformations-mechanismen für
semistrukturierte Daten
Interoperable Informationssysteme - 2Klemens Böhm
Transformation - Gliederung
Einleitung Cascading Stylesheets (CSS) Extensible Stylesheet Language (XSL)
TransformationXSLT – XSL Transformations
Formatobjekte YAT
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 3Klemens Böhm
Logische Struktur vs. Layout-Struktur Logische Dokumentbestandteile -
Elementtypen können beliebige Bedeutung haben,
Layout-Struktur - Darstellung des Dokuments.users/boehm/Windows/temp/Sample/simple.xmlAussprache, ‚AudioWeb‘
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 4Klemens Böhm
Architekturüberlegungen
Client, insbes.
‘alte’ Browser
Layout-Konvert.
Server
Client, z.B. IE5.0
Layout-Konvert
.
Server
Client
Konvert.
Server
Proxy/Firewall
Konvert.
Server
Client, z.B. IE5.0
Konvert.
Wann könnte serverseitige Konvertierung sinnvoll/vorteilhaft sein?
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 5Klemens Böhm
Stylesheets für XML Beschreiben, wie Dokumente
mit irgendeinem Medium dargestellt werden Es gibt zwei Sprachen
mit unterschiedlichen Fähigkeiten: CSS (‚Cascading Stylesheets‘) -
auch für HTML, keine Transformation, XSL -
auch Transformationen.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 6Klemens Böhm
CSS - Eigenschaften Komplementär zu
strukturierten Dokumenten,d.h. komplementaer zur Dokumenterstellung
plattformunabhängig, einfach, flexibel durch Cascading,
d.h. Kombination mehrerer Stylesheets
erlaubt Einbettung von Scripts.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 7Klemens Böhm
Aufbau von CSS-Stylesheets Begriffsbildung:
selector { property1: wert1; property2: wert2 } Beispiel:
<HEAD> <TITLE>CSS Example</TITLE> <STYLE TYPE="text/css"> H1 { font-size: x-large; color: red } H2 { font-size: large; color: blue } </STYLE> </HEAD>
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 8Klemens Böhm
Einbettung externer StylesheetsBeispiel:<HEAD><TITLE>CSS Example</TITLE><LINK REL=StyleSheet HREF="style.css” TYPE="text/css” MEDIA=screen><LINK REL=StyleSheet HREF="color-8b.css" TYPE="text/css” TITLE="8-bit Color Style" MEDIA="screen, print"><LINK REL="Alternate StyleSheet" HREF="color-24b.css” TYPE="text/css" TITLE="24-bit Color Style" MEDIA="screen, print"><LINK REL=StyleSheet HREF="aural.css”TYPE="text/css” MEDIA=aural></HEAD>
Mehrere Stylesheets koennen einen Style definieren (TITLE muss gleich sein)REL=StyleSheet + TITLE -> kommt zur Anwend.MEDIA-Wert falsch - Stylesheet wird ignoriertAlternate Style - Idee ist, dass Benutzer es aktivieren kann, Browser unterstuetzen es aber nicht.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 9Klemens Böhm
Beispiel für CSS-Stylesheetgolfplatz { display: block;
background-color: #eeeeee; border-width: thin; border-style: solid; margin: 0.75em 0.75em
0.75em 0.75em; padding: 0.5em 0.5em
0.5em 0.5em;}
adresse { display: block; }saison { display: block; font-style: italic; }greenfee, platz, telefon, fax, plz { display: none; }club { font-size: 140%;
color: blue; font-weight: bold; display: block;}
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 10Klemens Böhm
Pattern Matching mit CSSBeispiel:
DIV H1 EM { font-size: x-large; color: red }EM-Element in H1-Element in DIV-ElementEinleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 11Klemens Böhm
Cascading Order Im allgemeinen Fall
sind mehrere Ersetzungen anwendbar. Welcher Selektor gewinnt im Konfliktfall?
‚!important‘-Label für Regeln, Autor-Regel vs. Leser-Regel
(Autor-Regel gewinnt), ‚Specificity‘, Reihenfolge (letzte Regel gewinnt).
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 12Klemens Böhm
Eigenschaften von XSL XSL verwendet XML Syntax, deklarativ, erweiterbar
(Erweiterungen in Scripting Languages), umfasst CSS-Funktionalität.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 13Klemens Böhm
XSL - Konzepte XSL besteht aus zwei Teilen:
Sprache für Dokumenttransformation, XML Vokabular
zur Spezifikation der Formatierung. not required
Sogenannte Template Rules spezifizieren die Dokumenttransformation.
Template Rule besteht aus zwei Teilen: Pattern, das m. dem Source Tree gematcht
wird, Template, das instanziiert wird,
u. diese Instanziierung ist Teil des Result Trees. Höhere Wiederverwertbarkeit von XSL-Code.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 14Klemens Böhm
XSL Formatierungsprozess
Element-baum
Formatierungs-objekte Baum (FOT)
The TimesNew Roman
Ausgabe-medium
The TimesNew Roman
PD
FH
TML
Treiber-sprache
GUI
Papier
Browser
JFC
Trans-forma-tion
=
Inter-preta-tion
XSLStylesheet
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 15Klemens Böhm
XSLT - Übersicht Template Rules, Conflict Resolution, “Kontrollstrukturen”, Variablen, sonstige Features.
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 16Klemens Böhm
XML-Dokument mit Stylesheet-Referenz
<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="portfolio.xsl"?><portfolio xmlns:dt="urn:schemas-microsoft-com:datatypes" xml:space="preserve"> <stock exchange="nyse"> <name>zacx corp</name> <symbol>ZCXM</symbol> <price dt:dt="number">28.875</price> </stock> <stock exchange="nasdaq"> <name>zaffymat inc</name> <symbol>ZFFX</symbol> <price dt:dt="number">92.250</price> </stock> <stock exchange="nasdaq"> ... </stock></portfolio>
Processing InstructionStylesheet LanguageNamespace dt eingefuehrt und verwendetStylesheet-Referenz - Anklickenxml:space=„preserve“ - preserves white space from the source doc. (Default-Behavior von IE5.0)
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 17Klemens Böhm
Template Rules
<xsl:template match="employee"> <fo:block> Employee <xsl:apply-templates select="name"/> belongs to group <xsl:apply-templates select="ancestor::department/group"/> </fo:block></xsl:template>
<xsl:template match="product"> <table> <xsl:apply-templates select="sales/domestic"/> </table> <table> <xsl:apply-templates select="sales/foreign"/> </table> </xsl:template>
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Pattern
TemplateArbeitet die Kinder des aktuellen Elements ab.
Interoperable Informationssysteme - 18Klemens Böhm
Patterns Syntax von Patterns ist Teilmenge der
Syntax von (XPath-)Ausdrücken, Location Paths können (mit kleinen
Einschränkungen) als Patterns verwendet werden.
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 19Klemens Böhm
Unregelmässige DatenF:\temp\iis\demos\pole.xml, pole2.xml
<HTML> <HEAD> <TITLE><xsl:value-of select="document/title"/></TITLE> </HEAD> <BODY> <H1><xsl:value-of select="document/title"/></H1> <xsl:apply-templates select="document/section"/> </BODY> </HTML>
<xsl:template match="section"> <DIV> <xsl:apply-templates /> </DIV> </xsl:template>
<xsl:template match="section"> <DIV> <H2><xsl:value-of select="title"/></H2> <xsl:apply-templates /> </DIV> </xsl:template>
<xsl:apply-templates> - w/out ‘select’ attribute, all the children will be selected
Content von sectionoptionale Elementesection in sectionemph ueberall
“Selektiere section-Elemente (nur top-level) und wende passendes
Template an.”
<xsl:template match="text()"><xsl:value-of /></xsl:template>match - identifiziert children, die text nodes sindDefault fuer select-Attr. fuer value-of: value des akt. Knotens
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 20Klemens Böhm
Beispiel: Kundentabelle<?xml version="1.0">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns="http://www.w3.org/TR/REC-html40“>
<xsl:template match="/"> <HTML> <BODY> <TABLE> <xsl:for-each select="kunden/kunde"> <TR> <xsl:apply-templates
select="name"/> <xsl:apply-templates
select="adresse"/> <xsl:apply-templates
select="telefon"/> </TR> </xsl:for-each> </TABLE> </BODY> </HTML> </xsl:template>...
... <xsl:template match="name"> <TD><xsl:apply-templates/></TD> </xsl:template>
<xsl:template match="addresse"> <TD><xsl:apply-templates/></TD> </xsl:template>
<xsl:template match="telefon"> <TD><xsl:apply-templates/></TD> </xsl:template>
<xsl:template match="*"> <TD> <xsl:copy> <xsl:value-of/> </xsl:copy> </TD> </xsl:template>
</xsl:stylesheet>
Default-Namespace
xsl:copy - kopiert den Targetknoten v. der Source in den Output.Attribute und Kinder werden nicht automatisch kopiert. (xsl:copy-of)
xsl:value-of - retourniert das Element als Text
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 21Klemens Böhm
Erzeugen von Attributwerten <xsl:for-each select="portfolio/stock"> <TR> <xsl:attribute name="TITLE">
<xsl:value-of select="symbol"/> is listed on the
<xsl:value-of select="@exchange"/> stock exchange.
</xsl:attribute> <TD><xsl:value-of select="symbol"/></TD> <TD><xsl:value-of select="name"/></TD> <TD><xsl:value-of select="price"/></TD> </TR> </xsl:for-each>
Attributwert wird nicht ausgegeben.Muss offensichtlich das erste Element sein.Erzeugen eines Attributs mit einem Namen, der schon existiert.
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 22Klemens Böhm
Erzeugen von Elementen In vorangegangenen Beispielen wurde das
Element, das Teil der Zielstruktur ist, direkt hingeschrieben.
Man kann Elementnamen auch on-the-fly generieren.
Beispiel für die Verwendung des entsprechenden Konstrukts:<xsl:element
name = “DIV”namespace = “http://…”> optionales
Attribut
<!– Content: template --></xsl:element>
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 23Klemens Böhm
Kopieren von Struktur und TextAlles wird kopiert:<xsl:template match="@*|node()">
<xsl:copy> <xsl:apply-templates
select="@*|node()"/> </xsl:copy>
</xsl:template>
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 24Klemens Böhm
Conflict Resolution Es kann i.a. sein, dass ein Knoten mehrere
Template Rules matcht. Default Priority ist wie folgt:
Importierte oder inkludierte Regeln haben niedrigere Priorität,
Spezifischere Patterns haben höhere Priorität als weniger spezifische.Beispiel: Test, ob irgendein Knoten existiert, ist weniger spezifisch als Test für Knoten mit konkretem Namen.
Wenn es mehrere gleichberechtigte Regeln gibt, ist dies ein Fehler.
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 25Klemens Böhm
Kontrollstrukturen –Beispiel-Dokument
<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="portfolio.xsl"?><portfolio xmlns:dt="urn:schemas-microsoft-com:datatypes" xml:space="preserve"> <stock exchange="nyse"> <name>zacx corp</name> <symbol>ZCXM</symbol> <price dt:dt="number">28.875</price> </stock> <stock exchange="nasdaq"> <name>zaffymat inc</name> <symbol>ZFFX</symbol> <price dt:dt="number">92.250</price> </stock> <stock exchange="nasdaq"> ... </stock></portfolio>
Dokument von vorhin
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 26Klemens Böhm
Mögliche Zieldarstellung<HTML> <BODY> <TABLE BORDER="2"> <TR> <TD>Symbol</TD> <TD>Name</TD> <TD>Price</TD> </TR> <!-- repeat the following row for each stock --> <TR> <TD><!-- symbol goes here --></TD> <TD><!-- name goes here --></TD> <TD><!-- price goes here --></TD> </TR> </TABLE> </BODY></HTML>
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 27Klemens Böhm
Stylesheet mit Template<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <HTML> <BODY> <TABLE BORDER="2"> <TR> <TD>Symbol</TD> <TD>Name</TD> <TD>Price</TD> </TR> <xsl:for-each select="portfolio/stock"> <TR> <TD><xsl:value-of select="symbol"/></TD> <TD><xsl:value-of select="name"/></TD> <TD><xsl:value-of select="price"/></TD> </TR> </xsl:for-each> </TABLE> </BODY> </HTML> </xsl:template></xsl:stylesheet>
Stylesheet enthaelt keine Referenz auf Dok./Template: spezifiziert Zielstrukturbeliebig viele Templates
portfolio.xslsimple.xml - Andere Einbettung der Templates
ausgehend von der Dokument-Wurzel
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 28Klemens Böhm
Sortieren des Outputs<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <HTML> <BODY> <TABLE BORDER="2"> <xsl:for-each select="portfolio/stock”
order-by=“price”> <TR> <TD><xsl:value-of select="symbol"/></TD> <TD><xsl:value-of select="name"/></TD> <TD><xsl:value-of select="price"/></TD> </TR> </xsl:for-each> </TABLE> </BODY> </HTML> </xsl:template></xsl:stylesheet>
order-by=“BIDDER; - number(PRICE)”
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 29Klemens Böhm
Bedingter Output <xsl:if test=„@exchange[.=‚nasdaq‘]“>* </xsl:if>
<xsl:choose> <xsl:when test=…> <xsl:when test=…> … </xsl:choose>
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 30Klemens Böhm
Templates mit Namen Templates mit Namen können direkt aufgerufen werden. Beispiel: Kopieren von bestimmten Attributen in den
Zielbaum, unabhängig vom Elementtyp. Template-Definition:<xsl:template name="apply-temp-copy-lang"> <xsl:for-each select="@xml:lang"> <xsl:copy/> </xsl:for-each> <xsl:apply-templates/> </xsl:template>
Aufruf:<xsl:call-template name="apply-temp-copy-lang"/> anstelle von<xsl:apply-templates/>
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 31Klemens Böhm
VariablenZwei Arten der Variablendefinition: Mittels select-Attribut:
Variablendefinition: <xsl:variable name="n" select="2"/> ...
Verwendung der Variablen:<xsl:value-of select="item[$n]"/>
Wert des select-Attributes ist Expression. Über den Inhalt des xsl:variable-Elements:
Variablendefinition:<xsl:variable name="n">2</xsl:variable> ...
Verwendung der Variablen:<xsl:value-of select="item[position()=$n]"/>
Variable steht für Menge von Teilbäumen.
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 32Klemens Böhm
Zusätzliche FeaturesUnter anderem: Numerierung, Import und Inkludierung von Stylesheets, Whitespace Stripping, Erzeugung von Processing Instructions und
Kommentaren.
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 33Klemens Böhm
Einbettung von DOM-Methoden in XSL-Stylesheets
function invoiceTotal(invoice){ items = invoice.selectNodes("items/item"); var sum = 0; for (var item = items.nextNode(); item; item = items.nextNode()) { var price = item.selectNodes("price").item(0).nodeTypedValue; var qty = item.selectNodes("qty").item(0).nodeTypedValue; sum += price * qty; } return sum;}
<price dt:dt="number">18.00</price>
Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 34Klemens Böhm
Einbettung von DOM-Methoden in XSL-Stylesheets
Einbettung Albis/global/users/boehm/Windows/temp/invoice.xsl, invoice.xml
Schlüsselwort this mit üblicher Bedeutung.Einleitung
CSS
XSL
XSLT
-Template Rules
- Conflicts
- Kontroll- strukturen
- Variablen
- Sonstiges
FormatingObjects
YAT
Interoperable Informationssysteme - 35Klemens Böhm
XSL - Layout-Beschreibungsmechanismen
Bisherige Beispiele: Direkte Erzeugung von HTML aus XML;
Jetzt: Erzeugung einer ‚abstrakten‘, plattformunabhängigen Beschreibung des gelayouteten Dokuments.
XSL standardisiert das Vokabular dieser Beschreibungssprache;Implementierung als XML-Namespace.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 36Klemens Böhm
XSL Regelmodell - Formating Objects
...... ... ...
......Warnung:
...Text zwischen <xsl:text> und </xsl:text> wird explizit ausgegeben.
warnung
<xsl:template match="warnung">
<fo:block font-size="24pt" font-family="serif”> <xsl:text> Warnung: </xsl:text> <xsl:apply- templates/> </fo:block></xsl:template>
Regel
Aktion
Muster
<fo:block font-size ="24pt" font-family ="serif”> Warnung: ... </fo:block>
…<warnung> …</warnung>...
Stylesheet
PlattformunabhängigeBeschreibung
.......
XML-Dokument
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 37Klemens Böhm
Formatting Objects XSL Formatting Objects - spezifizieren die
Formatierung, eine Formatting Object Class
repräsentiert ein bestimmtes ‘Formatierverhalten’. Formater erzeugt hierarchische Anordnung
sog. Areas und Spaces. Beispiel für Formatting Objects:
block -block Formatting Object erlaubt die Erzeugung einer Block-Level Area mit Textzeilen.Beispiel: Schriftgrösse
XSL legt nicht fest, wie genau das Formatting, z.B. Zeilenumbruch, Letterspacing, Hyphenation, implementiert sein muss, lediglich Constraints.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 38Klemens Böhm
Formatting Model Areas sind das Ergebnis des Formatting. Areas reservieren Platz und nehmen Inhalt auf. Areas können ein Koordinatensystem definieren
und andere Areas enthalten. Formatting Object, durch das die Area erzeugt
wurde, spezifiziert Eigenschaften der Area wie margin oder border.
Vier Arten von Areas mit unterschiedlichen Eigenschaften: area-containers, block-areas, line-areas, und inline-areas.area-containers: eigenes Koordinatensystem, eigener writing mode, im Ggs. zu block-areas.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 39Klemens Böhm
XSL Beispiel<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl” xmlns:fo="http://www.w3.org/TR/WD-xsl/FO” result-ns="fo"> <xsl:template match="/"> <fo:basic-page-sequence font-family="serif"> <xsl:apply-templates/> </fo:basic-page-sequence> </xsl:template>
<xsl:template match="para"> <fo:block font-size="10pt" space-before="12pt"> <xsl:apply-templates/> </fo:block> </xsl:template></xsl:stylesheet>
Regel ist für den Wurzelknoten.Regel ist für para-Elemente.
para-Elemente werdenBlock Formatting Objects.
Stylesheet konstruiert Baum unter Verwendungdes Formatting Object Vocabulary.
Wert dieses Attributs gibt Output des XSL Processors an.Ist mit IE5.0 immer XML (inkl. HTML).
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 40Klemens Böhm
XSL Beispiel Ausschnitt aus XML-Dokument:This is an <emph>important</emph> point.
Regel matcht Elemente vom Typ emph u. erzeugt ein fo:inline-sequence Formatting Object.<xsl:template match="emph"> <fo:inline-sequence font-weight="bold"> <xsl:apply-templates/> </fo:inline-sequence></xsl:template>
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 41Klemens Böhm
XSL - Zusammenfassung Konstrukte von XSLT:
Template Rules, Kontrollstrukturen, Variablen,
Formating Objects.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 42Klemens Böhm
YAT System zur einfachen Manipulation von
Transformationsprogrammen, Explizite Beschreibung des Inputs und
Outputs von Transformationsprogrammen, YAT beinhaltet Typen von Datenstrukturen
(Mengen, Listen), akademische Entwicklung (INRIA,
Frankreich, 1998).
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 43Klemens Böhm
YATWas für Features? Customization:
Programm wird automatisch in Spezifischeres transformiert, das dann von Hand modifiziert werden kann.
Automatische Zusammensetzung von Transformationsprogrammen.
Abfolge:1. Modell vorstellen - erlaubt Vererbung,2. Transformationssprache -
nicht speziell, wird aber gebraucht, um Customization zu illustrieren,
3. Customization, Composition
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
Interoperable Informationssysteme - 44Klemens Böhm
Modell Modell: Beschreibung dessen, was Input/Output
der Konvertierung sein kann, z.B. Schema, d.h. Menge von Dokumenten, aber auch (pathologischer Fall) einzelnes Dokument.
Modell besteht aus Patterns und Wertebereichen der Variablen.
Fundamentaler Aspekt: Vererbung/Instanziierung. Begriff ‘Instanziierung’ allgemeiner als im XML-
Kontext: Spezielleres Schema ist Instanz des allgemeinen Schemas, nicht nur ‘Dokument ist Instanz eines Schemas’.
Wichtig für Customization.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 45Klemens Böhm
Customizing
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Input-Modell
Output-Modell
Pro-gramm
Input-Modell‘
Instanziierung
Prog.‘Input-
Modell‘
Customizing
Interoperable Informationssysteme - 46Klemens Böhm
YAT - Modelle (1)
car
name
S1: string
desc
S2: string
suppliers
set*&Psup
classPcar:
&Pcar
Psup:
...
Car Schema - Modell:
Kleinbuchstaben: Konstanten, Grossbuchstaben: Variable, fett: Patterns ‘*’ bedeutet, dass Kante in Instanziierung mehrmals
vorkommen darf.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 47Klemens Böhm
YAT - Modelle (2)
car
name
“Golf”
desc
“Der Golfbesticht durch …”
suppliers
set
&s1
classc1: s1: ...
‘Golf’Modell:
&s1
s2: ...
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 48Klemens Böhm
Ptype
YAT - Modelle (3)
class
Class_name
Pclass:
*Att
Ptype
tuple*Att
Ptype
Y: Int String
Z: (set, list, bag, array)*
&Pclass
Ptype:
ODMGModell:
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 49Klemens Böhm
Erläuterungen Kanten-Labels sind Occurrence-Indicators
(kein explizites Label genau 1). Variablen:
Bei Instanziierung sind Einschränkungen des Wertebereichs möglich, z.B. ‘Int String’ ‘String’,
Patterns: können in Blättern Patterns oder Pattern-Referenzen enthalten(Rekursion, Sharing + Zykel).
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 50Klemens Böhm
Modell-Instanziierung
Ptype
class
Class_name
Pclass:
*Att
Ptype
tuple*Att
Ptype
Y: Int String
Z: (set, list, bag, array)*
&Pclass
Ptype:ODMGModell:
car
name
S1: string
desc
S2: string
suppliers
set*&Psup
classPcar:
&Pcar
Psup:...
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 51Klemens Böhm
YAT - das allgemeinste Modell
L &Yat L
Yat*
Yat:
YAT Modell:Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 52Klemens Böhm
Text-Syntax für ModellePcar: class car < name S1: String,
desc S2: String, suppliers set * &Psup>
Psup: class supplier < name S1: String, city S2: String, zip S3: String>
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 53Klemens Böhm
DTD für Beispiel<!DOCTYPE brochure [<!ELEMENT brochure -- (number, title, model,
desc, spplrs)><!ELEMENT number -- (#PCDATA)><!ELEMENT title -- (#PCDATA)><!ELEMENT model -- (#PCDATA)><!ELEMENT desc -- (#PCDATA)><!ELEMENT spplrs -- (sup)*><!ELEMENT supplier -- (name, address)><!ELEMENT name -- (#PCDATA)><!ELEMENT address -- (#PCDATA)> ] >
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 54Klemens Böhm
Pbr:brochure < number Num,
title T, model Year, desc D, suppls * supplier
< name SN, address Add >>,
Year > 1975,C is city(Add),Z is Zip(Add)
Beispiel-Regel
Psup(SN):class supplier
< name SN, city C, zip Z>
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Output-PatternentsprichtSupplier-Pattern.
Input-PatternentsprichtBeispiel-DTD.
Interoperable Informationssysteme - 55Klemens Böhm
Erläuterungen Body der Regel enthält nicht nur Pattern,
sondern auch Prädikate, Aufrufe externer Funktionen
für Umrechnungen. Parametrisierter Pattern-Name
(hier ist ‘SN’ der Parameter von ‘Psup’),Erzeugung eines Objekts für jeden Wert von SN(d.h. SN ist quasi Schlüsselattribut, sonst undefiniertes Systemverhalten).
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 56Klemens Böhm
Rule Processing - Abfolge1.Pattern Matching für Rule Bodies2.Evaluierung externer Funktionen3.Evaluierung der Prädikate4.Zuordnung von OIDs (der Output-
Strukturen) zu parametrisierten Pattern-Namen(global für das ganze Programm)
5.Konstruktion der Output Patterns.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 57Klemens Böhm
Pbr:brochure
< number Num, title T, model Year, desc D, suppls * supplier
< name SN, address Add>>
Beispiel-Regel 2
Pcar(Pbr):class car
< name T, desc D, suppliers
set {} &Psup(SN)>
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 58Klemens Böhm
Erläuterungen Verwendung von Referenzen
Dereferenzierung wäre auch möglich, d.h. in der Regel stünde ‘set {} Psup(SN)’,und statt einer Referenz erhielte man eine Kopie des Teilbaums;
Erzeugung von Mengen von Söhnen.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 59Klemens Böhm
TypingProgramm: Modell ModellAussagen über Typen anhand von Input-/Output-Patterns, Signaturen von Prädikaten und Funktionen, Wertebereiche von Variablen.
Nutzen von Typing: Kombinierbarkeit von Programmen Zusammenhang zwischen Input- und
Output-Modellen von Programmen, z.B. ‘Ist _ Generalisierung von _?’,
Customizing von Programmen.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 60Klemens Böhm
Beispiel für Customizing - RegelnHtmlPage(Pclass):html< head title Classname,
body< h1 Classname, ul * li
< Att2, HtmlElement(Ptype)>>>
Pclass:
class Classname * Att Ptype,Att2 is concat(Att, “ : “)
HtmlElement(Ptype):ul * li HtmlElement(P2: Ptype)>
Ptype:
X: {set, bag} * P2: Ptype>
HtmlElement(Ptype): S Ptype: Data,
S is data_to_string(Data)
Explizite Typisierung, z.B. Variable X
Weitere Regeln für andereBestandteile des ODMG-Modells
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Für jede Klasseein HTML-Dokument.
Interoperable Informationssysteme - 61Klemens Böhm
Beispiel (Fortsetzung 1)HtmlPage(Pclass):html< head title car,
body< h1 car, ul< li< “name: “,
T1>, li< “age: “,
D1>, li< “suppliers: “,
ul * li a < href &HtmlPage(Psup),
cont Classname>>>>> Pcar:
class car < name T, desc D, suppliers set * &Psup>,
Psup:class Classname P2: Ptype, T1 is data_to_string(T),D1 is data_to_string(D)
Diese Regel wird aus den vorhandenen Regeln und dem Input-Modell automatisch erzeugt.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 62Klemens Böhm
Beispiel (Fortsetzung 2)HtmlPage(Pclass):html< head title car,
body < h1 car,
ul< li< “name: “, T1>,
li< “age: “, D1>>>>
Pcar:
class car < name T, desc D, suppliers set * &Psup>,
T1 is data_to_string(T),D1 is data_to_string(D)
Automatisch erzeugte Regel lässt sich von Hand anpassen.Besser, als Programm neu schreiben zu müssen.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 63Klemens Böhm
Composition Automatische Generierung eines Programms aus
zwei oder mehr existierenden, Benutzer kann es dann wieder anpassen.Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.
Interoperable Informationssysteme - 64Klemens Böhm
Zusammenfassung YAT “Entwicklungsumgebung” für
Transformationsprogramme, Input-/Output-Modelle, Customization und Kombinierbarkeit von
Transformationsprogrammen.
Einleitung
CSS
XSL
XSLT
FormatingObjects
YAT
- Modell
- Transform. sprache
- Customiz.