]> matita.cs.unibo.it Git - helm.git/blob - helm/on-line/xslt/metadataLib.xsl
Also starting from metadatas it is now possible to select the number
[helm.git] / helm / on-line / xslt / metadataLib.xsl
1 <?xml version="1.0"?>
2
3 <xsl:stylesheet version="1.0"
4  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5  xmlns:subst="http://www.cs.unibo.it/helm/subst">
6
7 <xsl:param name="CICURI" select="''"/>
8 <xsl:param name="getterURL" select="''"/>
9 <xsl:param name="draw_graphURL" select="''"/>
10
11 <!--CSC: code cut & pasted from makeGraphLinks -->
12 <xsl:param name="uri_set_size" select="'30'"/>
13 <!--CSC: end of cut & paste from makeGraphLinks -->
14
15 <xsl:variable name="BaseRDFURL" select="concat($getterURL,'getxml?uri=helm:rdf:www.cs.unibo.it/helm/rdf/')"/>
16 <xsl:variable name="BaseRDFURLForward" select="concat($BaseRDFURL,'forward//')"/>
17 <xsl:variable name="BaseRDFURLBackward" select="concat($BaseRDFURL,'backward//')"/>
18
19 <!-- Next function to quote strings for JavaScript (i.e. ' ==> \' -->
20 <xsl:template name="jsquote">
21  <xsl:param name="s" select="''"/>
22  <xsl:param name="news" select="''"/>
23  <xsl:choose>
24   <xsl:when test="$s = ''"><xsl:value-of select="$news"/></xsl:when>
25   <xsl:otherwise>
26    <xsl:variable name="char" select="substring($s,1,1)"/>
27    <xsl:choose>
28     <xsl:when test='$char = "&apos;"'>
29      <xsl:call-template name="jsquote">
30       <xsl:with-param name="s" select="substring($s,2)"/>
31       <xsl:with-param name="news" select='concat($news,"\\\&apos;")'/>
32      </xsl:call-template>
33     </xsl:when>
34     <xsl:otherwise>
35      <xsl:call-template name="jsquote">
36       <xsl:with-param name="s" select="substring($s,2)"/>
37       <xsl:with-param name="news" select="concat($news,$char)"/>
38      </xsl:call-template>
39     </xsl:otherwise>
40    </xsl:choose>
41   </xsl:otherwise>
42  </xsl:choose>
43 </xsl:template>
44
45 <xsl:template match="/">
46  <html>
47   <head>
48    <subst:script language="JavaScript" src="/javascript/defaults.js"/>
49    <subst:script language="JavaScript" src="/javascript/utils.js"/>
50    <subst:script language="JavaScript" src="/javascript/control.js"/>
51    <subst:script language="JavaScript" src="/javascript/graphLinks.js"/>
52
53    <title>Metadata of <xsl:value-of select="$CICURI"/></title>
54   </head>
55   <body onLoad="window.focus()" bgColor="white">
56    <script>
57      var CICURI = "<xsl:value-of select="$CICURI"/>";
58 <![CDATA[
59      document.write('<h1>Metadata of <a target="cic" href="' + mkCICURL(CICURI) + '">' + CICURI + '</a></h1>');
60 ]]>
61    </script>
62    <xsl:apply-templates select="*"/>
63    <!--CSC: code almost cut & pasted from makeGraphLinks -->
64    <form name="uri_set_size">
65     Number of nodes to show when following an hyperlink to a graph:
66     <input type="text" onClick="return false" value="{$uri_set_size}" size="2"/> (30 suggested)
67    </form>
68    <!--CSC: end of cut & paste from makeGraphLinks -->
69   </body>
70  </html>
71 </xsl:template>
72
73 <xsl:template name="makelink">
74  <xsl:param name="name" select="''"/>
75  <xsl:param name="CICURI" select="''"/>
76  <xsl:param name="RDFURI" select="''"/>
77  <xsl:variable name="quotedCICURI">
78   <xsl:call-template name="jsquote">
79    <xsl:with-param name="s" select="$CICURI"/>
80   </xsl:call-template>
81  </xsl:variable>
82  <xsl:choose>
83   <xsl:when test="document(concat($BaseRDFURLBackward,$RDFURI))/*/*/*">
84    <p>
85     <script>
86      var CICURI = "<xsl:value-of select="$CICURI"/>";
87 <![CDATA[
88      document.write('<a target="theory" href="' + mkMetaTheoryURL(CICURI) + '">View the objects depending on it.</a>');
89 ]]>
90     </script>
91    </p>
92    <p>
93     <script>
94 <![CDATA[
95      document.write('<a href="" onClick="window.open(mkMetaURL(\']]><xsl:value-of select="$quotedCICURI"/><![CDATA[\'),\'graph\');return false;">View the graph of all the objects depending on this one.</a>');
96 ]]>
97     </script>
98    </p>
99   </xsl:when>
100   <xsl:otherwise>
101    <p>
102     Object <xsl:value-of select="$name"/> is never referenced in other objects
103    </p>
104   </xsl:otherwise>
105  </xsl:choose>
106
107  <xsl:choose>
108   <xsl:when test="document(concat($BaseRDFURLForward,$RDFURI))/*/*/*">
109    <p>
110     <!-- CSC: Cut & Paster from above ==> create a single javascript function -->
111     <script>
112 <![CDATA[
113      document.write('<a href="" onClick="window.open(mkDepURL(\']]><xsl:value-of select="$quotedCICURI"/><![CDATA[\'),\'graph\');return false;">View the graph of all the dependencies of this object.</a>');
114 ]]>
115     </script>
116    </p>
117   </xsl:when>
118   <xsl:otherwise>
119    <p>
120     Object <xsl:value-of select="$name"/> does not reference any other object
121    </p>
122   </xsl:otherwise>
123  </xsl:choose>
124 </xsl:template>
125
126 </xsl:stylesheet>