Debugging:Understanding XSL-Generating Code in Perl

From SPCTools

Jump to: navigation, search

XSL is used heavily in the TPP for manipulating xml. Several programs (such as dynamically generate a XSL file on every invocation. The purpose of the XSL file is typically to generate html from xml.

When reading the perl code which generates this XSL code, keep these things in mind:

In perl code, when writing the XSL file, there are two types of variables which may be referenced. One is a standard perl variable, subsituted into the print statement. Another is an XSL variable, for which no subsitution occurs in perl. Take the following line:

print XSL  '<A TARGET="Win1" HREF="' . $CGI_HOME . 'ASAPRatioPeptideCGIDisplayParser.cgi?Xmlfile=' . $xmlfile . 
'&Basename={$basename}&Indx={$xpress_index}&Timestamp={$asap_time}&Spectrum={$xpress_spec}&ratioType=' .
$ratio_type . '">';

While "{$basename}" might look like a perl-subsituted variable, note the single-quotes that contain it. This is a variable defined previously in the XSL file. Searching for this definition, we find

print XSL  '<xsl:template match="pepx:msms_run_summary"> 
<xsl:variable name="basename" select="@base_name"/>

which defines the variable using a XPath statement.

On the other hand, "$xmlfile" is a standard perl variable; it's not surrounded by single quotes.

Personal tools