XSL if

Hallo,

versuch es mal hiermit,

Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">

        <html>
            <head>
                <meta http-equiv="Content-Type" content="text/html" charset="iso-8859-1"/>
                <title>IbS Bochum</title>
                <link rel="stylesheet" type="text/css" href="../../../layout/blau.css"/>
            </head>
            <body>
                <div id="col2news">

                    <xsl:apply-templates
                        select="document('News.xml')//Nachricht">
                        <xsl:sort select="Datum" order="descending" data-type="text"/>
                    </xsl:apply-templates>

                </div>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="Nachricht">
        <xsl:if test="position() &lt;= 10">
            <xsl:apply-templates />
        </xsl:if>
    </xsl:template>
    <xsl:template match="Titel">
        <h3>
            <xsl:apply-templates/>
        </h3>
    </xsl:template>
    <xsl:template match="Text">
        <p>
            <xsl:apply-templates/>
        </p>
    </xsl:template>
    <xsl:template match="fett">
        <b>
            <xsl:apply-templates/>
        </b>
    </xsl:template>
    <xsl:template match="Absatz">
        <br/>
        <br/>
    </xsl:template>
    <xsl:template match="E-Mail">
        <a>
            <xsl:attribute name="href">
                <xsl:choose>
                    <xsl:when test="contains(Url, '@')">
                        <xsl:value-of select="concat('mailto:', Url)"/>
                    </xsl:when>
                    <xsl:when test="starts-with(Url, 'www')">
                        <xsl:value-of select="concat('http://', Url)"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="Url"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:attribute>
            <p>
                <b>
                    <xsl:value-of select="Url-Text"/>
                </b>
            </p>
        </a>
    </xsl:template>
    <xsl:template match="Link">
        <a>
            <xsl:attribute name="href">
                <xsl:choose>
                    <xsl:when test="contains(Url, '@')">
                        <xsl:value-of select="concat('mailto:', Url)"/>
                    </xsl:when>
                    <xsl:when test="starts-with(Url, 'www')">
                        <xsl:value-of select="concat('http://', Url)"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="Url"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:attribute>
            <p>
                <b>
                    <xsl:value-of select="Url-Text"/>
                </b>
            </p>
        </a>
    </xsl:template>
    <xsl:template match="Datum">
        <p>
            <xsl:apply-templates/>
        </p>
        <hr/>
    </xsl:template>
</xsl:stylesheet>

So funktioniert es, ohne Zwischenschritt.


MFG

zEriX
 
Zurück