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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apply-Templates Select question

Status
Not open for further replies.

Craftor

Programmer
Feb 1, 2001
420
NZ
Hi all

I have an XML document that looks something like:
Code:
<results>
      <group>
         <id>1</id>
         <name>Home Office</name>
      </group>
      <group>
         <id>2</id>
         <name>Mobile Users</name>
      </group>
      <group>
         <id>3</id>
         <name>Contractors</name>
      </group>
      <doc>
         <docid>33301</docid>
         <filename>Doc1.doc</filename>         
         <groupid>3</groupid>
      </doc>
      <doc>
         <docid>33302</docid>
         <filename>Doc2.doc</filename>         
         <groupid>2</groupid>
      </docid>
      <doc>
         <docid>33303</docid>
         <filename>Doc3.doc</filename>         
         <groupid>1</groupid>
      </docid>
</results>

I want to display this as:
Home Office
33303

Mobile Users
33302

...etc.

I've got the following XSLT snippet - I'm just having difficulty putting the concept of &quot;select the document that has a group id matches the group id of the current node&quot; in XSLT.

Code:
<xsl:template match=&quot;group&quot;>
 <table>
  <tr>
   <td>
    <xsl:value-of select=&quot;name&quot;/>
   </td>
  </tr>
 </table>
 <table>
  <tr bgcolor=&quot;#003399&quot;>
   <td>#</td>
   <td>Name</td>
  </tr>
  <xsl:apply-templates select=&quot;../doc[../doc/groupid=id]&quot;/><!-- Problem here -->
 </table>
</xsl:template>

Can anyone help out with this, please? I've commented the line I'm having difficulty with.

Thanks as always

Craftor
:cool:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top