在XSL中引用自身数据的两种方法,如果你使用Msxml解析器,你可以用方法二: 方法一 <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mxh="http://xml.sz.luohuedu.net/"> <xsl:template match="/"> <mxh:Root> <Line Val="1"/> <Line Val="2"/> <Line Val="3"/> </mxh:Root> <xsl:for-each select="document('')/xsl:stylesheet/xsl:template/mxh:Root/Line"> <xsl:value-of select="@Val"/> </xsl:for-each> </xsl:template> </xsl:stylesheet> 方法二 <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"> <xsl:template match="/"> <xsl:variable name="Array"> <Root> <Line Val="1"/> <Line Val="2"/> <Line Val="3"/> </Root> </xsl:variable> <xsl:for-each select="msxsl:node-set($Array)/Root/Line"> <xsl:value-of select="@Val"/> </xsl:for-each> </xsl:template> </xsl:stylesheet>
|