xslt中的内部链接不起作用 [英] Internal link in xslt does not work

查看:100
本文介绍了xslt中的内部链接不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些关于 xslt 文件的问题。


  1. TO TOP不能很好地工作。它只能在页面顶部工作,但当我向下滚动时,它不会作为链接。

  2. 内部链接无法正常工作。它将文字写入似乎是链接的,但只有文本被写为链接,并且不再有效。


你能帮我解决一下如何修复它们吗?

 <?xml version =1.0encoding = UTF-8\" >?; 
< xsl:stylesheet version =1.0xmlns:xsl =http://www.w3.org/1999/XSL/Transform>
< xsl:output method =htmlversion =5.0encoding =UTF-8indent =yes/>
< xsl:template match =SquishReport / test>
< html>
< head>
< style>

#header {text-align:left; padding:5px;}

#nav {line-height:25px; width:1400px; float:left; padding:5px ;}

#section {position:relative; left:20px; top:50px;}

#top {width:200px; position:fixed; top:60px; right :5px;}

table,th,td {border:1px solid black; border-collapse:collapse;}

th,td {padding:2px}

< / style>
< / head>
< body>

< div id =header>
< h2> Squish-Testauswertung(< xsl:value-of select =epilog / attribute :: time/>)< / h2>
< / div>

< div id =nav>
< h3>摘要< / h3>
< table>
< xsl:for-each select =test>
< xsl:variable name =LinkItselect =attribute :: name/>
< xsl:when test =descendant :: node()/ attribute :: type ='FAIL'>
< tr>
< td bgcolor =red>< a href =#{$ LinkIt}title =click for Information>< xsl:value-of select =$ LinkIt/> ;< / A>< / TD>
< / tr>
< / xsl:when>
< xsl:when test =message / attribute :: type ='ERROR'>
< tr>
< td bgcolor =yellow>< a href =#{$ LinkIt}title =click for Information>< xsl:value-of select =$ LinkIt/> ;< / A>< / TD>
< / tr>
< / xsl:when>
< xsl:when test =message / attribute :: type ='FATAL'>
< tr>
< td bgcolor =coral>< a href =#{$ LinkIt}title =click for Information>< xsl:value-of select =$ LinkIt/> ;< / A>< / TD>
< / tr>
< / xsl:when>
< xsl:when test =descendant :: node()/ attribute :: type ='PASS'>
< tr>
< td bgcolor =lime>< a href =#{$ LinkIt}title =click for Information>< xsl:value-of select =$ LinkIt/> ;< / A>< / TD>
< / tr>
< / xsl:when>
< / xsl:for-each>
< / table>
< / div>

< div id =top>
< a href =#title =返回页首>< b> TO TOP< / b>< / a>
< br />
< table>
< tr>
< th>< / th>
< td> Log< / td>
< / tr>
< tr>
< th width =20bgcolor =yellow>< / th>
< td>错误< / td>
< / tr>
< tr>
< th bgcolor =coral>< / th>
< td>致命< / td>
< / tr>
< tr>
< th bgcolor =red>< / th>
< td>失败< / td>
< / tr>
< tr>
< th bgcolor =lime>< / th>
< td>传递< / td>
< / tr>
< / table>
< / div>

< div id =section>
< h3>详情< / h3>

< table>
< tr bgcolor =秘鲁>
< th>测试名称< / th>
< th> Logs< / th>
< / tr>
< xsl:for-each select =test>
< xsl:variable name =LogNumselect =count(message)/>
< xsl:variable name =VerifNumselect =count(verification)/>
< tr>
th rowspan ={$ LogNum + $ VerifNum + 1}style =text-align:left; vertical-align:top; position:>< a name =#{$ linkName} >< xsl:value-of select =$ LinkName/>< / a>< / th>
< / tr>
< xsl:for-each select =descendant :: node()>
< xsl:when test =attribute :: type ='LOG'>
< tr>
< td>< xsl:value-of select =description/>< / td>
< / tr>
< / xsl:when>
< xsl:when test =attribute :: type ='FATAL'>
< tr>
< td bgcolor =coral>< xsl:value-of select =description/>< / td>
< / tr>
< / xsl:when>
< xsl:when test =attribute :: type ='ERROR'>
< tr>
< td bgcolor =yellow>< xsl:value-of select =description/>< / td>
< / tr>
< / xsl:when>
< xsl:when test =attribute :: type ='FAIL'>
< tr>
< td bgcolor =red>< xsl:value-of select =description/>< / td>
< / tr>
< / xsl:when>
< xsl:when test =attribute :: type ='PASS'>
< tr>
< td bgcolor =lime>< xsl:value-of select =description/>< / td>
< / tr>
< / xsl:when>
< / xsl:for-each>
< / xsl:for-each>
< / table>
< / div>
< / body>
< / html>
< / xsl:template>

