[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

Subject: Re: How to define a xsl to display such a xml document...
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 6 Mar 2002 10:14:22 +0000
how to define xsl xml
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.