Connecting Tech Pros Worldwide Help | Site Map

XSLT strips bullet tag

 
LinkBack Thread Tools Search this Thread
  #1  
Old January 8th, 2009, 06:46 PM
Newbie
 
Join Date: Jan 2009
Posts: 3
Default XSLT strips bullet tag

I have the following XML:
Expand|Select|Wrap|Line Numbers
  1. <eventsTable>
  2. <eventRec> <dateTime>06/01/2009 21:36:43</dateTime> <rawDateTime>1231277803</rawDateTime> <type>Event</type> <source>GSC</source> <eventId>GSC_USER_CONFIG</eventId> <assAlrm>--</assAlrm> <username>walt</username> <desc>GSC Users<bullet>User Configuration Change</bullet> <bullet> SUBMITTED: walt logged in from IP address 172.16.207.22</bullet> </desc> </eventRec>
  3. <eventRec> <dateTime>05/01/2009 21:36:43</dateTime> <rawDateTime>1231277803</rawDateTime> <type>Event</type> <source>GSC</source> <eventId>GSC_CONFIG</eventId> <assAlrm>--</assAlrm> <username>walt</username> <desc>System switched to sleep mode</desc> </eventRec>
  4. <eventsTable>
I've developed the following XSL but it seems to strip out the bullets. So I get a displayed desc field like "GSC UsersUser Configuration Change SUBMITTED: walt logged in from IP address 172.16.207.20 " How would I edit my code to include the bullets or even just linebreaks? To get something like:

GSC Users
  • User Configuration Change
  • SUBMITTED: walt logged in from IP address 172.16.207.20

XSL:
Expand|Select|Wrap|Line Numbers
  1. <xsl:output method="html"/>
  2.  
  3. <xsl:template match="/">
  4.   <html>
  5. <body>
  6.   <table id="eventsTable" title="Events Log"><thead>
  7.       <tr>
  8.         <th align="center">TimeStamp</th>
  9.         <th align="center">Type</th>
  10.         <th align="center">Source</th>
  11.         <th align="center">ID</th>
  12.         <th align="center">Associated Alarm</th>
  13.         <th align="center">Username</th>
  14.         <th align="center">Description</th>
  15.       </tr></thead><tbody>
  16.       <xsl:for-each select="eventsTable/eventRec">
  17.         <xsl:sort select="position()" data-type="number" order="descending"/>
  18.         <xsl:if test="position() mod 2 = 1">
  19.           <tr class="even">
  20.             <td align="center"><xsl:value-of select="dateTime"/></td>
  21.             <td><xsl:value-of select="type"/></td>
  22.             <td><xsl:value-of select="source"/></td>
  23.             <td><xsl:value-of select="eventId"/></td>
  24.             <td align="center"><xsl:value-of select="assAlrm"/></td>
  25.             <td align="center"><xsl:value-of select="username"/></td>
  26.             <td><xsl:value-of select="desc"/></td>
  27.  
  28.           </tr>
  29.         </xsl:if>
  30.         <xsl:if test="position() mod 2 = 0">
  31.           <tr class="odd">
  32.             <td align="center"><xsl:value-of select="dateTime"/></td>
  33.             <td><xsl:value-of select="type"/></td>
  34.             <td><xsl:value-of select="source"/></td>
  35.             <td><xsl:value-of select="eventId"/></td>
  36.             <td align="center"><xsl:value-of select="assAlrm"/></td>
  37.             <td align="center"><xsl:value-of select="username"/></td>
  38.             <td><xsl:value-of select="desc"/></td>
  39.           </tr>  
  40.         </xsl:if>
  41.  
  42.       </xsl:for-each>
  43.     </tbody></table>
  44.   </body></html>
  45. </xsl:template>
  46.  
  47. </xsl:stylesheet>
Reply
  #2  
Old January 8th, 2009, 06:54 PM
Moderator
 
Join Date: Mar 2006
Posts: 1,096
Default

This is a little hard because we need to know: Do all bullet nodes start a list? Are there multiple lists in a single description? (hard to deal with). This code uses linebreaks instead.
Expand|Select|Wrap|Line Numbers
  1. <td><xsl:apply-templates select="desc/node()"/></td> 
  2.  
  3. <xsl:template match="bullet">
  4. <br/>- <xsl:value-of select="."/>
  5. <xsl:if test="not (generate-id(following::node()) = generate-id(following::*)) or position() = last()"> 
  6. <br/>
  7. </xsl:if>
  8. </xsl:template>
  9.  
Reply
  #3  
Old January 8th, 2009, 06:58 PM
Newbie
 
Join Date: Jan 2009
Posts: 3
Default

Quote:
Originally Posted by jkmyoung View Post
Expand|Select|Wrap|Line Numbers
  1. <td><xsl:copy-of select="desc/node()"/></td>
  2.  
Thanks for the quick reply.
Unfortunately when I make that change, it still doesn't display the bullets. But when I play with the xml a little bit and change the <bullet> tags to <li> tags it does display those. That may be the best solution if I don't receive any more suggestions about the bullet tags.
Reply
  #4  
Old January 8th, 2009, 07:01 PM
Moderator
 
Join Date: Mar 2006
Posts: 1,096
Default

Sorry, edited my reply because I realized <bullet> wasn't a html node.
Reply
  #5  
Old January 8th, 2009, 07:07 PM
Newbie
 
Join Date: Jan 2009
Posts: 3
Default

Heh, yea I was doing the same thing.

The latest code seems to work great. Thanks for the help!
Reply
Reply

Bookmarks

Tags
bullet, html, xsl, xslt

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.