Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用xsl以相反顺序读取xml_Xml_Xslt_Xslt 1.0_Reverse - Fatal编程技术网

使用xsl以相反顺序读取xml

使用xsl以相反顺序读取xml,xml,xslt,xslt-1.0,reverse,Xml,Xslt,Xslt 1.0,Reverse,我试图搜索并使其工作,但我失败了。有人能帮我得到一个正确的XSL文件,以相反的顺序得到XML节点吗 我的XML文件如下所示 <?xml version="1.0" standalone="no"?> <?xml-stylesheet type='text/xsl' href='ResultXSL.xsl'?> <Automation> <Run> <client1> <Date>25/02/2014</Date&g

我试图搜索并使其工作,但我失败了。有人能帮我得到一个正确的XSL文件,以相反的顺序得到XML节点吗

我的XML文件如下所示

<?xml version="1.0" standalone="no"?>
<?xml-stylesheet type='text/xsl' href='ResultXSL.xsl'?>
<Automation>
<Run>
<client1>
  <Date>25/02/2014</Date>
  <TotalTests>23</TotalTests>
  <Success>13</Success>
  <Failures>10</Failures>
</client1>
<client2>
  <Date>25/02/2014</Date>
  <TotalTests>4</TotalTests>
  <Success>0</Success>
  <Failures>4</Failures>
</client2>
<client3>
  <Date>25/02/2014</Date>
  <TotalTests>9</TotalTests>
  <Success>3</Success>
  <Failures>6</Failures>
</client3>
</Run> 
<Run>
<client1>
  <Date>26/02/2014</Date>
  <TotalTests>23</TotalTests>
  <Success>13</Success>
  <Failures>10</Failures>
</client1>
<client2>
  <Date>25/02/2014</Date>
  <TotalTests>4</TotalTests>
  <Success>0</Success>
  <Failures>4</Failures>
</client2>
<client3>
  <Date>25/02/2014</Date>
  <TotalTests>9</TotalTests>
  <Success>3</Success>
  <Failures>6</Failures>
</client3>
</Run>
<Run>
<client1>
  <Date>27/02/2014</Date>
  <TotalTests>23</TotalTests>
  <Success>13</Success>
  <Failures>10</Failures>
</client1>
<client2>
  <Date>25/02/2014</Date>
  <TotalTests>4</TotalTests>
  <Success>0</Success>
  <Failures>4</Failures>
</client2>
<client3>
  <Date>25/02/2014</Date>
  <TotalTests>9</TotalTests>
  <Success>3</Success>
  <Failures>6</Failures>
 </client3>
 </Run>
 </Automation>

25/02/2014
23
13
10
25/02/2014
4.
0
4.
25/02/2014
9
3.
6.
26/02/2014
23
13
10
25/02/2014
4.
0
4.
25/02/2014
9
3.
6.
27/02/2014
23
13
10
25/02/2014
4.
0
4.
25/02/2014
9
3.
6.
我需要以相反的顺序打印运行节点。目前我有XSL以正确的顺序打印它

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"      xmlns:TESA="tesa.philips.com">
<xsl:template match="/">
<html>
  <head>
  <meta http-equiv="refresh" content="30" />
  </head>
  <body>
    <hr/>
    <p>
      <table border="5"  cellpadding="3" cellspacing="0" width="1200">
        <tr>
          <th style="font-weight:bold;background:#a6caf0;width:350px;height:80">Date</th>
          <th style="font-weight:bold;background:#a6caf0;width:350px">Total Tests</th>
          <th style="font-weight:bold;background:#a6caf0;width:350px">Passed</th>
          <th style="font-weight:bold;background:#a6caf0;width:350px">Failure</th>
        </tr>
        <xsl:for-each select="Automation/Run">
          <tr>
            <td class="cellTextLeft">
              <xsl:value-of select="client1/Date"/>
            </td>
            <td class="cellTextLeft">
              <xsl:value-of select="client1/TotalTests"/>
            </td>
            <td class="cellTextLeft">
              <xsl:value-of select="client1/Success"/>
            </td>
            <td class="cellTextLeft">
              <xsl:value-of select="client1/Failures"/>
            </td>
          </tr>
          <tr>
            <td class="cellTextLeft">
              <xsl:value-of select="client2/Date"/>
            </td>
            <td class="cellTextLeft">
              <xsl:value-of select="client2/TotalTests"/>
            </td>
            <td class="cellTextLeft">
              <xsl:value-of select="client2/Success"/>
            </td>
            <td class="cellTextLeft">
              <xsl:value-of select="client2/Failures"/>
            </td>
          </tr>
          <tr>
            <td class="cellTextLeft">
              <xsl:value-of select="client3/Date"/>
            </td>
            <td class="cellTextLeft">
              <xsl:value-of select="client3/TotalTests"/>
            </td>
            <td class="cellTextLeft">
              <xsl:value-of select="client3/Success"/>
            </td>
            <td class="cellTextLeft">
              <xsl:value-of select="client3/Failures"/>
            </td>
          </tr>
          <tr style="background:Gray">
            <td style="height:20"> - </td>
            <td></td>               
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
        </xsl:for-each>
      </table>
    </p>
  </body>
