Xml xsl选择中的函数子字符串
如何显示二月发送的信件 如何显示二月发送的信件 由于日期元素似乎都具有一致的yyyy-mm-dd格式,因此使用谓词选择相关元素非常容易:Xml xsl选择中的函数子字符串,xml,date,xslt,substring,selection,Xml,Date,Xslt,Substring,Selection,如何显示二月发送的信件 如何显示二月发送的信件 由于日期元素似乎都具有一致的yyyy-mm-dd格式,因此使用谓词选择相关元素非常容易: <xsl:template match="/"> <html> <head> <title>Email box</title> <style type="text/css">
<xsl:template match="/">
<html>
<head>
<title>Email box</title>
<style type="text/css">
.emailsubject {background-color:fuchsia; font-size:x-large; }
.emailbody {font-family:sans-serif; font-size:11pt}
.emailsender {font-style:italic}
</style>
</head>
<body>
<h1>Email box</h1>
<h3>elements selection</h3>
<xsl:apply-templates select="substring(/emails/email/date,6,2)" />
</body>
</html>
</xsl:template>
<xsl:template match="email">
<p class="emailsubject">
<xsl:number value="position()" format="1. " />
<xsl:value-of select="subject"/>
</p>
<p class="emailsender"><text>from: </text><xsl:value-of select="from"/><text>, </text><xsl:value-of select="date"/></p>
<p class="emailbody"><xsl:value-of select="body"/></p>
</xsl:template>
</xsl:stylesheet>
你能提供一个XML输入文件吗?另外,在你问题的结尾似乎有一些角色垃圾。你能看一看吗?@user2969012相同的原则,但不同的谓词,你希望email元素包含sto,'Andrew Wozniak'。thx很多,它可以工作select=/emails/email[containsto,'Andrew Wozniak'或containscc,'Andrew Wozniak']
<xsl:template match="/">
<html>
<head>
<title>Email box</title>
<style type="text/css">
.emailsubject {background-color:fuchsia; font-size:x-large; }
.emailbody {font-family:sans-serif; font-size:11pt}
.emailsender {font-style:italic}
</style>
</head>
<body>
<h1>Email box</h1>
<h3>elements selection</h3>
<xsl:apply-templates select="substring(/emails/email/date,6,2)" />
</body>
</html>
</xsl:template>
<xsl:template match="email">
<p class="emailsubject">
<xsl:number value="position()" format="1. " />
<xsl:value-of select="subject"/>
</p>
<p class="emailsender"><text>from: </text><xsl:value-of select="from"/><text>, </text><xsl:value-of select="date"/></p>
<p class="emailbody"><xsl:value-of select="body"/></p>
</xsl:template>
</xsl:stylesheet>
<xsl:apply-templates select="/emails/email[substring(date, 6, 2) = '02']" />