對於xslt轉換而言,我需要重新組合所有包含相同用戶名的節點,並重新組合與此用戶對應的技能,這裏是一個簡單示例。 輸入:按屬性值對XML節點進行分組
<Rowsets>
<Rowset>
<Columns>
<Column Description="" MaxRange="1" MinRange="0" Name="login" SQLDataType="1" SourceColumn="User_login"/>
<Column Description="" MaxRange="1" MinRange="0" Name="longName" SQLDataType="1" SourceColumn="User_longName"/>
<Column Description="" MaxRange="1" MinRange="0" Name="Competency" SQLDataType="1" SourceColumn="Competency"/>
</Columns>
<Row>
<login>NG5E054</login>
<longName>---</longName>
<Competency>SKILL1</Competency>
</Row>
<Row>
<login>NG5E059</login>
<longName>---</longName>
<Competency>SKILL1</Competency>
</Row>
<Row>
<login>NG5E059</login>
<longName>---</longName>
<Competency>SKILL2</Competency>
</Row>
<Row>
<login>NG5E059</login>
<longName>---</longName>
<Competency>SKILL3</Competency>
</Row>
</Rowset>
</Rowsets>
而我所需的輸出是:
<Rowsets>
<Rowset>
<Columns>
<Column Description="" MaxRange="1" MinRange="0" Name="login" SQLDataType="1" SourceColumn="User_login"/>
<Column Description="" MaxRange="1" MinRange="0" Name="longName" SQLDataType="1" SourceColumn="User_longName"/>
<Column Description="" MaxRange="1" MinRange="0" Name="Competency" SQLDataType="1" SourceColumn="Competency"/>
</Columns>
<Row>
<login>NG5E054</login>
<longName>---</longName>
<Competency>SKILL1</Competency>
</Row>
<Row>
<login>NG5E059</login>
<longName>---</longName>
<Competency>SKILL1, SKILL2, SKILL3</Competency>
</Row>
</Rowset>
</Rowsets>
謝謝
搜索XSLT分組 - 這是這裏最常提到的XSLT問題。請注意,對於XSLT 1.0或2.0,答案是不同的。 –