]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/on-line/xslt/metadataLib.xsl
Code to share with makeGraphLinks.xsl extracted to graphLinks.js
[helm.git] / helm / on-line / xslt / metadataLib.xsl
index 95aab43f35817325360dedd77bf186cf3d271a55..900797e5f88c8c850af5f5d0f547d9588b27b39a 100644 (file)
@@ -6,6 +6,11 @@
 
 <xsl:param name="CICURI" select="''"/>
 <xsl:param name="getterURL" select="''"/>
+<xsl:param name="draw_graphURL" select="''"/>
+
+<xsl:variable name="BaseRDFURL" select="concat($getterURL,'getxml?uri=helm:rdf:www.cs.unibo.it/helm/rdf/')"/>
+<xsl:variable name="BaseRDFURLForward" select="concat($BaseRDFURL,'forward//')"/>
+<xsl:variable name="BaseRDFURLBackward" select="concat($BaseRDFURL,'backward//')"/>
 
 <xsl:template match="/">
  <html>
    <subst:script language="JavaScript" src="/javascript/defaults.js"/>
    <subst:script language="JavaScript" src="/javascript/utils.js"/>
    <subst:script language="JavaScript" src="/javascript/control.js"/>
+   <subst:script language="JavaScript" src="/javascript/graphLinks.js"/>
+
    <title>Metadata of <xsl:value-of select="$CICURI"/></title>
   </head>
   <body onLoad="window.focus()" bgColor="white">
-   <h1>Metadata of <xsl:value-of select="$CICURI"/></h1>
+   <script>
+     var CICURI = "<xsl:value-of select="$CICURI"/>";
+<![CDATA[
+     document.write('<h1>Metadata of <a target="cic" href="' + mkCICURL(CICURI) + '">' + CICURI + '</a></h1>');
+]]>
+   </script>
    <xsl:apply-templates select="*"/>
   </body>
  </html>
 </xsl:template>
 
-<xsl:template match="/" mode="makelink">
- <xsl:param name="name" select="''"/>
- <xsl:param name="RDFURI" select="''"/>
- <xsl:apply-templates select="*" mode="makelink">
-  <xsl:with-param name="name" select="$name"/>
-  <xsl:with-param name="RDFURI" select="$RDFURI"/>
- </xsl:apply-templates>
-</xsl:template>
-
-<xsl:template match="unresolved" mode="makelink">
- <xsl:param name="name" select="''"/>
- <p>
-  Object <xsl:value-of select="$name"/> is never referenced in other objects
- </p>
- <xsl:apply-templates select="." mode="mk_dep_graph"/>
-</xsl:template>
-
-<xsl:template match="url" mode="makelink">
+<xsl:template name="makelink">
  <xsl:param name="name" select="''"/>
+ <xsl:param name="CICURI" select="''"/>
  <xsl:param name="RDFURI" select="''"/>
- <p>
-  <script>
-   var RDFURI = "<xsl:value-of select="$RDFURI"/>";
-   var getterURL = "<xsl:value-of select="$getterURL"/>";
+ <xsl:choose>
+  <xsl:when test="document(concat($BaseRDFURLBackward,$RDFURI))/*/*/*">
+   <p>
+    <script>
+     var RDFURI = "helm:rdf:www.cs.unibo.it/helm/rdf/backward//<xsl:value-of select="$RDFURI"/>";
+     var getterURL = "<xsl:value-of select="$getterURL"/>";
 <![CDATA[
-   //url = setParam(url,"keys",getCICMathMLKeys());
-   var url = setParam(location.href,"keys","meta_theory%2CT1%2CT2%2CL%2CE");
-   url = setParam(url,"xmluri", getterURL + "getxml%3Furi%3D" + RDFURI);
-   document.write('<a target="theory" href="' + url + '">View the objects depending on it.</a>');
+     var url = setParam(location.href,"keys","meta_theory%2CT1%2CT2%2CL%2CE");
+     url = setParam(url,"xmluri", getterURL + "getxml%3Furi%3D" + RDFURI);
+     document.write('<a target="theory" href="' + url + '">View the objects depending on it.</a>');
 ]]>
-  </script>
- </p>
- <p>
-  <script>
-   var CICURI = "<xsl:value-of select="$CICURI"/>";
+    </script>
  </p>
  <p>
+    <script>
+     var CICURI = "<xsl:value-of select="$CICURI"/>";
 <![CDATA[
-   document.write('<a target="graph" href="http://localhost:8083/draw?url=' +
-    escape('http://localhost:8080/helm/servlet/uwobo/apply?xmluri=http://localhost:8081/getxml%3Furi%3D' + RDFURI + '&keys=MMG&param.getterURL=http%3A//localhost%3A8081/&prop.media-type=text/plain&param.CICURI=' + CICURI) + '">View the graph of all the objects dependending on this one.</a>');
+     document.write('<a target="graph" href="' + mkDepURL(CICURI,true) + '">View the graph of all the objects depending on this one.</a>');
 ]]>
-  </script>
- </p>
- <xsl:apply-templates select="." mode="mk_dep_graph"/>
-</xsl:template>
+    </script>
+   </p>
+  </xsl:when>
+  <xsl:otherwise>
+   <p>
+    Object <xsl:value-of select="$name"/> is never referenced in other objects
+   </p>
+  </xsl:otherwise>
+ </xsl:choose>
 
-<xsl:template match="*" mode="mk_dep_graph">
- <p>
-  <script>
-   var CICURI = "<xsl:value-of select="$CICURI"/>";
+ <xsl:choose>
+  <xsl:when test="document(concat($BaseRDFURLForward,$RDFURI))/*/*/*">
+   <p>
+    <!-- CSC: Cut & Paster from above ==> create a single javascript function -->
+    <script>
+     var CICURI = "<xsl:value-of select="$CICURI"/>";
 <![CDATA[
-   document.write('<a target="graph" href="http://localhost:8083/draw?url=' +
-    escape('http://localhost:8080/helm/servlet/uwobo/apply?xmluri=http://localhost:8081/getxml%3Furi%3D' + CICURI + '&keys=MDG&param.getterURL=http%3A//localhost%3A8081/&prop.media-type=text/plain&param.CICURI=' + CICURI) + '">View the graph of all the dependencies of this object.</a>');
+     document.write('<a target="graph" href="' + mkMetaURL(CICURI,true) + '">View the graph of all the dependencies of this object.</a>');
 ]]>
-  </script>
- </p>
+    </script>
+   </p>
+  </xsl:when>
+  <xsl:otherwise>
+   <p>
+    Object <xsl:value-of select="$name"/> does not reference any other object
+   </p>
+  </xsl:otherwise>
+ </xsl:choose>
 </xsl:template>
 
 </xsl:stylesheet>