Note that there are some explanatory texts on larger screens.

plurals
  1. POXSL If Function
    primarykey
    data
    text
    <p>I have the following XML document, and XSL stylesheet, and I've been tasked to apply the piece of CSS found in the XSL, to the stylesheet, and apply it when the result of the test is FAIL. I can't seem to work out how to do it, I've tried an xsl:if but couldn't seem to get it to change. Any ideas?</p> <p>Here's the code:</p> <p>XML File:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;?xml-stylesheet type="text/xsl" href="results.xsl"?&gt; &lt;request xmlns:xsi="httyp://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="results.xsd"&gt; &lt;authentication password="turkey" partnerid="exam" /&gt; &lt;method name="ListUserTestResults"&gt; &lt;parameters&gt; &lt;user_id&gt;42511&lt;/user_id&gt; &lt;transcript&gt;4234232&lt;/transcript&gt; &lt;test_id&gt;231&lt;/test_id&gt; &lt;test_name&gt;ASP 3.0 Test&lt;/test_name&gt; &lt;percentage&gt;75&lt;/percentage&gt; &lt;test_result&gt;PASS&lt;/test_result&gt; &lt;time&gt;2006-04-19T14:05:11Z&lt;/time&gt; &lt;/parameters&gt; &lt;parameters&gt; &lt;user_id&gt;42511&lt;/user_id&gt; &lt;transcript&gt;2356545&lt;/transcript&gt; &lt;test_id&gt;12&lt;/test_id&gt; &lt;test_name&gt;PHP 5.0 Test&lt;/test_name&gt; &lt;percentage&gt;35&lt;/percentage&gt; &lt;test_result&gt;FAIL&lt;/test_result&gt; &lt;time&gt;2006-05-17T10:19:45Z&lt;/time&gt; &lt;/parameters&gt; &lt;/method&gt; &lt;/request&gt; </code></pre> <p>And the XSL Stylesheet:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="html" version="4.0.1"/&gt; &lt;xsl:template match="/"&gt; &lt;style type="text/css"&gt; .FAIL {color:red;} &lt;/style&gt; &lt;h1&gt;Results from tests:&lt;/h1&gt; &lt;xsl:for-each select="request/method/parameters"&gt; &lt;h2&gt; &lt;xsl:number count="parameters" /&gt; User &lt;xsl:value-of select="user_id"/&gt; &lt;/h2&gt; &lt;h3&gt; &lt;xsl:value-of select="test_name"/&gt; (&lt;xsl:value-of select="test_id"/&gt;) &lt;/h3&gt; &lt;dl&gt; &lt;dt&gt;Transcript&lt;/dt&gt; &lt;dd&gt;&lt;xsl:value-of select="transcript"/&gt;&lt;/dd&gt; &lt;dt&gt;Percentage&lt;/dt&gt; &lt;dd&gt;&lt;xsl:value-of select="percentage"/&gt; &lt;xsl:if (&lt;xsl:value-of select="test_result"/&gt;) &lt;/dd&gt; &lt;dt&gt;Date/Time of test&lt;/dt&gt; &lt;dd&gt;&lt;xsl:value-of select="time"/&gt;&lt;/dd&gt; &lt;/dl&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>The test_result element needs to be changed from black text, to the CSS defined red, when read in the browser. I just can't work out how to do it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload