xml 内部CMS的基本XSLT模板
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml 内部CMS的基本XSLT模板相关的知识,希望对你有一定的参考价值。
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" >
<xsl:output method="html" indent="yes"/>
<xsl:template match="DocumentElement">
<xsl:for-each select="PageData">
<xsl:sort select="date" order="descending" />
<xsl:value-of select="PageDataTitle"/>
<xsl:call-template name="FormatDate">
<xsl:with-param name="DateTime" select="date"/>
</xsl:call-template>
<xsl:value-of select="preview" disable-output-escaping="yes"/>
<a target=”_blank”>
<xsl:attribute name="href"><xsl:value-of select="url"/></xsl:attribute>
Learn More
</a>
</xsl:for-each>
</xsl:template>
<xsl:template name="FormatDate">
<xsl:param name="DateTime" />
<!-- new date format January 1, 2009 -->
<xsl:variable name="Date">
<xsl:value-of select="substring-before($DateTime, 'T')" />
</xsl:variable>
<xsl:variable name="year">
<xsl:value-of select="substring($Date,1,4)" />
</xsl:variable>
<xsl:variable name="mo-temp">
<xsl:value-of select="substring-after($Date,'-')" />
</xsl:variable>
<xsl:variable name="mo">
<xsl:value-of select="substring-before($mo-temp,'-')" />
</xsl:variable>
<xsl:variable name="day-temp">
<xsl:value-of select="substring-after($mo-temp,'-')" />
</xsl:variable>
<xsl:variable name="day">
<xsl:value-of select="substring($day-temp,1,4)" />
</xsl:variable>
<xsl:choose>
<xsl:when test="$mo = '01'">January</xsl:when>
<xsl:when test="$mo = '02'">February</xsl:when>
<xsl:when test="$mo = '03'">March</xsl:when>
<xsl:when test="$mo = '04'">April</xsl:when>
<xsl:when test="$mo = '05'">May</xsl:when>
<xsl:when test="$mo = '06'">June</xsl:when>
<xsl:when test="$mo = '07'">July</xsl:when>
<xsl:when test="$mo = '08'">August</xsl:when>
<xsl:when test="$mo = '09'">September</xsl:when>
<xsl:when test="$mo = '10'">October</xsl:when>
<xsl:when test="$mo = '11'">November</xsl:when>
<xsl:when test="$mo = '12'">December</xsl:when>
</xsl:choose>
<xsl:value-of select="' '"/>
<xsl:value-of select="$day"/>
<xsl:value-of select="', '"/>
<xsl:value-of select="$year"/>
</xsl:template>
</xsl:stylesheet>
以上是关于xml 内部CMS的基本XSLT模板的主要内容,如果未能解决你的问题,请参考以下文章