Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT Aggregating Elements

Status
Not open for further replies.

C177LVR

Programmer
Joined
Mar 7, 2003
Messages
1
Location
US
What is the technique of using XSLT to transform the input to the output below? Although I have use XSLT for a short while, the new issue for me is aggregating common elements in the input (in this case airplane makes).

Input:

<Airport>
<Airplane Make=&quot;Cessna&quot; Tail=&quot;N11111&quot;/>
<Airplane Make=&quot;Cessna&quot; Tail=&quot;N22222&quot;/>
<Airplane Make=&quot;Piper&quot; Tail=&quot;N33333&quot;/>
<Airplane Make=&quot;Piper&quot; Tail=&quot;N44444&quot;/>
</Airport>

Output:

<Airport>
<Airplane Make=&quot;Cessna&quot;>
<Tail Number=&quot;N11111&quot;/>
<Tail Number=&quot;N22222&quot;/>
</Airplane>
<Airplane Make=&quot;Piper&quot;>
<Tail Number=&quot;N33333&quot;/>
<Tail Number=&quot;N44444&quot;/>
</Airplane>
</Airport>
 
Code:
<Airplane Make=&quot;Cessna&quot;>
<xsl:for-each select=&quot;//Airplane[@Make = 'Cessna']&quot;>
<xsl:element name=&quot;Tail&quot;>
  <xsl:attribute name=&quot;Number&quot;><xsl:value-of select=&quot;@Tail&quot;/></xsl:attribute>
</xsl:element>
</xsl:for-each>
</Airplane Make=&quot;Cessna&quot;>

hope that helps, it's not tested so probably a few errors exist

1010100 1000111 1001001 1000110 [cheers]
-pete

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top