Re: [xsl] XSLT Generated Text

Subject: Re: [xsl] XSLT Generated Text
From: Anton Triest <anton@xxxxxxxx>
Date: Thu, 18 Nov 2004 18:45:18 +0100
Hi Derek,

you wrote:

I am unable to get XSL stylesheets to display properly using Firefox v1 or IE
v6. I know the XSL transformation is happening because I can see the table
headers. However, the XSLT Generated Text is not being created (value-of
select="...). Hence, no table data. Can anyone tell me what I am doing wrong? I
am using Python and minidom to create the XML document. Thanks everyone. Derek.

XML:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE mamu_results SYSTEM
"http://172.20.0.70:81/mamu/mhc_mamu_results.dtd";>
<?xml-stylesheet type="text/xsl"
href="http://172.20.0.70:81/mamu/mhc_mamu_results.xsl";?>
<mamu_results>
<prediction_description xmlns='http://www.mhc-pathway.net/mamu/'>Predicting
to Mamu-A01 in sequence</prediction_description>
<prediction xmlns='http://www.mhc-pathway.net/mamu/'>
<start>3</start>
<end>10</end>
<sequence>AAATTAAA</sequence>
<mhc_affinity>5.0</mhc_affinity>
<combined_prediction>3.53</combined_prediction>
</prediction>
</mamu_results>


The root element is in no namespace, but its children are in a namespace so you'll need to add that info to the XSL... in the stylesheet element:

<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   xmlns:mamu="http://www.mhc-pathway.net/mamu/";
   exclude-result-prefixes="mamu">

...and then in the select expressions:

   <xsl:for-each select="mamu_results/mamu:prediction">
       <tr>
           <td><xsl:value-of select="mamu:start"/></td>
           <td><xsl:value-of select="mamu:end"/></td>
           <td><xsl:value-of select="mamu:sequence"/></td>
       </tr>
   </xsl:for-each>

Cheers,
Anton

XSL:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
 <html>
 <body>
   <h2>Prediction Results</h2>
   <table border="1">
   <tr bgcolor="#9acd32">
     <th align="left">Start</th>
     <th align="left">End</th>
     <th align="left">Sequence</th>
   </tr>
   <xsl:for-each select="mamu_results/prediction">
   <tr>
     <td><xsl:value-of select="start"/></td>
     <td><xsl:value-of select="end"/></td>
     <td><xsl:value-of select="sequence"/></td>
   </tr>
   </xsl:for-each>
   </table>
 </body>
 </html>
</xsl:template>

</xsl:stylesheet>

Current Thread