Advertisement
ems-paste

XSL attempt #2

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