Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generic XML Style Sheet

Status
Not open for further replies.

HardcoreTechnoHead

Technical User
Sep 19, 2002
17
GB
I have an audit table in a SQL database which keeps the actual audit data for all operations in XML format something like

<TABLENAME>
<NEW>
<COL1>value</COL1>
<COL2>value</COL2>
</NEW>
<OLD>
<COL1>value</COL1>
<COL2>value</COL2>
</OLD>
</TABLENAME>

I need ot be able to report on the audit trail and can very easily get to the data and dynamically build the reports.

As each table has a different layout/column names so the XML output generated is different for each table.

Basically, when the report renders in IE5, the output is very confusing for the users who do not read XML. Therefore it would be easier if I could produce an output in the form

TableName
New
Col1 Value
Col2 Value

Old
Col1 Value
Col2 Value

Any ideas how this can be achieved? It must be possible as Microsoft can do something similar in IE5 (even if it is not pretty IMHO =))
Andie Harper
&quot;If you can keep your head when all around you have lost theirs, you probably haven't understood the seriousness of the situation&quot;
 
i'm not real clear on your problem/goal statement. best as i can tell it seems reasonable. have u used or research XSLT at all yet?

-pete
 
I've been reading around but have not yet got past the barrier that you need to know the elemnt name up form the product the style sheet.

As I have approximatley 50 tables, If I need to know the element name I would have to write 50 style sheets. I sure it must be possible through a single stylesheet, but cannot yet find what I need to know to do it.

I'm relatively new to this topic Andie Harper
&quot;If you can keep your head when all around you have lost theirs, you probably haven't understood the seriousness of the situation&quot;
 
Found my own solution Andie Harper
&quot;If you can keep your head when all around you have lost theirs, you probably haven't understood the seriousness of the situation&quot;
 
<xsl:stylesheet xmlns:xsl=&quot; version=&quot;1.0&quot;>
<xsl:eek:utput method=&quot;html&quot;/>

<!-- Override the built-in template -->
<xsl:template match=&quot;text()&quot;/>

<xsl:template match=&quot;/&quot;>
<html>
<head>
<META HTTP-EQUIV=&quot;Expires&quot; CONTENT=&quot;0&quot;></META>
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;../styles/styles.css&quot; media=&quot;print&quot;></link>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>


<xsl:template match=&quot;//*&quot;>
<xsl:element name=&quot;H1&quot;>
<xsl:value-of select='name()'/>
</xsl:element>
<xsl:apply-templates/>
</xsl:template>

<xsl:template match=&quot;//*/*&quot;>
<table width=&quot;60%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot;>
<tr>
<td colspan=&quot;2&quot; class=&quot;Head&quot;>
<xsl:value-of select='name()'/>
</td>
</tr>
<xsl:apply-templates/>
</table>
</xsl:template>

<xsl:template match=&quot;//*/*/*&quot;>
<tr>
<td width=&quot;25%&quot; class=&quot;Body&quot;><strong><xsl:value-of select='name()'/>:</strong></td>
<td width=&quot;*&quot; class=&quot;Body&quot;><xsl:value-of select='text()'/></td>
</tr>
<xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet> Andie Harper
&quot;If you can keep your head when all around you have lost theirs, you probably haven't understood the seriousness of the situation&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top