Advertisement
Guest User

Untitled

a guest
May 2nd, 2012
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 4.35 KB | None | 0 0
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0"
  3. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4.  
  5.   <xsl:output method="html" indent="yes"/>
  6.  
  7.   <xsl:template match="Nodes/Node">
  8.     <xsl:apply-templates>
  9.       <xsl:sort select="substring-after(@name,' ')" data-type="number"/>
  10.     </xsl:apply-templates>
  11.   </xsl:template>
  12.  
  13.   <xsl:variable name="openTag">
  14.     <![CDATA[
  15.    <div>
  16.    ]]>
  17.   </xsl:variable>
  18.  
  19.   <xsl:variable name="closeTag">
  20.     <![CDATA[
  21.    </div>
  22.    ]]>
  23.   </xsl:variable>
  24.  
  25.   <xsl:template match="Nodes/Node/Node[not(@name='units' or @name='child data' or @name='stack')]">
  26.     <html>
  27.       <head>
  28.         <style type="text/css">
  29.           body {
  30.           font-size: 14px;
  31.           font-family: verdana;
  32.           background-color: white;
  33.  
  34.           }
  35.  
  36.           .root {
  37.           padding: 0px 0px 2px 0px;
  38.           }
  39.  
  40.           .root div {
  41.           padding: 0px 0px 0px 0px;
  42.           margin-left: 3em;
  43.           }
  44.         </style>
  45.       </head>
  46.       <body>
  47.         <!--Choose the appropriate color for the log-->
  48.         <xsl:variable name="txtcolor">
  49.           <xsl:variable name="colorcode" select="Prp[@name = 'type']/@value"/>
  50.           <xsl:choose>
  51.             <xsl:when test="$colorcode = '3'">red</xsl:when>
  52.             <xsl:when test="$colorcode = '0'">green</xsl:when>
  53.             <xsl:otherwise>blue</xsl:otherwise>
  54.           </xsl:choose>
  55.         </xsl:variable>
  56.  
  57.         <xsl:variable name="ownerid" select="Prp[@name='owner id']/@value" />
  58.         <xsl:variable name="nextownerid" select="preceding-sibling::Node[1]/Prp[@name='owner id']/@value"/>
  59.  
  60.         <!--Format the message to be displayed-->
  61.         <xsl:variable name="LogText">
  62.           <font color="{$txtcolor}">
  63.             <xsl:value-of select="Prp[@name='message']/@value"/>
  64.           </font>                
  65.         </xsl:variable>
  66.        
  67.         <!--Remarks are added if any-->
  68.         <xsl:variable name="Remarks">
  69.           <xsl:if test="string-length(Prp[@name = 'remarks']/@value) &gt; 1">
  70.             <br/>
  71.             <span style="margin-left: 2em">              
  72.               <img src="./info.png"></img>&#160;
  73.               <xsl:value-of select="Prp[@name = 'remarks']/@value"/>              
  74.             </span>
  75.           </xsl:if>
  76.         </xsl:variable>
  77.        
  78.         <!--Choose image to display-->
  79.         <xsl:variable name="Image">
  80.           <xsl:choose>
  81.             <xsl:when test="$txtcolor = 'green'">
  82.               <img src="./pass.png"></img>
  83.             </xsl:when>
  84.  
  85.             <xsl:when test="$txtcolor = 'red'">
  86.               <img src="./fail.png"></img>
  87.             </xsl:when>
  88.  
  89.             <xsl:when test="$txtcolor = 'yellow'">
  90.               <img src="./fail.png"></img>
  91.             </xsl:when>
  92.  
  93.             <xsl:otherwise>
  94.               <img src="./info.png"></img>
  95.             </xsl:otherwise>
  96.           </xsl:choose>
  97.         </xsl:variable>
  98.  
  99.         <!--Display the messages with indentation-->        
  100.         <div class="root">          
  101.           <xsl:choose>            
  102.             <xsl:when test="$ownerid &lt; $nextownerid">
  103.               <xsl:value-of select="$openTag" disable-output-escaping="yes"/>
  104.               <xsl:copy-of select="$Image"/>&#160;
  105.               <b>
  106.                 <xsl:copy-of select="$LogText"/>
  107.               </b>
  108.               <xsl:copy-of select="$Remarks"/>
  109.             </xsl:when>
  110.  
  111.             <xsl:when test="$ownerid &gt; $nextownerid">
  112.               <xsl:value-of select="$openTag" disable-output-escaping="yes"/>
  113.               <xsl:copy-of select="$Image"/>&#160;
  114.               <xsl:copy-of select="$LogText"/>
  115.               <xsl:copy-of select="$Remarks"/>
  116.               <xsl:value-of select="$closeTag" disable-output-escaping="yes"/>
  117.               <xsl:value-of select="$closeTag" disable-output-escaping="yes"/>
  118.  
  119.             </xsl:when>
  120.  
  121.             <xsl:otherwise>
  122.               <xsl:value-of select="$openTag" disable-output-escaping="yes"/>
  123.               <xsl:copy-of select="$Image"/>&#160;
  124.               <xsl:copy-of select="$LogText"/>
  125.               <xsl:copy-of select="$Remarks"/>
  126.               <xsl:value-of select="$closeTag" disable-output-escaping="yes"/>
  127.             </xsl:otherwise>
  128.           </xsl:choose>        
  129.         </div>
  130.       </body>
  131.     </html>
  132.   </xsl:template>
  133.  
  134. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement