XSLT
From Dietrich Blog (Strato)
Siehe auch: XSLT
Mithilfe von XSL-Stylesheets kann man XML-Dokumente in verschiedenen Output-Formate transformieren.
Web Links
XSL Namespace
Das XSL-Stylesheet sollte anfangen mit:
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" >
XSL Output Methods
- <xsl:output method = "text" />
- <xsl:output method = "html" />
- <xsl:output method = "xml" />
Ein einfaches Beispiel
Als Eingabe folgendes XML-Dokument:
<?xml version="1.0" encoding="UTF-8"?> <message>Yep, it worked!</message>
Zur Transformation folgendes XSL-Stylesheet:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" encoding="UTF-8"/> <!-- simply copy the message to the result tree --> <xsl:template match="/"> <xsl:value-of select="message"/> </xsl:template> </xsl:stylesheet>
Der Aufruf eines XSLT-Prozessors erzeut die Ausgabedatei (output-mthod="text"):
Yep, it worked!
Beispiel Notizbuch
Mein Outlook-Notizbuch hatte ich in EverNote importiert, um daraus ein irgendwie brauchbares XML-Standatdformat zu erzeugen, z.B. RSS oder Atom...
Eingabe ist die mit EverNote erstellte XML-Datei:
<evernote> <notes> <note name="title" content_date="2005/03/30 15:30:45" created="2008/04/07 19:55:01" id="[FA1234-5678-45454554]"> <content type="html"> <div>...html content...</div> </content> <contentplain> ....plain ascii content </contentplain> </note> </notes> </evernote>
Zur Tranformation folgendes XSLT-Sheet:
...
Weitere Beispiele
Xalan
XSLT-Prozessor Xalan...
-- Dkracht 13:07, 12 April 2009 (CEST)