解决方案

我假定您正在使用 Squishy格式版本3 ,并且你的测试用例不是嵌套的。



如果你的输入文档是,例如...

 < SquishReport xmlns =http://www.froglogic.com/resources/schemas/xml3version =3> 
< test type =testsuite>
< prolog time =2015-06-19T11:22:27 + 02:00>
< name>我的测试套件< /名称>
< / prolog>

< test type =testcase>
< prolog time =2015-06-19T11:22:27 + 02:00>
<名称>测试用例1< / name>
< location>
< uri> http://www.abc.net.au< / uri>
< / location>
< / prolog>
< verification>
< location>
< uri> x-testcase:/unit1.pas< / uri>
< lineNo> 2< / lineNo>
< / location>
< scriptedVerificationResult time =2015-06-19T11:22:27 + 02:01type =PASS>
< text>汇总了一列数字< / text>
< detail>总和是正确的< / detail>
< / scriptedVerificationResult>
< / verification>
<验证>
< location>
< uri> x-testcase:/unit1.pas< / uri>
< lineNo> 6< / lineNo>
< / location>
< propertyVerificationResult time =2015-06-19T11:22:27 + 02:01type =PASS/>
< / verification>
<验证>
< location>
< uri> x-testcase:/unit2.pas< / uri>
< lineNo> 3< / lineNo>
< / location>
< screenshotVerificationResult time =2015-06-19T11:22:27 + 02:02type =ERROR/>
< / verification>
< message time =2015-06-19T11:22:27 + 02:03type =LOG>这是日志消息< / message>
< message time =2015-06-19T11:22:27 + 02:04type =WARNING>这是一个警告< / message>
< message time =2015-06-19T11:22:27 + 02:05type =FATAL> Fatality!< / message>
< / test>

< test type =testcase>
< prolog time =2015-06-19T11:22:27 + 02:07>
<名称>测试用例2< / name>
< location>
< uri> http://feedly.com< / uri>
< / location>
< / prolog>
< verification>
< location>
< uri> x-testcase:/unit2.pas< / uri>
< lineNo> 5< / lineNo>
< / location>
< scriptedVerificationResult time =2015-06-19T11:22:27 + 02:08type =FAIL>
< text>出错了< / text>
< detail>堆栈溢出< / detail>
< / scriptedVerificationResult>
< / verification>
< / test>


< epilog time =2015-06-19T11:22:27 + 02:10/>
< / test>
< / SquishReport>

...然后这个XSLT 1.0样式表...

 < xsl:stylesheet 
xmlns:xsl =http://www.w3.org/1999/XSL/Transform
xmlns: sq =http://www.froglogic.com/resources/schemas/xml3
version =1.0
exclude-result-prefixes =sq>

< xsl:output method =htmlversion =5.0encoding =UTF-8indent =yes/>

