Μετασχηματισμοί

Παράδειγμα XSLT

<?xml version="1.0"?>
<!-- Apply using
xml tr project.xslt mexpress.xml
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="project">
                <h1>
                <xsl:value-of select="shortname" />
                -
                <xsl:value-of select="projtitle" />
                </h1>
                <!-- Show Logo -->
                <xsl:element name="img">
                        <xsl:attribute name="src"><xsl:value-of select="logo" /></xsl:attribute>
                </xsl:element>
                <br /> <br />
                <!-- Project Summary information -->
                <xsl:if test="count(project_code) != 0">
                        Project Code:
                        <xsl:value-of select="project_code" />
                        <xsl:if test="@international = 'yes'">
                                (International)
                        </xsl:if>
                        <br/>
                </xsl:if>
                <xsl:if test="count(funding_programme) != 0">
                        Funding programme: <xsl:value-of select="funding_programme" />
                        <br />
                </xsl:if>
                <xsl:if test="count(funding_agency) != 0">
                        Funding Agency: <xsl:value-of select="funding_agency" />
                        <br />
                </xsl:if>
                <xsl:if test="@type != ''">
                        Project type:
                        <xsl:choose>
                                <xsl:when test="@type = 'rtd'">RTD</xsl:when>
                                <xsl:when test="@type = 'consulting'">Consulting</xsl:when>
                                <xsl:when test="@type = 'training'">Training</xsl:when>
                                <xsl:when test="@type = 'dissemination'">Dissemination</xsl:when>
                        </xsl:choose>
                        <br />
                </xsl:if>
                <xsl:if test="count(web_site) != 0">
                        Web site:
                        <xsl:element name="a">
                                <xsl:attribute name="href"><xsl:value-of select="web_site"/></xsl:attribute>
                                <xsl:value-of select="web_site" />
                        </xsl:element>
                        <br />
                        <br />
                </xsl:if>
                <xsl:if test="count(our_budget) != 0">
                        ELTRUN budget: <xsl:value-of select="our_budget" />
                        <br />
                </xsl:if>
                <xsl:if test="count(total_budget) != 0">
                        Total budget: <xsl:value-of select="total_budget" />
                        <br />
                </xsl:if>
                <br />
        </xsl:template>
</xsl:stylesheet>

Αποτέλεσμα HTML

mExpress - mobile in-EXhibition PRovision of Electronic Support Services



Project Code: IST-2001-33432 (International)
Funding programme: IST
Funding Agency: European Commission
Project type: RTD
Web site: http://mexpress.intranet.gr/

ELTRUN budget: 328 EUR
Total budget: 3,493 EUR