Comparación presupuestaria
Nota 2.13: Préstamo a largo plazo
There is a second file that converts XML to HTML. It starts like this.
1700 <xsl:stylesheet
1701 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 1702 xmlns:m="http://www.w3.org/1998/Math/MathML"
1703 xmlns:html="http://www.w3.org/1999/xhtml" 1704 exclude-result-prefixes="m html " >
It is followed by some lines, identical to lines 1481–1500 that we shall reproduce here. The only thing that changes is the following variable.
1705 <xsl:variable name="Directory" select="concat($LeProjet, $year,’_Topics’)"/>
This constructs the toc on the main page. It consists in the following items: the composi- tion of the team, the presentation (see below, the non-topic part thereof is selected), the text: “View by topics”, all modules that have a topic, ordered by topics, surrounded by horizontal rules, followed by all modules that have no topic, including the bibliography. All links here have tar- get=‘mainraweb04’.
1706 <xsl:template name="table.matieres"> 1707 <div class="non-topic">
1708 <a href="{/raweb/identification/team/@id}.html" target="mainraweb04"> Members 1709 </a>
1710 </div>
1711 <xsl:call-template name="presentation_tdm_entry" /> 1712 <hr class="topic_color" />
1713 <div align="right"><font color="green">View by topics<br/></font></div> 1714 <xsl:call-template name="table.topic"> 1715 <xsl:with-param name="class">tdm_window</xsl:with-param> 1716 </xsl:call-template> 1717 <hr class="topic_color" /> 1718 <ul class="tdm_window"> 1719 <xsl:call-template name="table.section" /> 1720 <li>
1721 <a href="{/raweb/biblio/@id}.html" target="mainraweb04"> 1722 <xsl:value-of select="/raweb/biblio[1]/@titre"/> 1723 </a>
1724 </li> 1725 </ul>
1726 </xsl:template>
This is the TOC in the case of topics. There is a little difference with the code shown above: in fact, from the TOC frame you can toggle to the non-topic version.
1727 <xsl:template name="tdm">
1729 <div class="tdmdiv"> 1730 <BR/>
1731 <xsl:call-template name="jg.insert-team-name"/> 1732 <hr />
1733 <div class="non-topic">
1734 <a href="{/raweb/identification/team/@id}.html" target="mainraweb04"> Members </a> 1735 </div> 1736 <xsl:call-template name="presentation_tdm_entry"/> 1737 <xsl:call-template name="acces.topic"/> 1738 <xsl:call-template name="table.topic"> 1739 <xsl:with-param name="class">tdm_frame</xsl:with-param> 1740 </xsl:call-template> 1741 <xsl:call-template name="table.section"/>
1742 <a href="{/raweb/biblio/@id}.html" target="mainraweb04"> 1743 <xsl:value-of select="/raweb/biblio[1]/@titre"/> 1744 </a>
1745 </div>
1746 </xsl:template>
Note: it is assumed that either all modules in a section have a topic, or none. If this assertion fails, some module might be missing, or appear more than once.
This takes all modules from the eight main sections (‘presentation’ excepted) that have no topic, and creates a list item for them; it will contain the list of modules of the section.
1747 <xsl:template name="table.section">
1748 <xsl:for-each select="/raweb/child::*[ self::fondements or self::domaine
1749 or self::logiciels or self::resultats or
1750 self::contrats or self::international or self::diffusion]"> 1751 <xsl:if test="not(child::subsection/@topic)"> 1752 <li> 1753 <xsl:value-of select="./bodyTitle" /> 1754 <ul> 1755 <xsl:for-each select="subsection"> 1756 <xsl:call-template name="item_title_or_not_title" /> 1757 </xsl:for-each> 1758 </ul> 1759 </li> 1760 </xsl:if > 1761 </xsl:for-each> 1762 </xsl:template>
This is the same code as in the non-topic case, but the attribute of the <div> is not the same, and the section title is missing.15
1763 <xsl:template name="presentation_tdm_entry"> 1764 <xsl:if test="not(/raweb/presentation/subsection/@topic)"> 1765 <div class="non-topic"> 1766 <xsl:call-template name=presentation_tdm_entry.JG"/> 1767 </div> 1768 </xsl:if> 1769 </xsl:template>
For each <topic>, we output its name, in small caps, and for each section that has a module with this topic, we output the name of the section, and the relevant modules. The template takes a parameter, but it is not used.
15In the case where modules in the presentation section have topics, the algorithm for finding the previous module
1770 <xsl:template name="table.topic"> 1771 <xsl:param name="class" /> 1772 <div class="topic">
1773 <xsl:for-each select="/raweb/topic">
1774 <xsl:variable name="num-topic" select="@id" /> 1775 <h3 class="smallcap"> <xsl:apply-templates /></h3> 1776 <xsl:for-each select="/raweb/child::*[self::presentation
1777 or self::fondements or self::domaine or
1778 self::logiciels or self::resultats or self::contrats or
1779 self::international or self::diffusion]"> 1780 <xsl:if test="subsection[@topic=$num-topic]"> 1781 <xsl:value-of select="bodyTitle" /> 1782 <ul> 1783 <xsl:for-each select="subsection[@topic=$num-topic]"> 1784 <xsl:call-template name="item_title_or_not_title" /> 1785 </xsl:for-each> 1786 </ul> 1787 </xsl:if> 1788 </xsl:for-each> 1789 </xsl:for-each> 1790 </div> 1791 <br/> 1792 </xsl:template>
This finds the previous module. There are two cases to consider: it depends on whether we are in the topic part, or non-topic part. We use two variables: $var is the current topic id and $precedentTopic is the previous topic (or is empty if there is no previous topic).
1793 <xsl:template name="precedent">
1794 <xsl:variable name="var" select="./@topic" /> 1795 <xsl:variable name="precedentTopic"
1796 select="/raweb/topic[@id=$var]/preceding-sibling::topic[1]" /> 1797 <xsl:choose>
First assume that the module has a topic. The easy case is when there is a preceding sibling with the same topic. We chose the first one. Otherwise, we consider all modules that have as topic the previous topic; we select the last one; if this fails, we select the last module of the presentation section. 1798 <xsl:when test="./@topic"> 1799 <xsl:choose> 1800 <xsl:when test="preceding::subsection[@topic=$var]"> 1801 <xsl:value-of select="preceding::subsection[@topic=$var][1]/@id" /> 1802 </xsl:when> 1803 <xsl:when test="/raweb/descendant::subsection[@topic=($precedentTopic/@id)]"> 1804 <xsl:variable name="precedingTopicId" select="$precedentTopic/@id" /> 1805 <xsl:variable name="lastSubsection" 1806 select="/raweb/descendant::subsection[@topic=($precedentTopic/@id)][last()]" /> 1807 <xsl:value-of select="$lastSubsection/@id" /> 1808 </xsl:when> 1809 <xsl:otherwise> 1810 <xsl:value-of select="/raweb/presentation/subsection[last()]/@id" /> 1811 </xsl:otherwise> 1812 </xsl:choose> 1813 </xsl:when>
We consider now the case where the module has no topic. In the case where there is a preceding sibling in the same section without topic, we chose the first one. In the case where the section is the presentation, our module is located before the modules with topics, thus the preceding page is
that with the composition. If there is a preceding module without topic, we use it. Otherwise, if there are topics, and if there is a module with a topic, we chose the last module of the last topic. Otherwise, we chose the page with the team.
1814 <xsl:otherwise> 1815 <xsl:choose>
1816 <xsl:when test="parent::presentation and position()=1"> 1817 <xsl:value-of select="/raweb/identification/team/@id" /> 1818 </xsl:when> 1819 <xsl:when test="preceding-sibling::subsection[not(./@topic)]"> 1820 1821 <xsl:value-of select="preceding-sibling::subsection[not(./@topic)][1]/@id" /> 1822 </xsl:when> 1823 <xsl:when test="../preceding-sibling::*[1]/subsection[not(./@topic)]"> 1824 <xsl:value-of select="../preceding-sibling::*[1]/ 1825 subsection[not(./@topic)][last()]/@id" /> 1826 </xsl:when>
1827 <xsl:when test="/raweb/topic and /raweb/descendant::subsection[@topic]"> 1828 <xsl:variable name="lastTopic" select="//topic[last()]/@id" />
1829 <xsl:variable name="lastSubsection" 1830 select="/raweb/descendant::subsection[@topic=$lastTopic][last()]" /> 1831 <xsl:value-of select="$lastSubsection/@id" /> 1832 </xsl:when> 1833 <xsl:otherwise> 1834 <xsl:value-of select="/raweb/identification/team/@id" /> 1835 </xsl:otherwise> 1836 </xsl:choose> 1837 </xsl:otherwise> 1838 </xsl:choose> 1839 </xsl:template>
This finds the next module. The algorithm is the same as above (to be precise: if X precedes Y, then Y follows X).
1840 <xsl:template name="suivant">
1841 <xsl:variable name="var" select="./@topic" /> 1842 <xsl:variable name="followingTopic"
1843 select="/raweb/topic[@id=$var]/following-sibling::topic[1]" /> 1844 <xsl:choose>
There are two cases to consider. First assume that the module has a topic. The easy case is when there is a following sibling with a topic. We chose the first one. The next case is when there is a module with the following topic. We chose the first one. Then we consider the case where the current topic is the last one, and there is a module in one of the main sections (not presentation) that has no topic; the first one is selected. Otherwise, the next page is the bibliography.
1845 <xsl:when test="./@topic"> 1846 <xsl:choose> 1847 <xsl:when test="following::subsection[@topic=$var]"> 1848 <xsl:value-of select="following::subsection[@topic=$var][1]/@id" /> 1849 </xsl:when> 1850 <xsl:when test="/raweb/descendant::subsection[@topic=$followingTopic/@id]"> 1851 <xsl:value-of select="/raweb/descendant::subsection 1852 [@topic=$followingTopic/@id][1]/@id" /> 1853 </xsl:when>
1854 <xsl:when test="not($followingTopic) and
1855 /raweb/*[name()!=’presentation’]/subsection[not(@topic) or @topic=’’]"> 1856 <xsl:value-of select="/raweb/*[name()!=’presentation’]/
1858 </xsl:when> 1859 <xsl:otherwise> 1860 <xsl:text>bibliography</xsl:text> 1861 </xsl:otherwise> 1862 </xsl:choose> 1863 </xsl:when>
We consider here the case where the module has no topic. The easy case is when the section contains a following module without topic. Then comes the case where we are in the presentation section, it is the last module, and there is a module with a topic: in this case we chose the first module with the first topic. Otherwise we consider the case where there is a following module without topic, we chose the first one. Otherwise, we seclect the bibliography.
1864 <xsl:otherwise> 1865 <xsl:choose>
1866 <xsl:when test="following-sibling::subsection[not(@topic) or @topic=’’]"> 1867 <xsl:value-of select="following-sibling::subsection[not(@topic)
1868 or @topic=’’][1]/@id" />
1869 </xsl:when>
1870 <xsl:when test="parent::presentation and (position()=last())
1871 and /raweb/descendant::subsection[@topic and not(@topic=’’)]">
1872 <xsl:variable name="firstTopicId" select="/raweb/topic[1]/@id" /> 1873 <xsl:value-of select="/raweb/descendant::subsection
1874 [@topic=$firstTopicId][1]/@id" />
1875 </xsl:when>
1876 <xsl:when test="../following-sibling::*[1]/subsection[not(@topic) or @topic=’’]"> 1877 1878 <xsl:value-of select="../following-sibling::*[1]/subsection 1879 [not(@topic) or @topic=’’][1]/@id" /> 1880 </xsl:when> 1881 <xsl:otherwise> 1882 <xsl:text>bibliography</xsl:text> 1883 </xsl:otherwise> 1884 </xsl:choose> 1885 </xsl:otherwise> 1886 </xsl:choose> 1887 </xsl:template>
In the case where a module has a real title, we show the title of the section instead of the title of the module. Otherwise we do nothing.
1888 <xsl:template match="subsection[@topic]/bodyTitle"> 1889 <xsl:if test=".!=’(Sans Titre)’">
1890 <h1> <xsl:value-of select="../../bodyTitle" /> </h1> 1891 </xsl:if>
1892 </xsl:template>
In the case where the current element has a topic attribute, we output the value of the topic reference. Otherwise, we just output the section.
1893 <xsl:template name="section_title"> 1894 <xsl:choose>
1895 <xsl:when test="./@topic">
1896 <xsl:variable name="VarTop" select="@topic" />
1897 <h2>Topic : <xsl:value-of select="/raweb/topic[@id=$VarTop]" /></h2> 1898 </xsl:when>
1899 <xsl:otherwise>
1900 <h2>Section : <xsl:value-of select="../bodyTitle" /></h2> 1901 </xsl:otherwise>
1902 </xsl:choose> 1903 </xsl:template>
In all other cases, a body title disappears.
1904 <xsl:template match="subsection/bodyTitle"></xsl:template>
This is the end of the file.
1905 </xsl:stylesheet>