Advertisement
ems-paste

XSL attempt #3 (success!)

Oct 26th, 2013
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 8.12 KB | None | 0 0
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3. <xsl:template match="/">
  4.  
  5. <html>
  6. <body>
  7. <div class="xml">
  8. <div class="entrez_id1">Gene 1 Entrez ID: <xsl:value-of select="queryresponse/queryinfo/ggp1id" /></div>
  9. <xsl:variable name="gene1" select="queryresponse/queryinfo/ggp1id"></xsl:variable>
  10. <div class="entrez_id2">Gene 2 Entrez ID: <xsl:value-of select="queryresponse/queryinfo/ggp2id" /></div>
  11. <xsl:variable name="gene2" select="queryresponse/queryinfo/ggp2id"></xsl:variable>
  12. <div class="results_total">Number of events retrieved for gene pair: <xsl:value-of select="queryresponse/queryinfo/resultcount" /></div>
  13.  
  14.  
  15. <!-- <xsl:variable name="i" value="0"></xsl:variable> -->
  16.  
  17. <!-- For each event list info: Event ID, average confidence, event description, and sentences from which event was extracted -->
  18. <xsl:for-each select="queryresponse/queryresults/events/event">
  19.   <div class="event">
  20.     <xsl:variable name="event_id"><xsl:value-of select="@id" /></xsl:variable>
  21.     <xsl:variable name="avg_confidence"><xsl:value-of select="@averageconfidence" /></xsl:variable>
  22.     <xsl:variable name="event_type"><xsl:value-of select="type" /></xsl:variable>
  23.     <xsl:variable name="event_description"><xsl:value-of select="description" /> </xsl:variable>
  24.    
  25.     <div class="event_info">
  26.       <div class="event_id">Event ID: <xsl:value-of select="@id" /></div>
  27.       <div class="avg_confidence">Average confidence:  <xsl:value-of select="@averageconfidence" /></div>
  28.       <div class="event_type">Event type: <xsl:value-of select="type" /></div>
  29.       <div class="event_description">Event description: <xsl:value-of select="description" /></div>
  30.     </div>
  31.  
  32.     <!-- For each occurrence print appropriately highlighted sentence -->
  33.     <div class="occurrences_wrapper">
  34.       Occurrences:
  35.       <xsl:for-each select="current()/occurrences/occurrence">
  36.         <div class="occurrence_row">
  37.           <div class="occurrence">
  38.             <!-- Get highlighting start and end positions and set current sentence -->
  39.             <script type="text/javascript">
  40.               clear_arrays();
  41.               add_to_starts(<xsl:value-of select="trigger/@offsetbeg" />);
  42.               add_to_ends(<xsl:value-of select="trigger/@offsetend" />);
  43.               <xsl:for-each select="current()/ggps/ggp">
  44.                 add_to_starts(<xsl:value-of select="@offsetbeg" />);
  45.                 add_to_ends(<xsl:value-of select="@offsetend" />);
  46.               </xsl:for-each>
  47.               set_sentence(&quot;<xsl:value-of select="sentence" />&quot;);
  48.             </script>
  49.          
  50.             <!-- Format sentence div's for display. Each sentence has unique id. -->
  51.             <div class="sentence_wrapper">
  52.               <div class="sentence">
  53.                 <xsl:attribute name="id"><xsl:value-of select="generate-id()" /></xsl:attribute>
  54.               </div>
  55.             </div> <!-- end sentence wrapper -->
  56.             <div class="description">
  57.               <p>Trigger: <xsl:value-of select="trigger" /></p>
  58.               <xsl:for-each select="current()/ggps/ggp">
  59.                 <p><xsl:value-of select="@role"/>: <xsl:value-of select="." /> (<xsl:value-of select="@consensusname"/>)</p>
  60.               </xsl:for-each>
  61.             </div>
  62.           </div> <!-- end occurrence -->
  63.          
  64.           <!-- Replace sentence div with highlighted sentence -->
  65.           <script>
  66.             document.getElementById('<xsl:value-of select="generate-id()" />').innerHTML = highlight();
  67.           </script>
  68.          
  69.           <form action="submit_label" method="post">
  70.             <!-- no problem here -->
  71.             <xsl:variable name="foo">bar</xsl:variable>
  72.             <input type="text" name="{$foo}" placeholder="{$foo}"></input><br></br>
  73.      
  74.             <!-- generates error -->
  75.             <input type="text" name="event_id" placeholder="{$event_id}"></input>
  76.             <input type="hidden" name="event_id" value="{$event_id}"></input>
  77.            
  78.            
  79.             <!--  
  80.              <input type="hidden" name="gene1" value="{$gene1}"></input>
  81.              <input type="hidden" name="gene2" value="{$gene2}"></input>
  82.              <input type="hidden" name="event_id" value="{$event_id}"></input>
  83.              <input type="hidden" name="avg_confidence" value="{$avg_confidence}"></input>
  84.              <input type="hidden" name="event_type" value="{$event_type}"></input>
  85.              <input type="hidden" name="event_description" value="{$event_description}"></input>
  86.            -->
  87.             <input class="radio" type="radio" name="classification" value="correct"></input>Correct<br></br>
  88.             <input class="radio" type="radio" name="classification" value="incorrect"></input>Incorrect<br></br>
  89.             <input class="radio" type="radio" name="classification" value="uncertain"></input>Uncertain
  90.             <div class="textarea"><textarea name="comment" placeholder="Event extraction comments" rows="5"></textarea></div>
  91.             <div><input class="button" type="submit" value="Submit" /></div>
  92.           </form>
  93.           </div> <!-- end occurrence_row -->
  94.            
  95.            
  96.           <xsl:if test="nestedOccurrences/*" >
  97.             <xsl:for-each select="nestedOccurrences/occurrence">
  98.             <div class="occurrence_row">
  99.               <div class="nested_occurrence">Nested Occurrence:
  100.                 <div class="event_type">Event type: <xsl:value-of select="type" /></div>
  101.            
  102.                 <!-- Get highlighting start and end positions and set current sentence -->
  103.                 <script type="text/javascript">
  104.                   clear_arrays();
  105.                   add_to_starts(<xsl:value-of select="trigger/@offsetbeg" />);
  106.                   add_to_ends(<xsl:value-of select="trigger/@offsetend" />);
  107.                   <xsl:for-each select="current()/ggps/ggp">
  108.                     add_to_starts(<xsl:value-of select="@offsetbeg" />);
  109.                     add_to_ends(<xsl:value-of select="@offsetend" />);
  110.                   </xsl:for-each>
  111.                   set_sentence(&quot;<xsl:value-of select="../../sentence" />&quot;);
  112.                 </script>
  113.            
  114.                 <!-- Format sentence div's for display. Each sentence has unique id. -->
  115.                 <div class="sentence_wrapper">
  116.                   <div class="sentence">
  117.                     <xsl:attribute name="id"><xsl:value-of select="generate-id()" /></xsl:attribute>
  118.                   </div>
  119.                  
  120.                 </div> <!-- end sentence wrapper -->
  121.                 <div class="description">
  122.                   <p>Trigger: <xsl:value-of select="trigger" /></p>
  123.                   <xsl:for-each select="current()/ggps/ggp">
  124.                     <p><xsl:value-of select="@role"/>: <xsl:value-of select="." /> (<xsl:value-of select="@consensusname"/>)</p>
  125.                   </xsl:for-each>
  126.                 </div>
  127.            
  128.                 <!-- Replace sentence div with highlighted sentence -->
  129.                 <script>
  130.                   document.getElementById('<xsl:value-of select="generate-id()" />').innerHTML = highlight();
  131.                 </script>
  132.            
  133.               </div> <!-- end nested occurrence -->
  134.               <form>
  135.                 <input class="radio" type="radio" name="classification" value="correct"></input>Correct<br></br>
  136.                 <input class="radio" type="radio" name="classification" value="incorrect"></input>Incorrect<br></br>
  137.                 <input class="radio" type="radio" name="classification" value="uncertain"></input>Uncertain
  138.                 <div  class="textarea"><textarea placeholder="Event extraction comments" rows="5"></textarea></div>
  139.                 <div><input class="button" type="submit" value="Submit" /></div>
  140.               </form>
  141.             </div> <!-- end occurrence row -->
  142.             </xsl:for-each>
  143.           </xsl:if>
  144.       </xsl:for-each> <!-- end of for each occurrence -->
  145.     </div> <!-- end occurrences wrapper -->
  146.  
  147.   </div> <!-- end of event div -->
  148.   </xsl:for-each> <!-- end of event -->
  149.  
  150. </div>
  151. </body>
  152. </html>
  153. </xsl:template>
  154. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement