<!DOCTYPE greetings [ <!ELEMENT greetings (hello+) > <!ELEMENT hello (#PCDATA) > <!ATTLIST hello xml:lang CDATA #IMPLIED > <!ENTITY szlig "ß" > <!ENTITY uuml "ü" > ]> <greetings> <hello lang="en">Hello, world!</hello> <hello lang="fr">Bon jour, tout le monde!</hello> <hello lang="no">Goddag!</hello> <hello lang="de">Guten Tag!</hello> <hello lang="de-schwaben">Grüß Gott!</hello> </greetings>
<xsl:message> Writing file <xsl:value-of select="@file"/> ... </xsl:message>and default rules:
<xsl:template match='*'> <span style="color: red;" title="{name()}"> <<xsl:value-of select="name()"/>> <xsl:apply-templates/> </<xsl:value-of select="name()"/>> </xsl:template>
<!DOCTYPE xsl:stylesheet PUBLIC 'http://www.w3.org/1999/XSL/Transform' '/SGML/Public/W3C/xslt10.dtd' [ <!ENTITY lt "&#60;" ><!--=less-than sign R:--> <!ENTITY gt ">" ><!--=greater-than sign R:--> <!ENTITY nl "
"> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:template match="/"> <html> <head> <title>Hello, world! A simple XSLT demo</title> </head> <body> <h1>Hello world!</h1> </body> </html> </xsl:template> </xsl:stylesheet>
<!DOCTYPE xsl:stylesheet PUBLIC 'http://www.w3.org/1999/XSL/Transform' '/SGML/Public/W3C/xslt10.dtd' [ <!ENTITY lt "&#60;" > <!ENTITY gt ">" > ]> <xsl:stylesheet version="1.0" xmlns:xsl= "http://www.w3.org/1999/XSL/Transform"> <!--* ... guts of stylesheet here ... *--> </xsl:stylesheet>
<xsl:template match="/"> <html> <head> <title>Hello, world! A simple XSLT demo</title> </head> <body> <h1>Hello world!</h1> </body> </html> </xsl:template>
<xsl:template match='*'> <xsl:element name="span"> <xsl:attribute name="style">color:red</xsl:attribute> <xsl:text><</xsl:text> <xsl:value-of select="name()"/> <xsl:text>></xsl:text> <xsl:apply-templates/> <xsl:text></</xsl:text> <xsl:value-of select="name()"/> <xsl:text>></xsl:text> </xsl:element> </xsl:template>
<xsl:template match="greetings"> <html> <head> <title>Hello, world! A simple XSLT demo</title> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template>
<xsl:template match="hello"> <xsl:element name="h1"> <xsl:apply-templates/> </xsl:element> </xsl:template>
<xsl:template match="greetings"> <html> <head> <title>Hello, world! A simple XSLT demo</title> </head> <body> <h1>Hello, world! A simple XSLT demo</h1> <p>A hundred ways to say hello (er, well, <xsl:value-of select="count(//hello)"/> ways, anyway).</p> <ol><xsl:apply-templates/></ol> </body> </html> </xsl:template>
<xsl:template match="hello"> <xsl:element name="li"> <xsl:apply-templates/> </xsl:element> </xsl:template>
<xsl:template match="hello[@lang='en']" priority="2"> <li style="font-family: Palatino Linotype; color: #777;"> <xsl:apply-templates/> </li> </xsl:template>
<p>In Tübingen, one way is best: <xsl:apply-templates select="hello[@lang='de-schwaben']"/> </p>
<xsl:template match="hello[@lang='no']" priority="2"> <li style="font-family: Comic Sans MS; color: brown;"> <xsl:apply-templates/> </li> </xsl:template> <xsl:template match="hello[@lang='fr']" priority="2"> <li style="font-family: Script; color: blue; font-size: larger;"> <xsl:apply-templates/> </li> </xsl:template>
<p>In Tübingen: <xsl:apply-templates select="hello[@lang='de-schwaben']"/> </p>
<xsl:template match="hello" priority="1"> <xsl:element name="li"> <xsl:choose> <xsl:when test="@lang='en'"> <xsl:attribute name="style"> font-family: Palatino Linotype; color: #777; </xsl:attribute> </xsl:when> <xsl:when test="@lang='no'"> <xsl:attribute name="style"> font-family: Comic Sans MS; color: brown; </xsl:attribute> </xsl:when> <xsl:when test="@lang='fr'"> <xsl:attribute name="style"> font-family: Script; color: blue; font-size: larger; </xsl:attribute> </xsl:when> <xsl:when test="substring(@lang,1,2)='de'"> <xsl:attribute name="style"> font-family: Arial Black; color: purple; </xsl:attribute> </xsl:when> <xsl:when test="@lang='de-schwaben'"> <xsl:attribute name="style"> font-family: Arial; color: red; </xsl:attribute> </xsl:when> </xsl:choose> <xsl:apply-templates/> </xsl:element> </xsl:template>