Suppose that you have an XML file that you wish to examine in detail. You can load that into a browser, and even collapse and expand nodes at will. Here is an XSLT stylesheet that can be used to do something similar, but with custom highlighting.
As an example, suppose that you have an HTML file <example_page.html>. Add the stylesheet processing instruction line
<?xml-stylesheet type="text/xsl" href="xml_enh_ind.xsl" ?>
and optionally rename the file to example_page.html.xml>:
<?xml version="1.0" ?> <?xml-stylesheet type="text/xsl" href="xml_enh_ind.xsl" ?>
<html> <head> <title>Example Page</title> </head> <body> <h1>Example Page</h1> <p> <span>before empty element</span> <span></span> <span>after empty element</span> </p> <table style="border-collapse:collapse;" border="1"><tbody> <tr> <dt>a</dt> <dt>b</dt> </tr><tr> <dt>c</dt> <dt>d</dt> </tr> </tbody></table> </body> </html>
When viewed with the XSLT stylesheet and the associated format file set up to highlight certain table elements, the result looks like this:
Here, I’ve attached some files. As WordPress.com does not allow plain text files to be added, I’ve added them as <*.doc> files containing plain text. To used them, download them and then remove the <.doc> extension.
The main XSLT stylesheet file:
(save this as xml_enh_ind.xsl)
Note that this contains a reference to the format file, which should be edited as required:
<xsl:param name="formatfile" select="'xml_ehn_format_html.xml'"/>
Then, here is an example format file:
(save this as xml_ehn_format_html.xml)