RE: [xsl] XSL Dependency Mapping

Subject: RE: [xsl] XSL Dependency Mapping
From: Américo Albuquerque <melinor@xxxxxxx>
Date: Thu, 24 Jul 2003 18:38:21 +0100
Hi

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Andy Joslin
> Sent: Thursday, July 24, 2003 8:00 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> 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&#10;</xsl:text>
    <xsl:text>--+&#10;</xsl:text>
    <xsl:text>&#160;&#160;|&#10;</xsl:text>
    <xsl:apply-templates select="*[self::xsl:include or self::xsl:import]"/>
    <xsl:text>&#10;</xsl:text>
  </xsl:template>

  <xsl:template match="xsl:include">
    <xsl:param name="sep" select="'&#160;&#160;'"/>
    <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="'&#160;'"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:value-of select="concat($sep,'|&#10;')"/>
    <xsl:value-of select="concat($sep,'+-')"/>
    <xsl:value-of select="@href"/>
    <xsl:text> (include)</xsl:text>
    <xsl:text>&#10;</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,'&#160;')"/>
    </xsl:apply-templates>
  </xsl:template>

  <xsl:template match="xsl:import">
    <xsl:param name="sep" select="'&#160;&#160;'"/>
    <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="'&#160;'"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:value-of select="concat($sep,'|&#10;')"/>
    <xsl:value-of select="concat($sep,'+-')"/>
    <xsl:value-of select="@href"/>
    <xsl:text> (import)</xsl:text>
    <xsl:text>&#10;</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,'&#160;&#160;')"/>
    </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


Current Thread