< xsl:template match =sq:testmode =summary>
< xsl:apply-templates select =
(sq:verification / sq:scriptedVerificationResult [@ type ='FAIL'] |
sq:verification / sq:screenshotVerificationResult [@ type = 'FAIL'] |
sq:验证/平方:propertyVerificationResult [@ type ='FAIL'] |
sq:验证/ sq:tableVerificationResult [@ type ='FAIL']
)[ 1]mode =summary/>
< xsl:apply-templates select =
(sq:verification / sq:scriptedVerificationResult [@ type ='FATAL'] |
sq:verification / sq:screenshotVerificationResult [@type = '致命'] |
sq:验证/平方:propertyVerificationResult [@ type ='致命'] |
sq:验证/平方:tableVerificationResult [@ type ='致命'] |
sq :message [@ type ='FATAL']
)[1]mode =summary/>
< xsl:apply-templates select =
(sq:verification / sq:scriptedVerificationResult [@ type ='ERROR'] |
sq:verification / sq:screenshotVerificationResult [@type = '错误'] |
sq:验证/ sq:propertyVerificationResult [@ type ='ERROR'] |
sq:验证/ sq:tableVerificationResult [@ type ='ERROR']
)[ 1]mode =summary/>
< xsl:apply-templates select =
(sq:verification / sq:scriptedVerificationResult [@ type ='PASS'] |
sq:verification / sq:screenshotVerificationResult [@type = 'PASS'] |
sq:验证/平方:propertyVerificationResult [@ type ='PASS'] |
sq:验证/ sq:tableVerificationResult [@ type ='PASS']
)[ 1]mode =summary/>
< xsl:apply-templates select =sq:message [@ type ='WARNING'] [1]mode =summary/>
< / xsl:template>

< xsl:template match =@ type>
< xsl:attribute name =bgcolor>
< xsl:when test =。='FAIL'>红色< / xsl:when>
< xsl:when test =。='FATAL'> coral< / xsl:when>
< xsl:when test =。='ERROR'>黄色< / xsl:when>
< xsl:when test =。='PASS'> lime< / xsl:when>
< xsl:when test =。='WARNING'>琥珀< / xsl:when>
< / xsl:选择>
< / xsl:attribute>
< / xsl:template>



< xsl:template match =sq:scriptedVerificationResult |
sq:screenshotVerificationResult |
sq:propertyVerificationResult |
sq: tableVerificationResult |
sq:messagemode =summary>
< tr>< td>
< xsl:apply-templates select =@ type/>
self :: node()[not(self :: sq:message)] /../../ sq:prolog / sq:location / sq:uri / text()|
self :: sq:message /../ sq:prolog / sq:location / sq:uri / text()
}title =Click for Information>
self :: node()[not(self :: sq:message)] /../../ sq:prolog / sq:name |
self :: sq:message /../ sq:prolog / sq:name
/>
< / a>
< / td>< / tr>
< / xsl:template>

< xsl:template match =/>
< html>
< head>
< title> Squish-Testauswertung< / title>
< / head>
< body>
< div id =header>
< h2> Squish-Testauswertung(2015-06-19T11:22:27 + 02:00)< / h2>
< / div>
< div id =nav>
< h3>摘要< / h3>
< table>
< / table>
< / div>

< div id =top>
< br />
< table>
< tr>< th width =20>&#160;< / th> < TD>日志与LT; / TD>< / TR>
< tr>< th bgcolor =yellow>< / th>< td>错误< / td>< / tr>
< tr>< th bgcolor =coral>< / th>< td>致命< / td>< / tr>
< tr>< th bgcolor =amber>< / th>< td>警告< / td>< / tr>
< tr>< th bgcolor =red>< / th>< td>失败< / td>< / tr>
< tr>< th bgcolor =lime>< / th>< td> Pass< / td>< / tr>
< / table>
< / div>

< div id =section>
< h3>详情< / h3>
< table>
< tr bgcolor =秘鲁>< th>测试名称< / th>< th>日志< / th>< / tr>
< / table>
< / div>
< br />
< a href =#headertitle =到此页顶部>< b> TO TOP< / b>< / a>

< / body>
< / html>
< / xsl:template>

< tr>< th
rowspan ={count(sq:verification | sq:message)+ 1}
style =text-align:left; vertical-align:顶部;位置:>
< a>
< xsl:attribute name =name>
< xsl:value-of select =sq:prolog / sq:location / sq:uri/>
< / xsl:attribute>
< xsl:value-of select =sq:prolog / sq:name/>
< / a>< / th>< / tr>
< / xsl:template>

< xsl:template match =sq:verification [sq:scriptedVerificationResult]>
< tr>< td>
< xsl:apply-templates select =sq:scriptedVerificationResult / @ type/>
< xsl:value-of select =sq:scriptedVerificationResult / sq:detail/>
< / td>< / tr>
< / xsl:template>