</html>


日期 总测试 通过 失败 -

使用

    <xsl:for-each select="Automation/Run">
      <xsl:sort select="position()" data-type="number" order="descending"/>
      <tr>
        <td class="cellTextLeft">
          <xsl:value-of select="client1/Date"/>
        </td>

而不是

    <xsl:for-each select="Automation/Run">
      <tr>
        <td class="cellTextLeft">
          <xsl:value-of select="client1/Date"/>
        </td>

使用


而不是

    <xsl:for-each select="Automation/Run">
      <tr>
        <td class="cellTextLeft">
          <xsl:value-of select="client1/Date"/>
        </td>

试试这个样式表:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:TESA="tesa.philips.com">
    <xsl:template match="/">
        <html>
            <head>
                <meta http-equiv="refresh" content="30" />
            </head>
            <body>
                <hr/>
                <p>
                    <table border="5"  cellpadding="3" cellspacing="0" width="1200">
                        <tr>
                            <th style="font-weight:bold;background:#a6caf0;width:350px;height:80">Date</th>
                            <th style="font-weight:bold;background:#a6caf0;width:350px">Total Tests</th>
                            <th style="font-weight:bold;background:#a6caf0;width:350px">Passed</th>
                            <th style="font-weight:bold;background:#a6caf0;width:350px">Failure</th>
                        </tr>
                        <xsl:for-each select="Automation/Run">
                            <xsl:for-each select="*">
                                <xsl:sort select="name()" order="descending"/>
                                <tr>
                                    <td class="cellTextLeft">
                                        <xsl:value-of select="current()/descendant::Date"/>
                                    </td>
                                    <td class="cellTextLeft">
                                        <xsl:value-of select="current()/descendant::TotalTests"/>
                                    </td>
                                    <td class="cellTextLeft">
                                        <xsl:value-of select="current()/descendant::Success"/>
                                    </td>
                                    <td class="cellTextLeft">
                                        <xsl:value-of select="current()/descendant::Failures"/>
                                    </td>
                                </tr>
                            </xsl:for-each>
                            <tr style="background:Gray">
                                <td style="height:20"> - </td>
                                <td></td>               
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>
                        </xsl:for-each>
                    </table>
                </p>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>


日期 总测试 通过 失败 -

试试这个样式表:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:TESA="tesa.philips.com">
    <xsl:template match="/">
        <html>
            <head>
                <meta http-equiv="refresh" content="30" />
            </head>
            <body>
                <hr/>
                <p>
                    <table border="5"  cellpadding="3" cellspacing="0" width="1200">
                        <tr>
                            <th style="font-weight:bold;background:#a6caf0;width:350px;height:80">Date</th>
                            <th style="font-weight:bold;background:#a6caf0;width:350px">Total Tests</th>
                            <th style="font-weight:bold;background:#a6caf0;width:350px">Passed</th>
                            <th style="font-weight:bold;background:#a6caf0;width:350px">Failure</th>
                        </tr>
                        <xsl:for-each select="Automation/Run">
                            <xsl:for-each select="*">
                                <xsl:sort select="name()" order="descending"/>
                                <tr>
                                    <td class="cellTextLeft">
                                        <xsl:value-of select="current()/descendant::Date"/>
                                    </td>
                                    <td class="cellTextLeft">
                                        <xsl:value-of select="current()/descendant::TotalTests"/>
                                    </td>
                                    <td class="cellTextLeft">
                                        <xsl:value-of select="current()/descendant::Success"/>
                                    </td>
                                    <td class="cellTextLeft">
                                        <xsl:value-of select="current()/descendant::Failures"/>
                                    </td>
                                </tr>
                            </xsl:for-each>
                            <tr style="background:Gray">
                                <td style="height:20"> - </td>
                                <td></td>               
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>
                        </xsl:for-each>
                    </table>
                </p>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>


日期 总测试 通过 失败 -


我们是否可以修改此选项以仅显示XML中的最后10个条目(最新条目)?使用XSL是否可以实现这一点?请提出一个新问题,明确说明您是想要输入的最后10个条目,还是相反的顺序,还是基于输入中的某个日期值。我们是否可以修改此选项,以便在XML中仅显示最后10个条目(最新条目)?使用XSL是否可以实现这一点?请提出一个新问题,清楚地说明您是想要输入的最后10个条目,还是相反的顺序,还是基于输入中的某个日期值。