2017-02-08 60 views
0

我有兩個每60秒更新一次的XML文件。我需要從yds中提取DI-2中的FormattedValue和DI-2中的FormattedValue。然後,我需要將來自廢品yds的值除以總yds中的值。例如,用戶1有48.3碼的碎片和1454.1碼的總數。所以48.3/1454.1 = 0.033或3.3%。我需要爲13位用戶中的每一位用戶執行此操作。從兩個XML文件中提取值並進行數學運算

然後我需要顯示在網頁上爲每個用戶/機器的百分比。我非常瞭解HTML和CSS,但我不知道如何處理XML文件。任何幫助將不勝感激。

這是總YDS XML文件的例子

<Report xmlns="http://www.barcovision.com/schemas/sns/export-basic" xmlns:xsi="http://www.w3.org/2000/XMLSchema-instance" xml:space="preserve"> 
    <Stylesheet xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <Section Type="Header"> 
    <Row> 
     <Cell ColumnHead="KI-30"> 
     <Value xsi:type="xsi:string">Inspector Name</Value></Cell> 
    <Cell ColumnHead="KI-26"> 
     <Value xsi:type="xsi:string">Frame</Value></Cell> 
    <Cell ColumnHead="DI-2"> 
     <Value xsi:type="xsi:string">Length (yd)</Value></Cell></Row></Section> 

    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 1  </FormattedValue> 
      <Value xsi:type="string">User 1  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>M007</FormattedValue> 
     <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>1454.1</FormattedValue> 
     <Value xsi:type="double">1454.09998</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 1  </FormattedValue> 
     <Value xsi:type="string">User 1  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>1454.1</FormattedValue> 
     <Value xsi:type="double">1454.09998</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 2  </FormattedValue> 
      <Value xsi:type="string">User 2  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>M007</FormattedValue> 
     <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>709.8</FormattedValue> 
     <Value xsi:type="double">709.8</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 2  </FormattedValue> 
     <Value xsi:type="string">User 2  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>709.8</FormattedValue> 
     <Value xsi:type="double">709.8</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 3  </FormattedValue> 
      <Value xsi:type="string">User 3  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>M007</FormattedValue> 
     <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>612.2</FormattedValue> 
     <Value xsi:type="double"612.2</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 3  </FormattedValue> 
     <Value xsi:type="string">User 3  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>612.2</FormattedValue> 
     <Value xsi:type="double">612.2</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 4  </FormattedValue> 
      <Value xsi:type="string">User 4  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>M007</FormattedValue> 
     <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>2269.3</FormattedValue> 
     <Value xsi:type="double">2269.3</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 4  </FormattedValue> 
     <Value xsi:type="string">User 4  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>2269.3</FormattedValue> 
     <Value xsi:type="double">2269.3</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 5  </FormattedValue> 
      <Value xsi:type="string">User 5  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>M007</FormattedValue> 
     <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>200.0</FormattedValue> 
     <Value xsi:type="double">200.0</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 5  </FormattedValue> 
     <Value xsi:type="string">User 5  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>200.0</FormattedValue> 
     <Value xsi:type="double">200.0</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 6  </FormattedValue> 
      <Value xsi:type="string">User 6  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>M007</FormattedValue> 
     <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>1442.8</FormattedValue> 
     <Value xsi:type="double">1442.8</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 6  </FormattedValue> 
     <Value xsi:type="string">User 6  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>1442.8</FormattedValue> 
     <Value xsi:type="double">1442.8</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 7  </FormattedValue> 
      <Value xsi:type="string">User 7  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>M007</FormattedValue> 
     <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>3007.0</FormattedValue> 
     <Value xsi:type="double">3007.0</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 7  </FormattedValue> 
     <Value xsi:type="string">User 7  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>3007.0</FormattedValue> 
     <Value xsi:type="double">3007.0</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 8  </FormattedValue> 
      <Value xsi:type="string">User 8  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>M007</FormattedValue> 
     <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>1140.8</FormattedValue> 
     <Value xsi:type="double">1140.8</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 8  </FormattedValue> 
     <Value xsi:type="string">User 8  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>1140.8</FormattedValue> 
     <Value xsi:type="double">1140.8</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 9  </FormattedValue> 
      <Value xsi:type="string">User 9  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>M007</FormattedValue> 
     <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>604.3</FormattedValue> 
     <Value xsi:type="double">604.3</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 9  </FormattedValue> 
     <Value xsi:type="string">User 9  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>604.3</FormattedValue> 
     <Value xsi:type="double">604.3</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 10  </FormattedValue> 
      <Value xsi:type="string">User 10  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>M007</FormattedValue> 
     <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>1638.2</FormattedValue> 
     <Value xsi:type="double">1638.2</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 10  </FormattedValue> 
     <Value xsi:type="string">User 10  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>1638.2</FormattedValue> 
     <Value xsi:type="double">1638.2</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 11  </FormattedValue> 
      <Value xsi:type="string">User 11  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>M007</FormattedValue> 
     <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>211.8</FormattedValue> 
     <Value xsi:type="double">211.8</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 11  </FormattedValue> 
     <Value xsi:type="string">User 11  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>211.8</FormattedValue> 
     <Value xsi:type="double">211.8</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 12  </FormattedValue> 
      <Value xsi:type="string">User 12  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>M007</FormattedValue> 
     <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>1787.8</FormattedValue> 
     <Value xsi:type="double">1787.8</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 12  </FormattedValue> 
     <Value xsi:type="string">User 12  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>1787.8</FormattedValue> 
     <Value xsi:type="double">1787.8</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 13  </FormattedValue> 
      <Value xsi:type="string">User 13  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>M007</FormattedValue> 
     <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>709.8</FormattedValue> 
     <Value xsi:type="double">709.8</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 13  </FormattedValue> 
     <Value xsi:type="string">User 13  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"><FormattedValue>709.8</FormattedValue> 
     <Value xsi:type="double">709.8</Value></Cell></Row></Section></Section> 
