请问这样的xslt怎么写??谢谢各位~~
<?xml version= "1.0 " encoding= "gb2312 "?>
<?xml-stylesheet type= "text/xsl " href= "menu.xsl "?>
<config>
<AA id= "1 ">
<BB> dir1 </BB>
<BB> dir2 </BB>
</AA>
<AA id= "2 ">
<BB> dir2 </BB>
</AA>
<dir1>
<F> C1 </F>
<F> C2 </F>
</dir1>
<dir2>
<F> C3 </F>
<F> C4 </F>
</dir2>
</config>
想通过判断AA id值获取目录列表,然后通过匹配此目录标签,得到对应F标签下的内容
比如 查找到id=1节点,显示出C1C2C3C4
id=2的节点,显示C3C4
请问这样的xslt怎么写??谢谢各位~~
[解决办法]
<?xml version= "1.0 " encoding= "UTF-8 "?>
<xsl:stylesheet version= "1.0 " xmlns:xsl= "http://www.w3.org/1999/XSL/Transform " xmlns:fo= "http://www.w3.org/1999/XSL/Format ">
<xsl:template match= "config ">
<xsl:for-each select= "AA ">
ID= <xsl:value-of select= "@id "/> : <br/>
<xsl:call-template name= "matchNode ">
<xsl:with-param name= "key " select= "BB "/>
</xsl:call-template>
<hr/>
</xsl:for-each>
</xsl:template>
<xsl:template name= "matchNode ">
<xsl:param name= "key "> </xsl:param>
<xsl:for-each select= "//*[name()=$key] ">
<xsl:for-each select= "F ">
<xsl:value-of select= ". "/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>