Results 1 to 2 of 2

Thread: [RESOLVED] Basic XSLT question about parameters

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2007
    Posts
    89

    Resolved [RESOLVED] Basic XSLT question about parameters

    I’m new to XSLT transformation and have had trouble finding an answer to what I think is a very simple problem.

    Here is my xsl:
    Code:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
        <html>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
          <head>
            <title>SyncCheck Report</title>
            <link rel="stylesheet" href="resources/INCAT_Default.css" type="text/css"/>
          </head>
    
          <body background="resources/background.gif">
            <a name="top"/>
    
            <!-- Root table for whole report -->
            <table class="whole" width="640">
              <tr class="pass_section">
                <td>
                  <table width="100%">
                    <tr>
                      <td class="whole" align="left">
                        <a class="sec_link" name="Sync Check" href="#top" title="Go to top">Sync Check</a>
                      </td>
                      <td class="whole" align="right">     
                      </td>
                    </tr>
                  </table>
                  </td>
              </tr>
              
              <!-- Row in root table -->
              <tr>
                <td class="whole">
                  <!-- Table for Comments -->
                  <table class="results" width="100%">
                    <xsl:if test="report/st_sync/sync">
                    <tr>
                      <th>Attribute</th>
                      <th>Result</th>
                      <th>SmarTeam</th>
                      <th>Part</th>
                    </tr>
                    </xsl:if>
                    <xsl:for-each select="report/st_sync/sync">
                      <tr>
                        <!-- Alternate lines different background colour -->
                        <xsl:if test="position() mod 2 = 1">
                          <xsl:attribute name="class">failcolour</xsl:attribute>
                        </xsl:if>
    
                        <td><xsl:value-of select="@name"/>*
                        </td>
                        <td><xsl:value-of select="@result"/>*
                        </td>
                        <td><xsl:value-of select="@st_value"/>*
                        </td>
                        <td><xsl:value-of select="@part_value"/>*
                        </td>
                      </tr>
                    </xsl:for-each>
                  </table>
                  <!-- End of Table  -->
                </td>
              </tr>
              <!-- End of Row in root table -->
            </table>
            <!-- End of Root table for whole report -->
          </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>
    Here’s a sample of the xml that my VB is generating:
    Code:
    <?xml version="1.0" encoding="iso-8859-1"?><?xml-stylesheet type="text/xsl" href="xslt/syncCheck.xsl"?><report>
    <st_sync>
    <sync name="TDM_ID" result="Pass" st_value="x" part_value="x" />
    <sync name="CN_PART_NUMBER" result="FAIL" st_value="x" part_value="y" />
    <sync name="REVISION" result="Pass" st_value="-" part_value="-" />
    <sync name="TDM_DESCRIPTION" result="FAIL" st_value="x" part_value="y" />
    </st_sync>
    </report>

    The problem is the class="pass_section" in the xsl. I need to set that value dynamically in the VB code (meaning put a run-time value in the xml to set it).

    How do I do that?

    Thanks

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Dec 2007
    Posts
    89

    Re: [RESOLVED] Basic XSLT question about parameters

    Figured it out.

    in the xsl:
    Code:
              <xsl:if test="report[@status='Pass']">
              <tr class="pass_section">
                <td>
                  <table width="100%">
                    <tr>
                      <td class="whole" align="left">
                        <a class="sec_link" name="Sync Check" href="#top" title="Go to top">Sync Check</a>
                      </td>
                      <td class="whole" align="right">     
                      </td>
                    </tr>
                  </table>
                  </td>
              </tr>
              </xsl:if>
              <xsl:if test="report[@status='Fail']">
                <tr class="fail_section">
                  <td>
                    <table width="100%">
                      <tr>
                        <td class="whole" align="left">
                          <a class="sec_link" name="Sync Check" href="#top" title="Go to top">Sync Check</a>
                        </td>
                        <td class="whole" align="right">
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
              </xsl:if>
    in the vb:
    Code:
    If errorCount = 0 Then
                    xmlString &= "<report status=""Pass"">" & vbNewLine
                Else
                    xmlString &= "<report status=""Fail"">" & vbNewLine
                End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width