Skip to content
Permalink
Browse files

Reformat buildDependency.xsl for readability and indentation.

  • Loading branch information
mbjones committed Aug 19, 2018
1 parent 0d8ff09 commit 49736569989c550bb9daf1cf31253042ca394e33
Showing with 132 additions and 126 deletions.
  1. +132 −126 buildDependencyTable.xsl
@@ -32,131 +32,137 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:doc="eml://ecoinformatics.org/documentation-2.2.0"
version="1.0">
<xsl:output method="html" indent="yes"/>

<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../default.css"/>
<title>EML Dependency Chart</title>
</head>
<body class="tabledefault">
<h2 class="title">EML Dependency Chart</h2>
<p>
To read this chart, look at the row header and move across to the X. The
relationship can be read
<em>&lt;row header&gt; depends on &lt;column header&gt;</em>
or
<em>&lt;row header&gt; imports &lt;column header&gt;</em>
</p>
<p>
If you read the chart in the reverse fashion the relationship becomes
<em>&lt;column header&gt; is depended on by &lt;row header&gt;</em>
or
<em>&lt;column header&gt; is imported by &lt;row header&gt;</em>
</p>
<p>
If one module depends on another, it is a good chance that you are going
to be using at least a small subset of the other modules nodes within
the module that you want to use. This can be seen clearly by looking
at the diagrams associated with each
<a href="index.html#moduleDescriptions">module</a>.
</p>
<table border="1" cellpadding="3">
<tr>
<th/>
<!--create the column headers-->
<xsl:for-each select="//doc:module">
<th valign="bottom" class="tablehead2">
<xsl:call-template name="verttext">
<xsl:with-param name="text" select="."/>
</xsl:call-template>
</th>
</xsl:for-each>
</tr>

<!--loop through each module to do the rows-->
<xsl:for-each select="/xs:schema/xs:annotation/xs:appinfo/doc:module">
<xsl:variable name="modFile">
<xsl:value-of select="."/>
</xsl:variable>
<tr>

<!--color the row based on it's position-->
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
<xsl:when test="position() mod 2 = 0">roweven</xsl:when>
</xsl:choose>
</xsl:attribute>

<!-- save the position for later use-->
<xsl:variable name="pos">
<xsl:value-of select="position() mod 2"/>
</xsl:variable>

<td class="tablehead2"><xsl:value-of select="."/></td> <!--the row header-->
<!--go through the list of modules again, this time comparing its imported
modules to the module name from the outer loop-->
<xsl:for-each select="/xs:schema/xs:annotation/xs:appinfo/doc:module">
<xsl:variable name="modName">
<xsl:value-of select="substring-before(., '.')"/>
</xsl:variable>
<td align="center">
<xsl:for-each select="document($modFile)//xs:import">
<xsl:variable name="importedDoc">
<xsl:value-of select="substring-before(./@schemaLocation, '.')"/>
</xsl:variable>
<!-- compare the import variable to the modName variable-->
<xsl:if test="normalize-space($importedDoc)=normalize-space($modName)">
<xsl:attribute name="class">
<xsl:choose>
<!--change the color of the X cells slightly-->
<xsl:when test="$pos = 1">rowoddemphasis</xsl:when>
<xsl:when test="$pos = 0">rowevenemphasis</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:text>X</xsl:text> <!--put the x where they are equal-->
</xsl:if>
<xsl:if test="normalize-space($modName)=normalize-space(substring-before($modFile, '.'))">
<!--color the diagonal cells where the info makes no sense-->
<xsl:attribute name="bgcolor">
<xsl:text>black</xsl:text>
</xsl:attribute>
</xsl:if>
</xsl:for-each>
&#160; <!--put in a nonbreaking space to create the empty cells-->
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>

<!--this template makes the table headers go vertical-->
<xsl:template name="verttext">
<xsl:param name="text"/>
<xsl:variable name="textchar">
<xsl:value-of select="substring($text, 1, 1)"/>
</xsl:variable>
<xsl:variable name="textend">
<xsl:value-of select="substring($text, 2)"/>
</xsl:variable>

<xsl:value-of select="$textchar"/><br/>

