如何在 XSLT 中遍历以下兄弟姐妹
How to iterate through following sibling in XSLT
我有一个 XML 看起来像
<?xml version="1.0" encoding="UTF-8"?><Rowsets >
<Rowset>
<Row>
<plant>1000</plant>
<workCenterId>10001</workCenterId>
<workCenter>WC1</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>false</alertStatus>
<incidentStatus>false</incidentStatus>
<dashboardStatus>true</dashboardStatus>
</Row>
<Row>
<plant>1000</plant>
<workCenterId>10001</workCenterId>
<workCenter>WC1</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>true</alertStatus>
<incidentStatus>false</incidentStatus>
<dashboardStatus>false</dashboardStatus>
</Row>
<Row>
<plant>1000</plant>
<workCenterId>10001</workCenterId>
<workCenter>WC1</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>false</alertStatus>
<incidentStatus>true</incidentStatus>
<dashboardStatus>false</dashboardStatus>
</Row>
<Row>
<plant>1000</plant>
<workCenterId>10002</workCenterId>
<workCenter>WC2</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>false</alertStatus>
<incidentStatus>false</incidentStatus>
<dashboardStatus>true</dashboardStatus>
</Row>
<Row>
<plant>1000</plant>
<workCenterId>10002</workCenterId>
<workCenter>WC2</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>true</alertStatus>
<incidentStatus>false</incidentStatus>
<dashboardStatus>false</dashboardStatus>
</Row>
<Row>
<plant>1000</plant>
<workCenterId>10003</workCenterId>
<workCenter>WC3</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>false</alertStatus>
<incidentStatus>false</incidentStatus>
<dashboardStatus>false</dashboardStatus>
</Row>
<Row>
<plant>1000</plant>
<workCenterId>10004</workCenterId>
<workCenter>WC4</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>false</alertStatus>
<incidentStatus>false</incidentStatus>
<dashboardStatus>false</dashboardStatus>
</Row>
<Row>
<plant>1000</plant>
<workCenterId>10005</workCenterId>
<workCenter>WC4</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>false</alertStatus>
<incidentStatus>false</incidentStatus>
<dashboardStatus>false</dashboardStatus>
</Row>
</Rowset>
我想做的是遍历每个 Workcenter 并提取文本值“true”,无论它在哪里 true.in 如果 workCenter 相同,下一次迭代再次提取文本“true”,依此类推。
我是 XSLT 的新手,对兄弟节点一无所知。有人可以帮忙吗?
所有迭代后的预期输出`
<?xml version="1.0" encoding="UTF-8"?>
<root>
<WC>
<workCenter>WC1</workCenter>>
<alerts>alerts:true</alerts>
<dashboard>dashboard:true</dashboard>
<incident>incident:true</incident>
</WC>
<WC>
<workCenter>WC2</workCenter>>
<alerts>alerts:true</alerts>
<dashboard>dashboard:true</dashboard>
<incident>incident:false</incident>
</WC>
<WC>
<workCenter>WC3</workCenter>>
<alerts>alerts:false</alerts>
<dashboard>dashboard:false</dashboard>
<incident>incident:false</incident>
</WC>
<WC>
<workCenter>WC4</workCenter>>
<alerts>alerts:false</alerts>
<dashboard>dashboard:false</dashboard>
<incident>incident:false</incident>
</WC>
</root>
这在后端处理 SQL DB
我有一个 XML 看起来像
<?xml version="1.0" encoding="UTF-8"?><Rowsets >
<Rowset>
<Row>
<plant>1000</plant>
<workCenterId>10001</workCenterId>
<workCenter>WC1</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>false</alertStatus>
<incidentStatus>false</incidentStatus>
<dashboardStatus>true</dashboardStatus>
</Row>
<Row>
<plant>1000</plant>
<workCenterId>10001</workCenterId>
<workCenter>WC1</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>true</alertStatus>
<incidentStatus>false</incidentStatus>
<dashboardStatus>false</dashboardStatus>
</Row>
<Row>
<plant>1000</plant>
<workCenterId>10001</workCenterId>
<workCenter>WC1</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>false</alertStatus>
<incidentStatus>true</incidentStatus>
<dashboardStatus>false</dashboardStatus>
</Row>
<Row>
<plant>1000</plant>
<workCenterId>10002</workCenterId>
<workCenter>WC2</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>false</alertStatus>
<incidentStatus>false</incidentStatus>
<dashboardStatus>true</dashboardStatus>
</Row>
<Row>
<plant>1000</plant>
<workCenterId>10002</workCenterId>
<workCenter>WC2</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>true</alertStatus>
<incidentStatus>false</incidentStatus>
<dashboardStatus>false</dashboardStatus>
</Row>
<Row>
<plant>1000</plant>
<workCenterId>10003</workCenterId>
<workCenter>WC3</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>false</alertStatus>
<incidentStatus>false</incidentStatus>
<dashboardStatus>false</dashboardStatus>
</Row>
<Row>
<plant>1000</plant>
<workCenterId>10004</workCenterId>
<workCenter>WC4</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>false</alertStatus>
<incidentStatus>false</incidentStatus>
<dashboardStatus>false</dashboardStatus>
</Row>
<Row>
<plant>1000</plant>
<workCenterId>10005</workCenterId>
<workCenter>WC4</workCenter>
<alerts>alerts</alerts>
<incident>incident</incident>
<dashboard>dashboard</dashboard>
<alertStatus>false</alertStatus>
<incidentStatus>false</incidentStatus>
<dashboardStatus>false</dashboardStatus>
</Row>
</Rowset>
我想做的是遍历每个 Workcenter 并提取文本值“true”,无论它在哪里 true.in 如果 workCenter 相同,下一次迭代再次提取文本“true”,依此类推。
我是 XSLT 的新手,对兄弟节点一无所知。有人可以帮忙吗?
所有迭代后的预期输出`
<?xml version="1.0" encoding="UTF-8"?>
<root>
<WC>
<workCenter>WC1</workCenter>>
<alerts>alerts:true</alerts>
<dashboard>dashboard:true</dashboard>
<incident>incident:true</incident>
</WC>
<WC>
<workCenter>WC2</workCenter>>
<alerts>alerts:true</alerts>
<dashboard>dashboard:true</dashboard>
<incident>incident:false</incident>
</WC>
<WC>
<workCenter>WC3</workCenter>>
<alerts>alerts:false</alerts>
<dashboard>dashboard:false</dashboard>
<incident>incident:false</incident>
</WC>
<WC>
<workCenter>WC4</workCenter>>
<alerts>alerts:false</alerts>
<dashboard>dashboard:false</dashboard>
<incident>incident:false</incident>
</WC>
</root>
这在后端处理 SQL DB