< xsl:template match =sq:verification [sq:screenshotVerificationResult]>
< tr>< td>
< xsl:apply-templates select =sq:screenshotVerificationResult / @ type/>
< / td>< / tr>
< / xsl:template>

< xsl:template match =sq:verification [sq:propertyVerificationResult]>
< tr>< td>
< xsl:apply-templates select =sq:propertyVerificationResult / @ type/>
< xsl:text> propertyVerificationResult< / xsl:text>
< / td>< / tr>
< / xsl:template>

< xsl:template match =sq:verification [sq:tableVerificationResult]>
< tr>< td>
< xsl:text> tableVerificationResult< / xsl:text>
< / td>< / tr>
< / xsl:template>

< xsl:template match =sq:message>
< tr>< td>
< xsl:apply-templates select =@ type/>
< xsl:value-of select =text()/>
< / td>< / tr>
< / xsl:template>

< / xsl:stylesheet>

...会产生这样的结果....



  #header {text-align:left; padding:5px;}#nav {line-height:25px; width:1400px; float:left; padding:5px;}#部分{left:20px; top:50px;}#top {width:200px; position:fixed; top:60px; right:5px;} table,th,td {border:1px solid black; border-collapse:collapse;} th,td {padding:2px}  

< div id = 报头 > < H2>挤流-Testauswertung(2015-06-19T11:22:27 + 02:00)LT / H2> < / DIV> < div id =nav> < H3>总结< / H3> <表> < TR> < td bgcolor =coral>< a href =http://www.abc.net.autitle =click for Information>测试用例1< / a>< / td> < / TR> < TR> < td bgcolor =yellow>< a href =http://www.abc.net.autitle =click for Information>测试用例1< / a>< / td> < / TR> < TR> < td bgcolor =lime>< a href =http://www.abc.net.autitle =click for Information>测试用例1< / a>< / td> < / TR> < TR> < td bgcolor =amber>< a href =http://www.abc.net.autitle =点击查看信息>测试用例1< / a>< / td> < / TR> < TR> < td bgcolor =red>< a href =http://feedly.comtitle =点击查看信息>测试用例2< / a>< / td> < / TR> < /表> < / DIV> < div id =top>< br>< table> < TR> < th width =20> < /第> < TD>日志与LT; / TD> < / TR> < TR> < th bgcolor =yellow>< / th> < TD>错误< / TD> < / TR> < TR> < th bgcolor =coral>< / th> < TD>致命< / TD> < / TR> < TR> < th bgcolor =amber>< / th> < TD>警告< / TD> < / TR> < TR> < th bgcolor =red>< / th> < TD>失败< / TD> < / TR> < TR> < th bgcolor =lime>< / th> < TD>通行证< / TD> < / TR> < /表> < / DIV> < div id =section> < H3>详情< / H3> <表> < tr bgcolor =秘鲁> <的第i;测试名< /第> <的第i;日志< /第> < / TR> < TR> < th rowspan =7style =text-align:left; vertical-align:top; position:>< a name =http://www.abc.net.au>测试用例1·; / A>< /第> < / TR> < TR> < td bgcolor =lime>总和是正确的< / td> < / TR> < TR> < td bgcolor =lime> propertyVerificationResult< / td> < / TR> < TR> < td bgcolor =yellow> screenshotVerificationResult< / td> < / TR> < TR> < td bgcolor =>这是一条日志讯息< / td> < / TR> < TR> < td bgcolor =amber>这是一个警告< / td> < / TR> < TR> < td bgcolor =coral>死亡!< / td> < / TR> < TR> < th rowspan =2style =text-align:left; vertical-align:top; position:>< a name =http://feedly.com>测试用例2< / a> ;< /第> < / TR> < TR> < td bgcolor =red>堆栈溢出< / td> < / TR> < /表> < / div>< br>< a href =#headertitle =返回页首>< b> TO TOP< / b>< / a>< / body>


I have some problem regarding following xslt file.

  1. TO TOP does not work very well. It work only on top of page but when I am scrolling down then it is going not to be as a link.

  2. internal Link does not work properly. It writes the the text as seems to be linked but only the text is written as a link and it does not work anymore.

Can you please help me how can I fix them?