<xsl:if test="string-length($textend) > 0">
<!--recurse if there is anything left in the string-->
<xsl:call-template name="verttext">
<xsl:with-param name="text" select="$textend"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:doc="eml://ecoinformatics.org/documentation-2.2.0" version="1.0">

<xsl:output method="html" indent="yes"/>

<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../default.css"/>
<title>EML Dependency Chart</title>
</head>
<body class="tabledefault">
<h2 class="title">EML Dependency Chart</h2>
<p>
To read this chart, look at the row header and move across to the X. The relationship can be read
<em>&lt;row header&gt; depends on &lt;column header&gt;</em>
or
<em>&lt;row header&gt; imports &lt;column header&gt;</em>
</p>
<p>
If you read the chart in the reverse fashion the relationship becomes
<em>&lt;column header&gt; is depended on by &lt;row header&gt;</em>
or
<em>&lt;column header&gt; is imported by &lt;row header&gt;</em>
</p>
<p>
If one module depends on another, it is a good chance that you are going to be using at least a small subset of the other modules nodes within the module that you want to use. This can be seen clearly by looking at the diagrams associated with each
<a href="index.html#moduleDescriptions">module</a>.
</p>
<table border="1" cellpadding="3">
<tr>
<th/>
<!--create the column headers-->
<xsl:for-each select="//doc:module">
<th valign="bottom" class="tablehead2">
<xsl:call-template name="verttext">
<xsl:with-param name="text" select="."/>
</xsl:call-template>
</th>
</xsl:for-each>
</tr>

<!--loop through each module to do the rows-->
<xsl:for-each select="/xs:schema/xs:annotation/xs:appinfo/doc:module">
<xsl:variable name="modFile">
<xsl:value-of select="."/>
</xsl:variable>
<tr>
<!--color the row based on it's position-->
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
<xsl:when test="position() mod 2 = 0">roweven</xsl:when>
</xsl:choose>
</xsl:attribute>

<!-- save the position for later use-->
<xsl:variable name="pos">
<xsl:value-of select="position() mod 2"/>
</xsl:variable>

<td class="tablehead2"><xsl:value-of select="."/></td>
<!--the row header-->
<!--go through the list of modules again, this time comparing its imported modules to the module name from the outer loop-->

<xsl:for-each select="/xs:schema/xs:annotation/xs:appinfo/doc:module">
<xsl:variable name="modName">
<xsl:value-of select="substring-before(., '.')"/>
</xsl:variable>
<td align="center">

<xsl:for-each select="document($modFile)//xs:import">

<xsl:variable name="importedDoc">
<xsl:value-of select="substring-before(./@schemaLocation, '.')"/>
</xsl:variable>

<!-- compare the import variable to the modName variable-->
<xsl:if test="normalize-space($importedDoc)=normalize-space($modName)">
<xsl:attribute name="class">
<xsl:choose>
<!--change the color of the X cells slightly-->
<xsl:when test="$pos = 1">rowoddemphasis</xsl:when>
<xsl:when test="$pos = 0">rowevenemphasis</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:text>X</xsl:text>
<!--put the x where they are equal-->
</xsl:if>

<xsl:if test="normalize-space($modName)=normalize-space(substring-before($modFile, '.'))">
<!--color the diagonal cells where the info makes no sense-->
<xsl:attribute name="bgcolor">
<xsl:text>black</xsl:text>
</xsl:attribute>
</xsl:if>

</xsl:for-each>
&#160;
<!--put in a nonbreaking space to create the empty cells-->
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>

<!--this template makes the table headers go vertical-->
<xsl:template name="verttext">

<xsl:param name="text"/>

<xsl:variable name="textchar">
<xsl:value-of select="substring($text, 1, 1)"/>
</xsl:variable>

<xsl:variable name="textend">
<xsl:value-of select="substring($text, 2)"/>
</xsl:variable>

<xsl:value-of select="$textchar"/><br/>

<xsl:if test="string-length($textend) > 0">
<!--recurse if there is anything left in the string-->

<xsl:call-template name="verttext">
<xsl:with-param name="text" select="$textend"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

</xsl:stylesheet>

0 comments on commit 4973656

Please sign in to comment.
You can’t perform that action at this time.