472,110 Members | 2,152 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,110 software developers and data experts.

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>
Jan 8 '09 #1
4 6186
jkmyoung
2,057 Expert 2GB
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.  
Jan 8 '09 #2
@jkmyoung
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.
Jan 8 '09 #3
jkmyoung
2,057 Expert 2GB
Sorry, edited my reply because I realized <bullet> wasn't a html node.
Jan 8 '09 #4
Heh, yea I was doing the same thing.

The latest code seems to work great. Thanks for the help!
Jan 8 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Nicole Szymanski | last post: by
5 posts views Thread by Derek Fountain | last post: by
3 posts views Thread by Peter Schlenker | last post: by
1 post views Thread by David Bradbury | last post: by
8 posts views Thread by Udo Marx | last post: by
13 posts views Thread by Matt | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.