Hi
-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
Andy Joslin
Sent: Thursday, July 24, 2003 8:00 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] XSL Dependency Mapping
Hi All
Does anyone know of a tool that can generate a dependency map
of a whole set of XSL's ? (i.e. which stylesheets import others, etc.)
A tool that generated some kind of site map/tree of related
XSLs would be great as I'm trying to clean up and reign in
some 400 files with a view to finding common dependencies, etc.
Does XML Spy have this feature ?
You could do that with xslt.
Try these templates:
<xsl:template match="xsl:stylesheet">
<xsl:text>Mappings </xsl:text>
<xsl:text>--+ </xsl:text>
<xsl:text>  | </xsl:text>
<xsl:apply-templates select="*[self::xsl:include or self::xsl:import]"/>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="xsl:include">
<xsl:param name="sep" select="'  '"/>
<xsl:variable name="nxt">
<xsl:choose>
<xsl:when test="following-sibling::*[self::xsl:include or
self::xsl:import][1]">
<xsl:value-of select="'|'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="' '"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat($sep,'| ')"/>
<xsl:value-of select="concat($sep,'+-')"/>
<xsl:value-of select="@href"/>
<xsl:text> (include)</xsl:text>
<xsl:text> </xsl:text>
<xsl:apply-templates
select="document(@href)/xsl:stylesheet/*[self::xsl:include or
self::xsl:import]">
<xsl:with-param name="sep" select="concat($sep,$nxt,' ')"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="xsl:import">
<xsl:param name="sep" select="'  '"/>
<xsl:variable name="nxt">
<xsl:choose>
<xsl:when test="following-sibling::*[self::xsl:include or
self::xsl:import][1]">
<xsl:value-of select="'|'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="' '"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat($sep,'| ')"/>
<xsl:value-of select="concat($sep,'+-')"/>
<xsl:value-of select="@href"/>
<xsl:text> (import)</xsl:text>
<xsl:text> </xsl:text>
<xsl:apply-templates
select="document(@href)/xsl:stylesheet/*[self::xsl:include or
self::xsl:import]">
<xsl:with-param name="sep" select="concat($sep,$nxt,'  ')"/>
</xsl:apply-templates>
</xsl:template>
Hope this helps you.
Regards,
Américo Albuquerque
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list