<?xml version="1.0" encoding="UTF-8"?>   
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="5.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="SquishReport/test">
    <html>
        <head>
            <style>

                #header {text-align:left;padding:5px;}

                #nav {line-height:25px;width:1400px;float:left;padding:5px;}

                #section {position:relative;left:20px;top:50px;}

                #top {width:200px;position:fixed;top: 60px;right: 5px;}

                table, th, td {border: 1px solid black;border-collapse: collapse;} 

                th, td {padding:2px}

            </style>
        </head>
        <body>

            <div id="header">
                <h2> Squish-Testauswertung(<xsl:value-of select="epilog/attribute::time"/>)</h2>
            </div>

            <div id="nav">
                <h3>Summary</h3>
                <table>
                    <xsl:for-each select="test">
                        <xsl:variable name="LinkIt" select="attribute::name"/>
                        <xsl:choose>
                            <xsl:when test="descendant::node()/attribute::type='FAIL'">
                                <tr>
                                    <td bgcolor="red"><a href="#{$LinkIt}" title="click for Information"><xsl:value-of select="$LinkIt"/></a></td>
                                </tr>
                            </xsl:when>
                            <xsl:when test="message/attribute::type='ERROR'">
                                <tr>
                                    <td bgcolor="yellow"><a href="#{$LinkIt}" title="click for Information"><xsl:value-of select="$LinkIt"/></a></td>
                                </tr>
                            </xsl:when>
                            <xsl:when test="message/attribute::type='FATAL'">
                                <tr>
                                    <td bgcolor="coral"><a href="#{$LinkIt}" title="click for Information"><xsl:value-of select="$LinkIt"/></a></td>
                                </tr>
                            </xsl:when>
                            <xsl:when test="descendant::node()/attribute::type='PASS'">
                                <tr>
                                    <td bgcolor="lime"><a href="#{$LinkIt}" title="click for Information"><xsl:value-of select="$LinkIt"/></a></td>
                                </tr>
                            </xsl:when>
                        </xsl:choose>
                    </xsl:for-each>
                </table>
            </div>

            <div id="top">
                <a href="#" title="To the top of this page"><b>TO TOP</b></a>
                <br/>
                <table>
                    <tr>
                        <th></th>
                        <td>Log</td>
                    </tr>
                    <tr>
                        <th width="20" bgcolor="yellow"></th>
                        <td>Error</td>
                    </tr>
                    <tr>
                        <th bgcolor="coral"></th>
                        <td>Fatal</td>
                    </tr>
                    <tr>
                        <th bgcolor="red"></th>
                        <td>Fail</td>
                    </tr>
                    <tr>
                        <th bgcolor="lime"></th>
                        <td>Pass</td>
                    </tr>
                </table>
            </div>

            <div id="section">
                <h3>Details</h3>

                <table>
                    <tr bgcolor="Peru">
                        <th>Testname</th>
                        <th>Logs</th>
                    </tr>
                    <xsl:for-each select="test">
                        <xsl:variable name="LogNum" select="count(message)" />
                        <xsl:variable name="VerifNum" select="count(verification)"/>
                        <xsl:variable name="LinkName" select="attribute::name"/>
                        <tr>
                            <th rowspan="{$LogNum+$VerifNum+1}" style="text-align:left;vertical-align:top;position:"><a name="#{$LinkName}"><xsl:value-of select="$LinkName"/></a></th>
                        </tr>
                        <xsl:for-each select="descendant::node()">
                            <xsl:choose>
                                <xsl:when test="attribute::type='LOG'">
                                    <tr>
                                        <td><xsl:value-of select="description"/></td>
                                    </tr>
                                </xsl:when>
                                <xsl:when test="attribute::type='FATAL'">
                                    <tr>
                                        <td bgcolor="coral"><xsl:value-of select="description"/></td>
                                    </tr>
                                </xsl:when>
                                <xsl:when test="attribute::type='ERROR'">
                                    <tr>
                                        <td bgcolor="yellow"><xsl:value-of select="description"/></td>
                                    </tr>
                                </xsl:when>
                                <xsl:when test="attribute::type='FAIL'">
                                    <tr>
                                        <td bgcolor="red"><xsl:value-of select="description"/></td>
                                    </tr>
                                </xsl:when>
                                <xsl:when test="attribute::type='PASS'">
                                    <tr>
                                        <td bgcolor="lime"><xsl:value-of select="description"/></td>
                                    </tr>
                                </xsl:when>
                            </xsl:choose>
                        </xsl:for-each>
                    </xsl:for-each>
                </table>
            </div>
        </body>
    </html>
