resinweb服务器源文件

源代码在线查看: if-xpath-attribute.xtp

软件大小: 3202 K
上传用户: WJQ198926
关键词: resinweb 服务器
下载地址: 免注册下载 普通下载 VIP

相关代码

												Since xsl:if can be cumbersome, Resin adds a special XPath				function .  Although if() is not part of the XPath standard,				it's expected that the next version of the standard will add it.								 is like the Java conditional expression				 pattern.  In XPath, it				looks like .  Using if() can simplify				stylesheets dramatically, especially in combination with attribute				value templates.  The				following is a simplification of the previous stylesheet using "example"				as the default attribute value.												<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">								<xsl:template match="example">				  <table class="if(@class,@class,'example')">				    <tr>				      <td>				        <xsl:apply-templates/>				      </td>				    </tr>				  </table>				</xsl:template>								</xsl:stylesheet>												Notice that the 'example' value needs to be quoted, otherwise it				would be interpreted as selecting an element value.  The following XTP				specifies a different class for the example.  Often, though, it's a				good idea to stick with meaningful tags like <example> and leave				formatting questions like the CSS class to the stylesheet.  In that case,				you can use attributes to select different templates.												<example class="simple-example">				This is an example.				</example>												<table class="simple-example">				<tr>				  <td>This is an example</td>				</tr>				</table>																								 is a conditional expression.																							

相关资源