- 论坛徽章:
- 0
|
没人帮我, 还是自己来...
在这里自说自话真没劲啊
- <?xml version="1.0" encoding="UTF-8" ?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output method="xml" indent="yes"/>
- <xsl:template name="make_group">
- <xsl:param name="paths"/>
- <xsl:param name="prefix"/>
- <xsl:for-each select="$paths">
- <xsl:choose>
- <xsl:when test="not(starts-with(.,$prefix))">
- </xsl:when>
- <xsl:when test="contains(substring-after(.,$prefix),'\')">
- <xsl:variable name="id" select="generate-id(.)"/>
- <xsl:variable name="folder" select="substring-before(substring-after(.,$prefix),'\')"/>
- <xsl:variable name="new_prefix" select="concat($prefix,$folder,'\')"/>
- <xsl:if test="$id=generate-id($paths[concat($prefix,substring-before(substring-after(.,$prefix),'\'),'\')=$new_prefix][1])">
- <xsl:call-template name="make_group">
- <xsl:with-param name="paths" select="$paths"/>
- <xsl:with-param name="prefix" select="$new_prefix"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="id" select="generate-id(.)"/>
- <xsl:if test="$id=generate-id($paths[starts-with(.,$prefix)][1])">
- <xsl:element name="dir">
- <xsl:attribute name="path">
- <xsl:value-of select="substring($prefix,1,string-length($prefix)-1)"/>
- </xsl:attribute>
- </xsl:element>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:template>
- <xsl:template match="/">
- <xsl:call-template name="make_group">
- <xsl:with-param name="paths" select="/project/file/@path"/>
- <xsl:with-param name="prefix" select="''"/>
- </xsl:call-template>
- </xsl:template>
- </xsl:stylesheet>
复制代码
[ 本帖最后由 太平绅士 于 2009-1-27 17:00 编辑 ] |
|