</xsl:template>

解决方案

I have assumed that you are using Squishy format version 3, and that your test cases are not nested.

If your input document is, for example, ...

<SquishReport xmlns="http://www.froglogic.com/resources/schemas/xml3" version="3">
  <test type="testsuite">
    <prolog time="2015-06-19T11:22:27+02:00">
      <name>My test suite</name>
    </prolog>

  <test type="testcase">
    <prolog time="2015-06-19T11:22:27+02:00">
        <name>Test case 1</name>
        <location>
          <uri>http://www.abc.net.au</uri>
        </location>
      </prolog>
    <verification>
        <location>
          <uri>x-testcase:/unit1.pas</uri>
          <lineNo>2</lineNo>
        </location>
    <scriptedVerificationResult time="2015-06-19T11:22:27+02:01" type="PASS">
      <text>Summed a column of numbers</text>
      <detail>The sum was correct</detail>
    </scriptedVerificationResult>  
    </verification>
    <verification>
        <location>
          <uri>x-testcase:/unit1.pas</uri>
          <lineNo>6</lineNo>
        </location>
    <propertyVerificationResult time="2015-06-19T11:22:27+02:01" type="PASS" />
    </verification>
    <verification>
        <location>
          <uri>x-testcase:/unit2.pas</uri>
          <lineNo>3</lineNo>
        </location>
    <screenshotVerificationResult time="2015-06-19T11:22:27+02:02" type="ERROR" />
    </verification>
    <message time="2015-06-19T11:22:27+02:03" type="LOG">This is a log message</message>
    <message time="2015-06-19T11:22:27+02:04" type="WARNING">This is a warning</message>
    <message time="2015-06-19T11:22:27+02:05" type="FATAL">Fatality!</message>
    <epilog time="2015-06-19T11:22:27+02:06"/>
  </test>

  <test type="testcase">
    <prolog time="2015-06-19T11:22:27+02:07">
        <name>Test case 2</name>
        <location>
          <uri>http://feedly.com</uri>
        </location>
      </prolog>
    <verification>
        <location>
          <uri>x-testcase:/unit2.pas</uri>
          <lineNo>5</lineNo>
        </location>
    <scriptedVerificationResult time="2015-06-19T11:22:27+02:08" type="FAIL">
      <text>Something went wrong</text>
      <detail>Stack overflow</detail>
    </scriptedVerificationResult>  
    </verification>
    <epilog time="2015-06-19T11:22:27+02:09"/>
  </test>


  <epilog time="2015-06-19T11:22:27+02:10"/>
  </test>
</SquishReport>

... then this XSLT 1.0 stylesheet ...

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:sq="http://www.froglogic.com/resources/schemas/xml3"
  version="1.0"
  exclude-result-prefixes="sq">  

<xsl:output method="html" version="5.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="sq:test" mode="summary">
  <xsl:apply-templates select="
    (sq:verification/sq:scriptedVerificationResult  [@type='FAIL'] |
     sq:verification/sq:screenshotVerificationResult[@type='FAIL'] |
     sq:verification/sq:propertyVerificationResult  [@type='FAIL'] |
     sq:verification/sq:tableVerificationResult     [@type='FAIL'] 
     )[1]" mode="summary" />
  <xsl:apply-templates select="
    (sq:verification/sq:scriptedVerificationResult  [@type='FATAL'] |
     sq:verification/sq:screenshotVerificationResult[@type='FATAL'] |
     sq:verification/sq:propertyVerificationResult  [@type='FATAL'] |
     sq:verification/sq:tableVerificationResult     [@type='FATAL'] | 
     sq:message                                     [@type='FATAL'] 
     )[1]" mode="summary" />
  <xsl:apply-templates select="
    (sq:verification/sq:scriptedVerificationResult  [@type='ERROR'] |
     sq:verification/sq:screenshotVerificationResult[@type='ERROR'] |
     sq:verification/sq:propertyVerificationResult  [@type='ERROR'] |
     sq:verification/sq:tableVerificationResult     [@type='ERROR'] 
     )[1]" mode="summary" />
  <xsl:apply-templates select="
    (sq:verification/sq:scriptedVerificationResult  [@type='PASS'] |
     sq:verification/sq:screenshotVerificationResult[@type='PASS'] |
     sq:verification/sq:propertyVerificationResult  [@type='PASS'] |
     sq:verification/sq:tableVerificationResult     [@type='PASS'] 
     )[1]" mode="summary" />
  <xsl:apply-templates select="sq:message[@type='WARNING'][1]" mode="summary" />
