在线:context()的作用????
在b.xsl中使用的context()有什么作用?"/bbs/post[@pid=context()/@sid]"它的判断是什么意思?
谢谢!
xsl文件:b.xsl
<?xml version="1.0" encoding="gb2312" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="*"/>
</body>
</html>
</xsl:template>
<xsl:template match="post">
<li>
<div>
<xsl:attribute name="title"><xsl:value-of select="content"/></xsl:attribute>
<xsl:attribute name="style">cursor:hand;</xsl:attribute>
<xsl:attribute name="onclick">javascript:alert("<xsl:value-of select="title"/>");</xsl:attribute>
<xsl:value-of select="title"/>
<xsl:if test="/bbs/post[@pid=context()/@sid]">
<xsl:element name="ul">
<xsl:apply-templates select="/bbs/post[@pid=context()/@sid]"/>
</xsl:element>
</xsl:if>
</div>
</li>
</xsl:template>
<xsl:template match="bbs">
<ul>
<xsl:apply-templates select="post[@pid=0]"/>
</ul>
</xsl:template>
</xsl:stylesheet>
xml文件:bbs.xml
<?xml version="1.0" encoding="gb2312" ?>
<?xml-stylesheet type="text/xsl" href="b.xsl" ?>
<bbs>
<post sid="4" pid="3" aid="1">
<title>4-3-1,this is a test</title>
<content>slddfjslajfsdljf</content>
</post>
<post sid="5" pid="3" aid="1">
<title>5-3-1,this is a test</title>
<content>slddfjslajfsdljf</content>
</post>
<post sid="3" pid="1" aid="1">
<title>3-1-1,this is a test</title>
<content>slddfjslajfsdljf</content>
</post>
<post sid="1" pid="0" aid="1">
<title>1-0-1,this is a test</title>
<content>slddfjslajfsdljf</content>
</post>
<post sid="2" pid="0" aid="2">
<title>2-0-2,this is a test</title>
<content>slddfjslajfsdljf</content>
</post>
</bbs><!--这里sid是贴子的id号,pid是贴子的父id号。title是标题,content是贴子的内容-->