我有两个XML文件,每60秒更新一次。我需要从废yds中提取DI-2中的FormattedValue,从总yds中提取DI-2中的FormattedValue。然后,我需要把价值除以废铁,再除以总yds的价值。例如,用户1有48.3码的废料和1454.1码的总和。因此,48.3 / 1454.1 = 0.033,即3.3%。我需要为13个用户中的每一个做这件事。
然后,我需要在网页上显示每个用户/机器的百分比。我非常了解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>发布于 2017-02-09 23:09:09
如果从2个XML文件读取,那么实际上:
基本思想是XSL文件:
Group部分(在第一个XML文件中),Row部分中的Total标记,User Name和Total value,Scrap value,为了进行测试,我对您的文件做了以下更改:
Stylesheet标记。xmlns=".../export-basic"命名空间。<?xml-stylesheet type="text/xsl" href="Report_1.xsl"?>,就在Report标记之前(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>所有三个文件: Report_1.xml (总数据)、Report_2.xml (报废数据)和Report_1.xsl (上述转换)都应该位于同一个目录中。在浏览器中打开第一个XML文件。
我用Firefox测试了它们。
https://stackoverflow.com/questions/42114551
复制相似问题