</xsl:template>

<xsl:template match="@type">
    <xsl:attribute name="bgcolor">
      <xsl:choose>
        <xsl:when test=".='FAIL'"   >red</xsl:when>
        <xsl:when test=".='FATAL'"  >coral</xsl:when>
        <xsl:when test=".='ERROR'"  >yellow</xsl:when>
        <xsl:when test=".='PASS'"   >lime</xsl:when>
        <xsl:when test=".='WARNING'">amber</xsl:when>
      </xsl:choose>
    </xsl:attribute>  
</xsl:template>



<xsl:template match="sq:scriptedVerificationResult   |
                     sq:screenshotVerificationResult |
                     sq:propertyVerificationResult   |
                     sq:tableVerificationResult      |
                     sq:message" mode="summary">
  <tr><td>
    <xsl:apply-templates select="@type" />
    <a href="{
      self::node()[not(self::sq:message)]/../../sq:prolog/sq:location/sq:uri/text() |
      self::sq:message/../sq:prolog/sq:location/sq:uri/text() 
    }" title="click for Information">
      <xsl:value-of select="
        self::node()[not(self::sq:message)]/../../sq:prolog/sq:name |
        self::sq:message/../sq:prolog/sq:name
      " />
    </a>
  </td></tr>                                 
</xsl:template>

<xsl:template match="/">
  <html>
  <head>
    <title>Squish-Testauswertung</title>
  </head> 
  <body>
<div id="header">
<h2>Squish-Testauswertung(2015-06-19T11:22:27+02:00)</h2>
</div>
<div id="nav">
  <h3>Summary</h3>
  <table>
    <xsl:apply-templates select="sq:SquishReport/sq:test/sq:test[@type='testcase']" mode="summary" />
  </table>
</div>   

<div id="top">
  <br/>
  <table>
    <tr><th width="20" >&#160;</th> <td>Log</td></tr>
    <tr><th bgcolor="yellow"></th><td>Error</td></tr>
    <tr><th bgcolor="coral"></th><td>Fatal</td></tr>
    <tr><th bgcolor="amber"></th><td>Warning</td></tr>
    <tr><th bgcolor="red"></th><td>Fail</td></tr>
    <tr><th bgcolor="lime"></th><td>Pass</td></tr>
  </table>
</div>

<div id="section">
  <h3>Details</h3>
    <table>
      <tr bgcolor="Peru"><th>Testname</th><th>Logs</th></tr>
      <xsl:apply-templates select="sq:SquishReport/sq:test/sq:test[@type='testcase']" />
   </table>
</div>
<br/>
<a href="#header" title="To the top of this page"><b>TO TOP</b></a>

</body>  
</html>  
</xsl:template>

<xsl:template match="sq:test">
  <tr><th
        rowspan="{count( sq:verification | sq:message) + 1}"
        style="text-align:left;vertical-align:top;position:">
    <a>
      <xsl:attribute name="name">
        <xsl:value-of select="sq:prolog/sq:location/sq:uri" />
      </xsl:attribute>  
      <xsl:value-of select="sq:prolog/sq:name" />
    </a></th></tr>
  <xsl:apply-templates select="sq:verification | sq:message" />
</xsl:template>

<xsl:template match="sq:verification[sq:scriptedVerificationResult]">
   <tr><td>
     <xsl:apply-templates select="sq:scriptedVerificationResult/@type" />
     <xsl:value-of select="sq:scriptedVerificationResult/sq:detail" />
   </td></tr>
</xsl:template>

