im folgende Beispiel die Anforderung <userSearchRecords>
Elemente zu fusionieren (durch <userAccount/login>
Element identifiziert) durch <otherAttributes>
Kind-Element zu bewegen, wenn nötig, das heißt: wenn 2 <userSearchRecords>
Elemente der XML, verbinden sie durch Bewegen des <otherAttributes>
von dem zweiten <userSearchRecords>
zu dem ersten und Entfernen des zweiten <userSearchRecords>
Elements; Ansonsten lass es so wie es ist.XSLT merge Knoten mit demselben Identifikator Elemente
Beispiel XML-Eingabe:
<SearchReply_OutputVariable>
<part name="parameters">
<searchResponse>
<userSearchRecords>
<userAccount>
<login>A</login>
<otherAttributes>
<name>X</name>
<value>1</value>
</otherAttributes>
</userAccount>
</userSearchRecords>
<userSearchRecords>
<userAccount>
<login>B</login>
<otherAttributes>
<name>X</name>
<value>2</value>
</otherAttributes>
</userAccount>
</userSearchRecords>
<userSearchRecords>
<userAccount>
<login>C</login>
<otherAttributes>
<name>X</name>
<value>1</value>
</otherAttributes>
</userAccount>
</userSearchRecords>
<userSearchRecords>
<userAccount>
<login>D</login>
<otherAttributes>
<name>X</name>
<value>1</value>
</otherAttributes>
</userAccount>
</userSearchRecords>
<userSearchRecords>
<userAccount>
<login>G</login>
<otherAttributes>
<name>Y</name>
<value>5</value>
</otherAttributes>
</userAccount>
</userSearchRecords>
<userSearchRecords>
<userAccount>
<login>C</login>
<otherAttributes>
<name>Y</name>
<value>6</value>
</otherAttributes>
</userAccount>
</userSearchRecords>
<userSearchRecords>
<userAccount>
<login>H</login>
<otherAttributes>
<name>Y</name>
<value>7</value>
</otherAttributes>
</userAccount>
</userSearchRecords>
<userSearchRecords>
<userAccount>
<login>A</login>
<otherAttributes>
<name>Y</name>
<value>7</value>
</otherAttributes>
</userAccount>
</userSearchRecords>
</searchResponse>
</part>
</SearchReply_OutputVariable>
Erwartete XML-Ausgabe:
<SearchReply_OutputVariable>
<part name="parameters">
<searchResponse>
<userSearchRecords>
<userAccount>
<login>A</login>
<otherAttributes>
<name>X</name>
<value>1</value>
</otherAttributes>
<otherAttributes>
<name>Y</name>
<value>7</value>
</otherAttributes>
</userAccount>
</userSearchRecords>
<userSearchRecords>
<userAccount>
<login>B</login>
<otherAttributes>
<name>X</name>
<value>2</value>
</otherAttributes>
</userAccount>
</userSearchRecords>
<userSearchRecords>
<userAccount>
<login>C</login>
<otherAttributes>
<name>X</name>
<value>1</value>
</otherAttributes>
<otherAttributes>
<name>Y</name>
<value>6</value>
</otherAttributes>
</userAccount>
</userSearchRecords>
<userSearchRecords>
<userAccount>
<login>D</login>
<otherAttributes>
<name>X</name>
<value>1</value>
</otherAttributes>
</userAccount>
</userSearchRecords>
<userSearchRecords>
<userAccount>
<login>G</login>
<otherAttributes>
<name>Y</name>
<value>5</value>
</otherAttributes>
</userAccount>
</userSearchRecords>
<userSearchRecords>
<userAccount>
<login>H</login>
<otherAttributes>
<name>Y</name>
<value>7</value>
</otherAttributes>
</userAccount>
</userSearchRecords>
</searchResponse>
</part>
</SearchReply_OutputVariable>
In der XML-Ausgabe gibt es nun 6 <userSearchRecords>
, während in der XML-Eingabe In der XML-Eingabe gibt es 8 waren waren 2 <userSearchRecords>
mit <login>
Wert A, und 2 <userSearchRecords>
mit <login>
Wert C. In der Ausgabe XML wurden diese Elemente zusammengeführt (<otherAttributes>
Kind aus der übereinstimmenden logi verschoben n Paar und <userSearchRecords>
Element aus dem passenden Paar entfernt).
Kann mir jemand in die richtige Richtung zeigen, wie man das löst?
Danke!
Es ist eine Gruppe Problem. Mit XSLT 2.0 können Sie '' verwenden, mit XSLT 1.0 verwenden Sie eine muenchische Gruppierung mit einem Schlüssel ' '. –