Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
The following code relates to the earlier post and shows the processing of a concatenated XML file using an XSLT. This has been tested using a Xalan on the command line but this is available as XML::Xalan.

Example of concatenated XML reports:

<?xml version="1.0"?> <Report> <opt> <Agent_Class>Backup</Agent_Class> <MD>dirA</MD> <Agent_Instance>NetBackup</Agent_Instance> <Date>2003/12/08</Date> <Server>ServerABC</Server> <Instance_Detail>Backup Problems ServerABC:57</Instance_Detail> <Time>08:04:58</Time> <Header>X-CALL</Header> <State>CRITICAL</State> </opt> <opt> <Agent_Class>Backup</Agent_Class> <MD>dirA</MD> <Agent_Instance>NetBackup</Agent_Instance> <Date>2003/12/08</Date> <Server>ServerABC</Server> <Instance_Detail>Backup Problems ServerABC:57</Instance_Detail> <Time>08:04:58</Time> <Header>X-CALL</Header> <State>CRITICAL</State> </opt> <opt> <Agent_Class>Backup</Agent_Class> <MD>dirB</MD> <Agent_Instance>NetBackup</Agent_Instance> <Date>2003/12/08</Date> <Server>ServerABC</Server> <Instance_Detail>Backup Problems ServerABC:57</Instance_Detail> <Time>09:00:58</Time> <Header>X-CALL</Header> <State>Nominal</State> </opt> </Report>
Example of XSLT to do the conversion:

<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" /> <xsl:preserve-space elements="*"/> <!-- Transforms the XML report into an HTML report --> <xsl:template match="/"> <html> <head> <title>Server Status Report</title> </head> <body> <xsl:comment>Generated file</xsl:comment> <h1>Server Status Report</h1> <p/> <table border="1"> <xsl:for-each select="Report/opt"> <xsl:sort select="MD"/> <tr> <td><xsl:value-of select="MD" /></td> <td><xsl:value-of select="Server" />&#160;<xsl:value-of select="Ag +ent_Class" /></td> <td>&#160;</td> </tr> <tr> <td>&#160;</td> <td><xsl:value-of select="Instance_Detail" /></td> <td><xsl:value-of select="Date" />&#160;<xsl:value-of select="Date +" /></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:transform>

In reply to Re: Re: Fast processing of XML files for CGI by inman
in thread Fast processing of XML files for CGI by AcidHawk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-26 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found