|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am really new to xsl and am working a project that I have to use xsl in.
Not new to programming :-) I am creating an offline log viewer. The log is in xml and am using xsl stylesheet to convert to html document. The problem I am having is under log.xml //set/file_open_error I have multiple entries which will change as this is a backup log from veritas. I need to display all file_open_errors (no matter how many) but am only able to get one to show up in my final product. I have included the portion of xml I am trying to format and the xsl I am now using. (sorry can't give out the whole .xml file don't feel like masking all information!) Any help would be very much appreciated! Thanks Chris log.xml Code:
- <set> <set_resource_name>\\xxx\C$</set_resource_name> <tape_name>Family Name: "Media created 1/19/2004 9:00:06 PM"</tape_name> - <volume> <display_volume>Backup of "\\xxx\C$ "</display_volume> </volume> <description>Backup set #8 on storage media #1 Backup set description: "Backup 0031"</description> <backup_type>Backup Type: INCREMENTAL - Changed Files - Reset Archive Bit</backup_type> <start_time>Backup started on 1/20/2004 at 9:02:47 PM.</start_time> <file_open_error>Unable to open the item \\xxx\C$\WINNT\SYSTEM32\Dhcp\dhcp.mdb - skipped.</file_open_error> <file_open_error>Unable to open the item \\xxx\C$\WINNT\SYSTEM32\Dhcp\j50.log - skipped.</file_open_error> <file_open_error>Unable to open the item \\xxx\C$\WINNT\SYSTEM32\Dhcp\tmp.edb - skipped.</file_open_error> <sql_dbcc_group /> <end_time>Backup completed on 1/20/2004 at 9:02:54 PM.</end_time> - <summary> <misc>Backed up 12 files in 16 directories.</misc> <file_skipped_stat>3 items were skipped.</file_skipped_stat> <new_processed_bytes>Processed 7,714,066 bytes in 7 seconds.</new_processed_bytes> <vlm_hist_rateformat2>Throughput rate: 63.1 MB/min</vlm_hist_rateformat2> </summary> <filler>----------------------------------------------------------------------</filler> </set> log.xsl Code:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/"> <html> <title> <xsl:value-of select="//header/server"/> </title> <body> <xsl:value-of select="//header/filler"/> <h2> <p> <xsl:value-of select="//header/server"/> </p> <p> <xsl:value-of select="//header/name"/> </p> <p> <xsl:value-of select="//header/start_time"/> </p> <p> <xsl:value-of select="//header/type"/> </p> <p> <xsl:value-of select="//header/log_name"/> </p> </h2> <p> <xsl:value-of select="//backup/filler"/> </p> <table> <tr> <xsl:for-each select="//machine"> <h2> Server Name<xsl:value-of select="machine_name"/> </h2> <p><xsl:value-of select="set/tape_name"/></p> <p><xsl:value-of select="set/volume/display_volume"/></p> <p><xsl:value-of select="set/description"/></p> <p><xsl:value-of select="set/backup_type"/></p> <p><xsl:value-of select="set/start_time"/></p> <table> <tr> <xsl:for-each select="file_open_error"> <xsl:value-of select="."/> </xsl:for-each> </tr> </table> <p><xsl:value-of select="set/end_time"/></p> <p><xsl:value-of select="set/summary/misc"/></p> <p><xsl:value-of select="set/summary/file_skipped_stat"/></p> <p><xsl:value-of select="set/summary/new_processed_bytes"/></p> <p><xsl:value-of select="set/summary/vlm_hist_rateformat2"/></p> <xsl:value-of select="//backup/filler"/> </xsl:for-each> </tr> </table> <p> <xsl:value-of select="//backup/filler"/> </p> </body> </html> </xsl:template> </xsl:stylesheet> |
|
#2
|
|||
|
|||
|
I simplified your xml file as follows since it was badly formed:
<set> <file_open_error>Unable to open the item \\xxx\C$\WINNT\SYSTEM32\Dhcp\dhcp.mdb - skipped.</file_open_error> <file_open_error>Unable to open the item \\xxx\C$\WINNT\SYSTEM32\Dhcp\j50.log - skipped.</file_open_error> <file_open_error>Unable to open the item \\xxx\C$\WINNT\SYSTEM32\Dhcp\tmp.edb - skipped.</file_open_error> <misc>Backed up 12 files in 16 directories.</misc> </set> and your sample xsl as follows: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/"> <html> <head></head> <body> <h1><xsl:value-of select="//misc"/></h1> <table> <xsl:for-each select="//file_open_error"> <tr><td> <xsl:value-of select="."/> </td></tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> The ouput is as follows: <html> <head> <META http-equiv="Content-Type" content="text/html; charset=UTF-16"> </head> <body> <h1>Backed up 12 files in 16 directories.</h1> <table> <tr><td>Unable to open the item \\xxx\C$\WINNT\SYSTEM32\Dhcp\dhcp.mdb - skipped.</td></tr> <tr><td>Unable to open the item \\xxx\C$\WINNT\SYSTEM32\Dhcp\j50.log - skipped.</td></tr> <tr><td>Unable to open the item \\xxx\C$\WINNT\SYSTEM32\Dhcp\tmp.edb - skipped.</td></tr> </table> </body> </html> As you can see it includes all the file_open_errors as required. Enjoy - F |
|
#3
|
|||
|
|||
|
Thanks
Thanks that worked very well!!!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XSL woes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|