<Section Type="Total"> 
    <Row> 
    <Cell Column="KI-30"> 
     <FormattedValue>Grand Total: 13  </FormattedValue> 
<Value xsi:type="string">Grand Total: 13  </Value></Cell> 
<Cell Column="KI-26"><FormattedValue/> 
<Value xsi:type="string"/></Cell> 
<Cell Column="DI-2"> 
    <FormattedValue>18265.2</FormattedValue> 
<Value xsi:type="double">18265.19976</Value></Cell></Row></Section></Stylesheet></Report> 

這是廢鋼YDS XML文件

<Report xmlns="http://www.barcovision.com/schemas/sns/export-basic" xmlns:xsi="http://www.w3.org/2000/XMLSchema-instance" xml:space="preserve"> 
    <Stylesheet xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <Section Type="Header"> 
    <Row> 
     <Cell ColumnHead="KI-30"> 
     <Value xsi:type="xsi:string">Inspector Name</Value></Cell> 
     <Cell ColumnHead="KI-26"><Value xsi:type="xsi:string">Frame</Value></Cell> 
    <Cell ColumnHead="DI-2"><Value xsi:type="xsi:string">Length (yd)</Value></Cell></Row></Section> 

    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 1  </FormattedValue> 
    <Value xsi:type="string">User 1  </Value></Cell> 
     <Cell Column="KI-26"> 
      <FormattedValue>M007</FormattedValue> 
      <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"> 
      <FormattedValue>48.3</FormattedValue> 
      <Value xsi:type="double">48.29999</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 1  </FormattedValue> 
     <Value xsi:type="string">User 1  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"> 
     <FormattedValue>48.3</FormattedValue> 
     <Value xsi:type="double">48.29999</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 2  </FormattedValue> 
    <Value xsi:type="string">User 2  </Value></Cell> 
     <Cell Column="KI-26"> 
      <FormattedValue>M007</FormattedValue> 
      <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"> 
      <FormattedValue>25.6</FormattedValue> 
      <Value xsi:type="double">25.6</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 2  </FormattedValue> 
     <Value xsi:type="string">User 2  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"> 
     <FormattedValue>25.6</FormattedValue> 
     <Value xsi:type="double">25.6</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 3  </FormattedValue> 
    <Value xsi:type="string">User 3  </Value></Cell> 
     <Cell Column="KI-26"> 
      <FormattedValue>M007</FormattedValue> 
      <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"> 
      <FormattedValue>27.2</FormattedValue> 
      <Value xsi:type="double">27.2</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 3  </FormattedValue> 
     <Value xsi:type="string">User 3  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"> 
     <FormattedValue>27.2</FormattedValue> 
     <Value xsi:type="double">27.2</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 4  </FormattedValue> 
    <Value xsi:type="string">User 4  </Value></Cell> 
     <Cell Column="KI-26"> 
      <FormattedValue>M007</FormattedValue> 
      <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"> 
      <FormattedValue>3.7</FormattedValue> 
      <Value xsi:type="double">3.7</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 4  </FormattedValue> 
     <Value xsi:type="string">User 4  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"> 
     <FormattedValue>3.7</FormattedValue> 
     <Value xsi:type="double">3.7</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 5  </FormattedValue> 
    <Value xsi:type="string">User 5  </Value></Cell> 
     <Cell Column="KI-26"> 
      <FormattedValue>M007</FormattedValue> 
      <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"> 
      <FormattedValue>56.7</FormattedValue> 
      <Value xsi:type="double">56.7</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 5  </FormattedValue> 
     <Value xsi:type="string">User 5  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"> 
     <FormattedValue>56.7</FormattedValue> 
     <Value xsi:type="double">56.7</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 6  </FormattedValue> 
    <Value xsi:type="string">User 6  </Value></Cell> 
     <Cell Column="KI-26"> 
      <FormattedValue>M007</FormattedValue> 
      <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"> 
      <FormattedValue>33.1</FormattedValue> 
      <Value xsi:type="double">33.1</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 6  </FormattedValue> 
     <Value xsi:type="string">User 6  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"> 
     <FormattedValue>33.1</FormattedValue> 
     <Value xsi:type="double">33.1</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 7  </FormattedValue> 
    <Value xsi:type="string">User 7  </Value></Cell> 
     <Cell Column="KI-26"> 
      <FormattedValue>M007</FormattedValue> 
      <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"> 
      <FormattedValue>161.5</FormattedValue> 
      <Value xsi:type="double">161.5</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 7  </FormattedValue> 
     <Value xsi:type="string">User 7  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"> 
     <FormattedValue>161.5</FormattedValue> 
     <Value xsi:type="double">161.5</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 8  </FormattedValue> 
    <Value xsi:type="string">User 8  </Value></Cell> 
     <Cell Column="KI-26"> 
      <FormattedValue>M007</FormattedValue> 
      <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"> 
      <FormattedValue>62.3</FormattedValue> 
      <Value xsi:type="double">62.3</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 8  </FormattedValue> 
     <Value xsi:type="string">User 8  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"> 
     <FormattedValue>62.3</FormattedValue> 
     <Value xsi:type="double">62.3</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 9  </FormattedValue> 
    <Value xsi:type="string">User 9  </Value></Cell> 
     <Cell Column="KI-26"> 
      <FormattedValue>M007</FormattedValue> 
      <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"> 
      <FormattedValue>23.3</FormattedValue> 
      <Value xsi:type="double">23.3</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 9  </FormattedValue> 
     <Value xsi:type="string">User 9  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"> 
     <FormattedValue>23.3</FormattedValue> 
     <Value xsi:type="double">23.3</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 10  </FormattedValue> 
    <Value xsi:type="string">User 10  </Value></Cell> 
     <Cell Column="KI-26"> 
      <FormattedValue>M007</FormattedValue> 
      <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"> 
      <FormattedValue>73.0</FormattedValue> 
      <Value xsi:type="double">73.0</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 10  </FormattedValue> 
     <Value xsi:type="string">User 10  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"> 
     <FormattedValue>73.0</FormattedValue> 
     <Value xsi:type="double">73.0</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 11  </FormattedValue> 
    <Value xsi:type="string">User 11  </Value></Cell> 
     <Cell Column="KI-26"> 
      <FormattedValue>M007</FormattedValue> 
      <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"> 
      <FormattedValue>5.6</FormattedValue> 
      <Value xsi:type="double">5.6</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 11  </FormattedValue> 
     <Value xsi:type="string">User 11  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"> 
     <FormattedValue>5.6</FormattedValue> 
     <Value xsi:type="double">5.6</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 12  </FormattedValue> 
    <Value xsi:type="string">User 12  </Value></Cell> 
     <Cell Column="KI-26"> 
      <FormattedValue>M007</FormattedValue> 
      <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"> 
      <FormattedValue>11.0</FormattedValue> 
      <Value xsi:type="double">11.0</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 12  </FormattedValue> 
     <Value xsi:type="string">User 12  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"> 
     <FormattedValue>11.0</FormattedValue> 
     <Value xsi:type="double">11.0</Value></Cell></Row></Section></Section> 
    <Section Type="Group"> 
    <Section Type="Details"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>User 13  </FormattedValue> 
    <Value xsi:type="string">User 13  </Value></Cell> 
     <Cell Column="KI-26"> 
      <FormattedValue>M007</FormattedValue> 
      <Value xsi:type="string">M007</Value></Cell> 
     <Cell Column="DI-2"> 
      <FormattedValue>48.3</FormattedValue> 
      <Value xsi:type="double">48.29999</Value></Cell></Row></Section> 

    <Section Type="Total"> 
    <Row> 
     <Cell Column="KI-30"> 
     <FormattedValue>User 13  </FormattedValue> 
     <Value xsi:type="string">User 13  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue>1 </FormattedValue> 
     <Value xsi:type="string">1 </Value></Cell> 
     <Cell Column="DI-2"> 
     <FormattedValue>48.3</FormattedValue> 
     <Value xsi:type="double">48.29999</Value></Cell></Row></Section></Section> 
    <Section Type="Total"> 
     <Row> 
     <Cell Column="KI-30"> 
      <FormattedValue>Grand Total: 12  </FormattedValue> 
      <Value xsi:type="string">Grand Total: 12  </Value></Cell> 
     <Cell Column="KI-26"><FormattedValue/> 
     <Value xsi:type="string"/></Cell> 
     <Cell Column="DI-2"><FormattedValue>531.3</FormattedValue> 
     <Value xsi:type="double">531.29988</Value></Cell></Row></Section></Stylesheet></Report> 

