以下样式表:
XSLT 1.0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="text" encoding="UTF-8"/><xsl:strip-space elements="*"/><xsl:template match="/"> <xsl:for-each select="//definition"> <xsl:for-each select="ancestor::*"> <xsl:text>/</xsl:text> <xsl:value-of select="name()"/> <xsl:if test="(preceding-sibling::*|following-sibling::*)[name()=name(current())]"> <xsl:text>[</xsl:text> <xsl:value-of select="count(preceding-sibling::*[name()=name(current())]) + 1"/> <xsl:text>]</xsl:text> </xsl:if> </xsl:for-each> <xsl:text>/definition</xsl:text> <xsl:if test="position()!=last()"> <xsl:text> </xsl:text> </xsl:if> </xsl:for-each></xsl:template></xsl:stylesheet>
当应用于示例输入时,将返回:
/odML/section/definition/odML/section/property[1]/definition/odML/section/property[2]/definition/odML/section/property[2]/value/definition/odML/definition
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)