?
Solved

Real Easy One! - XSL define table <tr> tag id based on XML

Posted on 2003-02-28
4
Medium Priority
?
162 Views
Last Modified: 2013-11-19
I have a XML doc with following example data:
<DIRECTOR id='D11'>
   <NAME>BILL GATES</NAME>
   <LEVEL>D11</LEVEL>
</DIRECTOR>
...

Note that the id value and LEVEL are the same.  I did this to help you help me.  I don't care which one you use for the question below.

I want to use the value D11 as the id in a table row:
<table>
    <xsl:for-each select='DIRECTOR'>
    <tr id='D11'>
       <td>
          <xsl:value-of select='NAME'/>
       </td>
    </tr>
    </xsl:for-each>
</table>

Obviously, I don't want to hard code D11.  Is there a function (xml, javascript, whatever) that will extract the value from either the DIRECTOR id or LEVEL values?

The following DOESN'T work but may give you an idea of where I'm going with this:
    <tr id='{DIRECTOR.id}'>
  *OR*
    <tr id='{LEVEL}'>

Thanks in advance!!!
0
Comment
Question by:tab13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 8042810
node
----
<table>
   <xsl:for-each select='DIRECTOR'>
   <tr id='<xsl:value-of select="level"/>'>
      <td>
         <xsl:value-of select='NAME'/>
      </td>
   </tr>
   </xsl:for-each>
</table>


attribute:
----------
<table>
   <xsl:for-each select='DIRECTOR'>
   <tr id='<xsl:value-of select="@level"/>'>
      <td>
         <xsl:value-of select='NAME'/>
      </td>
   </tr>
   </xsl:for-each>
</table>

0
 
LVL 28

Accepted Solution

by:
sybe earned 80 total points
ID: 8042823
or:
===
<table>
  <xsl:for-each select='DIRECTOR'>
  <tr>
     <xsl:attribute name="id><xsl:value-of select="level"/></xsl:attribute>
     <td>
        <xsl:value-of select='NAME'/>
     </td>
  </tr>
  </xsl:for-each>
</table>


0
 

Expert Comment

by:zzo38
ID: 8044388
<table>
 <xsl:for-each select='DIRECTOR'>
 <tr>
    <xsl:attribute name="id"><xsl:value-of select="LEVEL"/></xsl:attribute>
    <td><xsl:value-of select="LEVEL"/></td>
    <td>
       <xsl:value-of select='NAME'/>
    </td>
 </tr>
 </xsl:for-each>
</table>
0
 

Author Comment

by:tab13
ID: 8051833
This is what I needed!  The word 'level' should have been capitalized, but I was swift enough to catch it.  Thanks very much.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question