回答

0

如果從2個XML文件,那麼實際上讀的例子:

  • 第一XML文件加載XSL文件(和它處理XML),
  • 此XSL文件加載第二個XML文件並使用它。

的基本思想是,XSL文件:

  • 遍歷Group部分(第一XML文件中),
  • 從目前部分它讀取包含在(嵌入式)Total部分標籤,
  • 從這一行中讀取User NameTotal value,
  • 從第二個文件中讀取Scrap value(查找我們荷蘭國際集團當前用戶名),
  • 計算比率,
  • 生成一個錶行。

對於我的測試目的我做了以下修改您的文件:

  • 我刪除Stylesheet標籤兩個文件。
  • 我刪除了xmlns=".../export-basic"命名空間。 (Report_1.xsl是我的XSL文件, 見下文)。

在這裏,你有XSLT的工作示例:

<?xml version="1.0" encoding="UTF-8" ?> 
<xsl:transform version="2.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes" /> 
    <xsl:strip-space elements="*"/> 
    <xsl:variable name="rep_2" select="document('Report_2.xml')" /> 
    <xsl:variable name="rep2Totals" select= 
    "$rep_2/Report/Section[@Type='Group']/Section[@Type='Total']"/> 

    <xsl:template match="Report"> 
    <table border="1"> 
     <tr> 
     <th style="width: 100px">User Name</th> 
     <th style="width: 60px">Scrap Value</th> 
     <th style="width: 75px">Total Value</th> 
     <th style="width: 75px">Ratio</th> 
     </tr> 
     <xsl:for-each select="Section[@Type='Group']"> 
     <xsl:variable name="totalRow" select="Section[@Type='Total']/Row"/> 
     <xsl:variable name="userName" select= 
      "$totalRow/Cell[@Column='KI-30']/FormattedValue"/> 
     <xsl:variable name="totalVal" select= 
      "$totalRow/Cell[@Column='DI-2']/FormattedValue"/> 
     <xsl:variable name="rep2Row" select= 
      "$rep2Totals/Row/Cell[@Column='KI-30'][FormattedValue=$userName]/.."/> 
     <xsl:variable name="scrapVal" select= 
      "$rep2Row/Cell[@Column='DI-2']/FormattedValue"/> 
     <xsl:variable name="divRes" select= 
      "format-number($scrapVal div $totalVal, '##0.00%')"/> 
     <tr> 
      <td><xsl:value-of select="normalize-space($userName)"/></td> 
      <td class="right"><xsl:value-of select="$scrapVal"/></td> 
      <td class="right"><xsl:value-of select="$totalVal"/></td> 
      <td class="right"><xsl:value-of select="$divRes"/></td> 
     </tr> 
     </xsl:for-each> 
    </table> 
    </xsl:template> 

    <xsl:template match="/"> 
    <hmtl> 
     <head> 
     <title>Report</title> 
     <style> 
     td { padding: 2px 6px; } 
     .right { text-align: right; padding-right: 12px; } 
     </style> 
     </head> 
     <body> 
     <xsl:apply-templates/> 
     </body> 
    </hmtl> 
    </xsl:template> 

    <xsl:template match="text()[not(normalize-space())]"/> 

    <xsl:template match="@*|node()"> 
    <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy> 
    </xsl:template> 
</xsl:transform> 

所有3個文件:Report_1.xml(總數據),Report_2.xml(廢數據), 和Report_1.xsl(上面的轉換)應該在同一個目錄中。 在瀏覽器中打開第一個XML文件。

我使用Firefox測試了它們。

+0

這是完美的Valdi_Bo!這是一個巨大的幫助! –

相關問題