XSL/XML网页制作入门,入门到精通[10]
[入库:2005年8月18日] [更新:2007年3月25日]
<?xml version="1.0" encoding="gb2312"?>
<?xml:stylesheet type="text/xsl" href="resume_template.xsl"?>
<document>
<resume>
<name>禹希初</name>
<sex>男</sex>
<birthday>1977.5</birthday>
<skill>数据库设计与维护</skill>
<skill>web开发</skill>
</resume>
</document>

然后,建立一个新xsl文件resume_template.xsl,采用模板的形式,其内容如下:
程序代码:
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/tr/wd-xsl">
<!--根模板-->
<xsl:template match="/">
<html><head><title>个人简历</title></head>
<body>
<xsl:apply-templates select="document/resume"/>
</body>
</html>
</xsl:template>
<!--简历模板-->
<xsl:template match="resume">
<table border="1" cellspacing="0">
<caption>个人简历(
<xsl:eval>formatindex(childnumber(this),"i")</xsl:eval>
)</caption>
<xsl:apply-templates select="name"/>
<xsl:apply-templates select="sex"/>
<xsl:apply-templates select="birthday"/>
<tr/>
<td>技能</td><td colspan="5">
<table cellspacing="0">
<xsl:apply-templates select="skill"/>
</table>
</td>
</table>
<br/>
</xsl:template>
<!--姓名模板-->
<xsl:template match="name"><td>姓名</td>
<td><xsl:value-of/></td>
</xsl:template>
<!--性别模板-->
<xsl:template match="sex"><td>性别</td>
<td><xsl:value-of/></td>
</xsl:template>
<!--生日模板-->
<xsl:template match="birthday"><td>生日</td>
<td><xsl:value-of/></td>
</xsl:template>
<!--技能模板-->
<xsl:template match="skill">
<tr><td><xsl:value-of/></td></tr>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="gb2312"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/tr/wd-xsl"><!--根模板--><xsl:template match="/"><html><head><title>个人简历
</title></head><body><xsl:apply-templates select="document/resume"/></body></html></xsl:template><!--简历模板--><xsl:template match="resume">
本文关键:XSL/XML网页制作入门,入门到精通
本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)