<xsl:template match="sq:verification[sq:screenshotVerificationResult]">
   <tr><td>
     <xsl:apply-templates select="sq:screenshotVerificationResult/@type" />
     <xsl:text>screenshotVerificationResult</xsl:text>
   </td></tr>
</xsl:template>

<xsl:template match="sq:verification[sq:propertyVerificationResult]">
   <tr><td>
     <xsl:apply-templates select="sq:propertyVerificationResult/@type" />
     <xsl:text>propertyVerificationResult</xsl:text>
   </td></tr>
</xsl:template>

<xsl:template match="sq:verification[sq:tableVerificationResult]">
   <tr><td>
     <xsl:apply-templates select="sq:tableVerificationResult/@type" />
     <xsl:text>tableVerificationResult</xsl:text>
   </td></tr>
</xsl:template>

<xsl:template match="sq:message">
   <tr><td>
     <xsl:apply-templates select="@type" />
     <xsl:value-of select="text()" />
   </td></tr>
</xsl:template>

</xsl:stylesheet>

... will yield a result like this ....

#header {text-align:left;padding:5px;}
#nav {line-height:25px;width:1400px;float:left;padding:5px;}
#section {left:20px;top:50px;}
#top {width:200px;position:fixed;top: 60px;right: 5px;}
table, th, td {border: 1px solid black;border-collapse: collapse;} 
th, td {padding:2px}

<div id="header">
      <h2>Squish-Testauswertung(2015-06-19T11:22:27+02:00)</h2>
    </div>
    <div id="nav">
      <h3>Summary</h3>
      <table>
        <tr>
          <td bgcolor="coral"><a href="http://www.abc.net.au" title="click for Information">Test case 1</a></td>
        </tr>
        <tr>
          <td bgcolor="yellow"><a href="http://www.abc.net.au" title="click for Information">Test case 1</a></td>
        </tr>
        <tr>
          <td bgcolor="lime"><a href="http://www.abc.net.au" title="click for Information">Test case 1</a></td>
        </tr>
        <tr>
          <td bgcolor="amber"><a href="http://www.abc.net.au" title="click for Information">Test case 1</a></td>
        </tr>
        <tr>
          <td bgcolor="red"><a href="http://feedly.com" title="click for Information">Test case 2</a></td>
        </tr>
      </table>
    </div>
    <div id="top"><br><table>
        <tr>
          <th width="20"> </th>
          <td>Log</td>
        </tr>
        <tr>
          <th bgcolor="yellow"></th>
          <td>Error</td>
        </tr>
        <tr>
          <th bgcolor="coral"></th>
          <td>Fatal</td>
        </tr>
        <tr>
          <th bgcolor="amber"></th>
          <td>Warning</td>
        </tr>
        <tr>
          <th bgcolor="red"></th>
          <td>Fail</td>
        </tr>
        <tr>
          <th bgcolor="lime"></th>
          <td>Pass</td>
        </tr>
      </table>
    </div>
    <div id="section">
      <h3>Details</h3>
      <table>
        <tr bgcolor="Peru">
          <th>Testname</th>
          <th>Logs</th>
        </tr>
        <tr>
          <th rowspan="7" style="text-align:left;vertical-align:top;position:"><a name="http://www.abc.net.au">Test case 1</a></th>
        </tr>
        <tr>
          <td bgcolor="lime">The sum was correct</td>
        </tr>
        <tr>
          <td bgcolor="lime">propertyVerificationResult</td>
        </tr>
        <tr>
          <td bgcolor="yellow">screenshotVerificationResult</td>
        </tr>
        <tr>
          <td bgcolor="">This is a log message</td>
        </tr>
        <tr>
          <td bgcolor="amber">This is a warning</td>
        </tr>
        <tr>
          <td bgcolor="coral">Fatality!</td>
        </tr>
        <tr>
          <th rowspan="2" style="text-align:left;vertical-align:top;position:"><a name="http://feedly.com">Test case 2</a></th>
        </tr>
        <tr>
          <td bgcolor="red">Stack overflow</td>
        </tr>
      </table>
    </div><br><a href="#header" title="To the top of this page"><b>TO TOP</b></a></body>

这篇关于xslt中的内部链接不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