[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to define a xsl to display such a xml document
Hi Sjoy, > Here, Group controls several Keyword, and the Members are > corresponded to Keywords attribute id. > > I want to display all members of one group into one td of table. How > can I do that? First, I'd set up a key so that it's easy to retrieve the Keyword with a particular id, from its id: <xsl:key name="keywords" match="Keyword" use="@id" /> With that key defined, you can do: key('keywords', 1) to get all the Keyword elements in the document whose id attribute has the value '1'. Then, for each Group: <xsl:for-each select="content/Groups/Group"> ... </xsl:for-each> You want to create a td: <xsl:for-each select="content/Groups/Group"> <td> ... </td> </xsl:for-each> In which you go through the Member elements one by one: <xsl:for-each select="content/Groups/Group"> <td> <xsl:for-each select="Member"> ... </xsl:for-each> </td> </xsl:for-each> And get the value of the Keyword whose id is equal to the value of the current Member: <xsl:for-each select="content/Groups/Group"> <td> <xsl:for-each select="Member"> <xsl:value-of select="key('keywords', .)" /> </xsl:for-each> </td> </xsl:for-each> You might want to put some extra HTML in there, but I hope that shows the basic method. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|