我有两个每60秒更新一次的XML文件。我需要从废料yds中提取DI-2中的FormattedValue和从总yds中提取DI-2中的FormattedValue。然后我需要将scrap yds中的值除以total 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>
这是scrap 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 :(得分:0)
如果您从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>
所有3个文件: Report_1.xml (总数据), Report_2.xml (废品数据), 和 Report_1.xsl (上述转换)应该在同一目录中。 在浏览器中打开第一个XML文件。
我使用Firefox测试了它们。