[导入]xslt例子(Coloring alternate rows和两个Template例子):
2005-10-13 13:47
309 查看
1。position() mode 2
例:Coloring alternate rows
<TABLE border="1" width="25%">
<xsl:for-each select="/FitnessCenter/Member">
<TR>
<xsl:if test="position() mod 2 = 0">
<xsl:attribute name="bgcolor">yellow</xsl:attribute>
</xsl:if>
<TD><xsl:value-of select="Name"/></TD>
</TR>
</xsl:for-each>
</TABLE>
2。Dument(url) :指向外部另一个Xml文档
<xsl:variable name="fitnessCenter2"
select="document('file://localhost/xml-course/.../FitnessCenter2.xml')"/>
<xsl:for-each select="$fitnessCenter2/FitnessCenter/Member">
3。<xsl:call-template
例:使用带参数(param)的模板(template)
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>Fitness Center</TITLE>
</HEAD>
<BODY>
<xsl:call-template name="displayNameWithFont">
<xsl:with-param name="fontFace" select="'Impact'"/>
<xsl:with-param name="name"
select="/FitnessCenter/Member[1]/Name"/>
</xsl:call-template>
<BR/>
...
</BODY>
</HTML>
</xsl:template>
<xsl:template name="displayNameWithFont">
<xsl:param name="fontFace" select="'Braggadocio'"/> <!-- default font -->
<xsl:param name="name"/>
<FONT face="{$fontFace}">
<xsl:value-of select="$name"/>
</FONT>
</xsl:template>
使用带参数的模板例二:
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>Fitness Center</TITLE>
</HEAD>
<BODY>
16 / 2 =
<xsl:variable name="result">
<xsl:call-template name="NumDiv2">
<xsl:with-param name="N" select="16"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$result"/>
</BODY>
</HTML>
</xsl:template>
<xsl:template name="NumDiv2">
<xsl:param name="N"/>
<xsl:value-of select="$N div 2"/>
</xsl:template>
文章来源:http://spaces.msn.com/members/jewer91/Blog/cns!1p6udCMYMrSYD0M1VOX6N3VQ!126.entry
例:Coloring alternate rows
<TABLE border="1" width="25%">
<xsl:for-each select="/FitnessCenter/Member">
<TR>
<xsl:if test="position() mod 2 = 0">
<xsl:attribute name="bgcolor">yellow</xsl:attribute>
</xsl:if>
<TD><xsl:value-of select="Name"/></TD>
</TR>
</xsl:for-each>
</TABLE>
2。Dument(url) :指向外部另一个Xml文档
<xsl:variable name="fitnessCenter2"
select="document('file://localhost/xml-course/.../FitnessCenter2.xml')"/>
<xsl:for-each select="$fitnessCenter2/FitnessCenter/Member">
3。<xsl:call-template
例:使用带参数(param)的模板(template)
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>Fitness Center</TITLE>
</HEAD>
<BODY>
<xsl:call-template name="displayNameWithFont">
<xsl:with-param name="fontFace" select="'Impact'"/>
<xsl:with-param name="name"
select="/FitnessCenter/Member[1]/Name"/>
</xsl:call-template>
<BR/>
...
</BODY>
</HTML>
</xsl:template>
<xsl:template name="displayNameWithFont">
<xsl:param name="fontFace" select="'Braggadocio'"/> <!-- default font -->
<xsl:param name="name"/>
<FONT face="{$fontFace}">
<xsl:value-of select="$name"/>
</FONT>
</xsl:template>
使用带参数的模板例二:
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>Fitness Center</TITLE>
</HEAD>
<BODY>
16 / 2 =
<xsl:variable name="result">
<xsl:call-template name="NumDiv2">
<xsl:with-param name="N" select="16"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$result"/>
</BODY>
</HTML>
</xsl:template>
<xsl:template name="NumDiv2">
<xsl:param name="N"/>
<xsl:value-of select="$N div 2"/>
</xsl:template>
文章来源:http://spaces.msn.com/members/jewer91/Blog/cns!1p6udCMYMrSYD0M1VOX6N3VQ!126.entry
相关文章推荐
- 两个客户端操作TreeView节点CheckBox的小例子
- activeMQ,spring的jmstemplate简单例子
- 两个数据库相同表数据比对Excel宏例子
- 两个C/C++与汇编进行混合编程的小例子
- override与new(用两个小例子来解释)
- ECLIPSE导入一个工程报了如下两个错误 (其中一个是The type java.lang.Object cannot be resolved )
- eclipse导入J2ME中的例子
- 引用作为参数传递时容易搞错的两个例子
- [J2SE]s02e03.两个错误处理的例子(课后练习)
- oracle数据导入sqlldr小例子
- 7.Cprimerplus链表的两个例子
- Linux下两个程序进行socket通信的简单例子
- 一个用双信号灯同步机制,协调两个后台线程的例子。
- struts 2.0 两个简单例子
- [导入].net分布式事务例子
- 使用.NET生成XML时导入XSLT
- 两个客户端操作TreeView节点CheckBox的小例子
- [导入]ASP 编程中 20 个非常有用的例子
- Java 多线程编程两个简单的例子
- 从两个例子来看C++的异常和Java中的异常【原】