Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nested Group By and Order By in XSL 1

Status
Not open for further replies.

xtremeLogic

Programmer
Dec 19, 2003
53
CA
Hi,

I have an xml file whose basic structure is:
Code:
<Scan>
  <Check ID=&quot;100&quot; Grade=&quot;5&quot; Type=&quot;1&quot; Cat=&quot;1&quot; Rank=&quot;3&quot; 
   Name=&quot;Check1&quot; URL1=&quot;c1.html&quot; URL2=&quot;C2.html&quot;>
     <Advice>Sample summary of problem</Advice>
     <Detail>
	<Head>
	  <Col>Detail 1</Col>
	  <Col>Detail 2</Col>
	</Head>
	<Row Grade=&quot;5&quot;>
  	  <Col>c1d1</Col>
	  <Col>c1d2</Col>
	</Row>
	<Row Grade=&quot;5&quot;>
	  <Col>abc:</Col>
	  <Col>def</Col>
	</Row>
     </Detail>
    </Check>
    .
    .
    .
</Scan>
I have created an XSL file to transform the XML into HTML but since I am new to XSL I am having a lot of trouble grouping the data and ordering it.

Basically I would like to Group the Data by the Check entity attribute: Type (which has possible values of 1-4). So if it is Type=1, I would like to output a specific title at the top of the table like &quot;Title1&quot; similarly for Type=2, &quot;SomeTitle&quot;, and onwards.
Now after grouping by Type, I would like to group by the Check entity attribute: Cat (possible values of 1 or 2). Similarly I would like to output a subTitle for each Category. Finally I would like to order the end results by Grade.

Here is the portion of my XSL that I have got. I tried putting nested <xsl:for-each select=&quot;Check&quot;><xsl:for-each select=&quot;Type&quot;><xsl:for-each select=&quot;Cat&quot;> but I get no output. I would greatly appreciate it if someone could kindly tell me how to get this group by working. I have looked at some online resources like Muenchian grouping and they can be confusing.
Code:
<xsl:for-each select=&quot;Scan&quot;>
<xsl:for-each select=&quot;Check&quot;>
	<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;10&quot; bgcolor=&quot;#A1BDEA&quot;>
		<thead>
			<tr>
				<td width=&quot;50&quot; class=&quot;tableHeaderText&quot;>Score</td>
				<td width=&quot;100&quot; class=&quot;tableHeaderText&quot;>Issue</td>
				<td class=&quot;tableHeaderText&quot;>Results</td>
			</tr>
		</thead>
		<tbody>
			<xsl:sort order=&quot;ascending&quot; select=&quot;@Grade&quot; data-type=&quot;number&quot;/>
			<tr>
				<xsl:choose>
					<xsl:when test=&quot;position() mod 2 = 1&quot;>
						<xsl:attribute name=&quot;class&quot;>rowOdd </xsl:attribute>
					</xsl:when>
					<xsl:otherwise>
						<xsl:attribute name=&quot;class&quot;>rowEven</xsl:attribute>
					</xsl:otherwise>
				</xsl:choose>
				<td align=&quot;center&quot; valign=&quot;top&quot;>
					<xsl:choose>
						<xsl:when test=&quot;@Grade=1&quot;>
							<xsl:for-each select=&quot;@Grade&quot;>
								<img src=&quot;X_Red.gif&quot;/>
							</xsl:for-each>
						</xsl:when>
						<xsl:when test=&quot;(@Grade=5)&quot;>
							<xsl:for-each select=&quot;@Grade&quot;>
								<img src=&quot;Check_Green.gif&quot;/>
							</xsl:for-each>
						</xsl:when>
						<xsl:otherwise/>
					</xsl:choose>
				</td>
				<td valign=&quot;top&quot;>
					<xsl:for-each select=&quot;@Name&quot;>
						<xsl:value-of select=&quot;.&quot;/>
					</xsl:for-each>
				</td>
				<td valign=&quot;top&quot;>
					<xsl:for-each select=&quot;Advice&quot;>
						<xsl:value-of select=&quot;.&quot;/>
					</xsl:for-each>
					<br/>
					<table width=&quot;100%&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>
						<tr>
							<td width=&quot;200&quot;>
								<xsl:for-each select=&quot;@URL1&quot;>
									<a>
										<xsl:attribute name=&quot;class&quot;>linkText</xsl:attribute>
										<xsl:attribute name=&quot;href&quot;><xsl:value-of select=&quot;.&quot;/></xsl:attribute>
										<xsl:attribute name=&quot;target&quot;>_blank</xsl:attribute>
										What was scanned
									</a>
								</xsl:for-each>
							</td>
							<td>
								<xsl:for-each select=&quot;@URL2&quot;>
									<a>
										<xsl:attribute name=&quot;class&quot;>linkText</xsl:attribute>
										<xsl:attribute name=&quot;href&quot;><xsl:value-of select=&quot;.&quot;/></xsl:attribute>
										<xsl:attribute name=&quot;target&quot;>_blank</xsl:attribute>
										How to correct this
									</a>
								</xsl:for-each>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</tbody>
	</table>
</xsl:for-each>
</xsl:for-each>
 
Hi, I couldn't really make sense of is - that is: I couldn't quite figure out what output you wanted.
However, I found a solution for your sorting problem, and I guess you can adapt the xsl easily, to make the output you need.
What I did was: first make nodelists of unique Types and Cats, and loop through them using <xsl:for-each>.
For each combination, make a list of Checks that fit, and call <xsl:apply-templates/> again: in a separate <xsl:template match=&quot;Check&quot;> the <Check> itself is parsed.

Oh, and by the way: you tend to use <xsl:for-each> to loop through attributes, when you don't want to loop at all, because your context is already the node you want to parse.
Have a look at the way I parse <Check>: there's only an <xsl:for-each> if there are more then one nodes for an x-path expression.

<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot; <xsl:eek:utput method=&quot;html&quot; version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; indent=&quot;yes&quot;/>
<xsl:template match=&quot;/&quot;>
<xsl:apply-templates/>
</xsl:template>

<xsl:template match=&quot;Scan&quot;>
<table>
<tr>
<td colspan=&quot;3&quot;>Some header</td>
</tr>

<xsl:variable name=&quot;AllTypes&quot; select = &quot;Check[not(@Type=preceding::Check/@Type)]/@Type&quot;/>
<xsl:variable name=&quot;AllCats&quot; select = &quot;Check[not(@Cat=preceding::Check/@Cat)]/@Cat&quot;/>

<xsl:for-each select=&quot;$AllTypes&quot;>
<xsl:sort order=&quot;ascending&quot; select=&quot;.&quot;/>
<xsl:variable name=&quot;Type&quot; select=&quot;.&quot;/>
<tr bgcolor=&quot;green&quot;>
<td>Type</td>
<td colspan=&quot;2&quot;>
<xsl:value-of select=&quot;$Type&quot;/>
</td>
</tr>

<xsl:for-each select=&quot;$AllCats&quot;>
<xsl:sort order=&quot;ascending&quot; select=&quot;.&quot;/>
<xsl:variable name=&quot;Cat&quot; select=&quot;.&quot;/>
<tr bgcolor=&quot;lime&quot;>
<td>Cat</td>
<td colspan=&quot;2&quot;>
<xsl:value-of select=&quot;$Cat&quot;/>
</td>
</tr>

<xsl:for-each select=&quot;//Check[@Type=$Type and @Cat=$Cat]&quot;>
<xsl:sort order=&quot;ascending&quot; select=&quot;@Grade&quot;/>
<xsl:apply-templates select=&quot;.&quot;/>
</xsl:for-each>

</xsl:for-each>
</xsl:for-each>

</table>
</xsl:template>

<xsl:template match=&quot;Check&quot;>

<tr bgcolor=&quot;gray&quot;>
<td>
<xsl:value-of select=&quot;@Name&quot;/>
</td>
<td colspan=&quot;2&quot;>
<xsl:value-of select=&quot;Advice&quot;/>
</td>
</tr>

<tr>
<td>Grade</td>
<xsl:for-each select=&quot;Detail/Head/Col&quot;>
<td>
<xsl:value-of select=&quot;.&quot;/>
</td>
</xsl:for-each>
</tr>

<xsl:for-each select=&quot;Detail/Row&quot;>
<tr>
<xsl:choose>
<xsl:when test=&quot;position() mod 2 = 1&quot;>
<xsl:attribute name=&quot;bgcolor&quot;>SILVER</xsl:attribute>
</xsl:when>
<xsl:eek:therwise>
<xsl:attribute name=&quot;bgcolor&quot;>WHITE</xsl:attribute>
</xsl:eek:therwise>
</xsl:choose>
<td>
<xsl:value-of select=&quot;@Grade&quot;/>
</td>
<xsl:for-each select=&quot;Col&quot;>
<td>
<xsl:value-of select=&quot;.&quot;/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>

</xsl:template>

</xsl:stylesheet>
 
Hey jel,

Thanks for your help. It really helped! I didn't understand how templates worked in xsl and this really showed me. I adapted your code to conform to my output but there are a couple of things that I still cannot modify. The problem that I am having is that for cat=2, I would like to output some other images based on a different set of conditions, but when I try to reference the category variable I get an invalid reference. Also, sometimes I get a table row output for cat=2 even though, there isn't a cat=2 in the xml file. I'm sure the solutions aren't too substantial but I can't seem to figure things out. Here's my new xsl file, I really appreciate any help. Thanks.
Code:
<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform&quot;>[/URL]
<xsl:output method=&quot;html&quot; version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; indent=&quot;yes&quot;/>
<xsl:template match=&quot;/&quot;><!-- MAIN PAGE TEMPLATE -->
	<html>
		<head>
			<title>Scan Results</title>
			<STYLE>
			BODY{FONT-FAMILY: Arial, Helvetica, Sans Serif; COLOR: black; FONT-SIZE: 12px;background-Color:White;}
			TR.rowEven { background-Color: #A1BDEA; } 
			TR.rowOdd { background-color: #EFEFEF;}
			TD{FONT-FAMILY: Arial, Helvetica, Sans Serif; COLOR: Black; FONT-SIZE: 12px; Font-weight:normal;}
			.headerText{FONT-FAMILY: Arial, Helvetica, Sans Serif; COLOR: #628ABB; FONT-SIZE: 22px; Font-weight:bold;}
			.subHeaderText{FONT-FAMILY: Arial, Helvetica, Sans Serif; COLOR: Black; FONT-SIZE: 14px; Font-weight:bold;}
			.tableHeaderText{FONT-FAMILY: Arial, Helvetica, Sans Serif; COLOR: Black; FONT-SIZE: 14px; Font-weight:bold;}
			.titleText{FONT-FAMILY: Arial, Helvetica, Sans Serif; COLOR: Black; FONT-SIZE: 12px; Font-weight:bold;}
			.linkText{Text-decoration:none;}
			</STYLE>
		</head>
	<body>
	<xsl:apply-templates/><!-- Call Sub Templates -->
	</body>
	</html>
</xsl:template>

<xsl:template match=&quot;SecScan&quot;>
	<span class=&quot;headerText&quot;>View Scan Report</span><br/>
	<br/><br/>
	<xsl:variable name=&quot;AllTypes&quot; select = &quot;Check[not(@Type=preceding::Check/@Type)]/@Type&quot;/>
	<xsl:variable name=&quot;AllCats&quot; select = &quot;Check[not(@Cat=preceding::Check/@Cat)]/@Cat&quot;/>

	<xsl:for-each  select=&quot;$AllTypes&quot;>
		<xsl:sort order=&quot;ascending&quot; select=&quot;.&quot;/>
		<xsl:variable name=&quot;Type&quot; select=&quot;.&quot;/>
		<xsl:choose>
			<xsl:when test=&quot;$Type = 1&quot;>
				<p><span class=&quot;subHeaderText&quot;>Scan Type 1</span></p>
			</xsl:when>
			<xsl:when test=&quot;$Type= 2&quot;>
				<p><span class=&quot;subHeaderText&quot;>Scan Type 2</span></p>
			</xsl:when>
			<xsl:when test=&quot;$Type= 3&quot;>
				<p><span class=&quot;subHeaderText&quot;>Scan Type 3</span></p>
			</xsl:when>
			<xsl:when test=&quot;$Type= 4&quot;>
				<p><span class=&quot;subHeaderText&quot;>Scan Type 4</span></p>
			</xsl:when>
			<xsl:otherwise>
				<p><span class=&quot;subHeaderText&quot;>Additional Scan Results</span></p>
			</xsl:otherwise>
		</xsl:choose>		
		
		<xsl:for-each  select=&quot;$AllCats&quot;>
			<xsl:sort order=&quot;ascending&quot; select=&quot;.&quot;/>
			<xsl:variable name=&quot;Cat&quot; select=&quot;.&quot;/>
			<xsl:choose>
				<xsl:when test=&quot;$Cat= 1&quot;>
					<p><span class=&quot;titleText&quot;>Category 1</span></p>
				</xsl:when >
				<xsl:otherwise>
					<p><span class=&quot;titleText&quot;>Other Category</span></p>
				</xsl:otherwise>
			</xsl:choose>
			
			<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;8&quot; bgcolor=&quot;#A1BDEA&quot;>
				<tr>
					<td width=&quot;40&quot; class=&quot;tableHeaderText&quot;>Score</td>
					<td width=&quot;150&quot; class=&quot;tableHeaderText&quot;>Issue</td>
					<td width=&quot;*%&quot; class=&quot;tableHeaderText&quot;>Results</td>
				</tr>

				<xsl:for-each select=&quot;//Check[@Type=$Type and @Cat=$Cat]&quot;>
					<xsl:sort order=&quot;ascending&quot; select=&quot;@Grade&quot;/>
					<tr>
						<xsl:choose>
							<xsl:when test=&quot;position() mod 2 = 0&quot;>
								<xsl:attribute name=&quot;class&quot;>rowEven</xsl:attribute>
							</xsl:when>
							<xsl:otherwise>
								<xsl:attribute name=&quot;class&quot;>rowOdd</xsl:attribute>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:apply-templates select=&quot;.&quot;/>
					</tr>					
				</xsl:for-each>

			</table>	
		</xsl:for-each><!-- $AllCats -->

	</xsl:for-each><!-- $AllTypes-->

 </xsl:template><!-- SecScan -->
<xsl:template match=&quot;Check&quot;>
		<td width=&quot;40&quot; align=&quot;center&quot; valign=&quot;top&quot;>
				<xsl:choose>
					<xsl:when test=&quot;@Grade <= 2&quot;>
						<xsl:for-each select=&quot;@Grade&quot;>
							<img src=&quot;X_Red.gif&quot;/>
						</xsl:for-each>
					</xsl:when>
					<xsl:when test=&quot;@Grade <=4&quot;>
						<xsl:for-each select=&quot;@Grade&quot;>
							<img src=&quot;X_Yellow.gif&quot;/>
						</xsl:for-each>
					</xsl:when>
					<xsl:when test=&quot;@Grade=5&quot;>
						<xsl:for-each select=&quot;@Grade&quot;>
							<img src=&quot;Check_Green.gif&quot;/>
						</xsl:for-each>
					</xsl:when>
					<xsl:otherwise></xsl:otherwise>
				</xsl:choose>
		</td>
		<td width=&quot;150&quot; align=&quot;left&quot; valign=&quot;top&quot;>
			<xsl:for-each select=&quot;@Name&quot;>
				<xsl:value-of select=&quot;.&quot;/>
			</xsl:for-each>
		</td>
		<td width=&quot;*%&quot; align=&quot;left&quot; valign=&quot;top&quot;>
			<xsl:for-each select=&quot;Advice&quot;>
				<xsl:value-of select=&quot;.&quot;/>
			</xsl:for-each>
			<br/>
			<table width=&quot;100%&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>
				<tr>
					<td width=&quot;150&quot;>
						<xsl:for-each select=&quot;@URL1&quot;>
							<a>
								<xsl:attribute name=&quot;class&quot;>linkText</xsl:attribute>
								<xsl:attribute name=&quot;href&quot;><xsl:value-of select=&quot;.&quot;/></xsl:attribute>
								<xsl:attribute name=&quot;target&quot;>_blank</xsl:attribute>
							What was scanned
						</a>
						</xsl:for-each>
					</td>
					<td>
						<xsl:for-each select=&quot;@URL2&quot;>
							<a>
								<xsl:attribute name=&quot;class&quot;>linkText</xsl:attribute>
								<xsl:attribute name=&quot;href&quot;><xsl:value-of select=&quot;.&quot;/></xsl:attribute>
								<xsl:attribute name=&quot;target&quot;>_blank</xsl:attribute>
							How to correct this
						</a>
						</xsl:for-each>
					</td>
				</tr>
			</table>
		</td>
</xsl:template><!-- Check -->
 
The problem that I am having is that for cat=2, I would like to output some other images based on a different set of conditions, but when I try to reference the category variable I get an invalid reference.
The variable $Cat is 'out of scope' within &lt;xsl:template match=&quot;Check&quot;&gt;. However, you can use the attribute @Cat, because the Check-node is your context.

I caught you red-handed once again trying to loop through atrributes:
&lt;xsl:for-each select=&quot;@URL2&quot;&gt;
&lt;a&gt;
...
&lt;xsl:attribute name=&quot;href&quot;&gt;
&lt;xsl:value-of select=&quot;.&quot;/&gt;
&lt;/xsl:attribute&gt;
...
&lt;/a&gt;
&lt;/xsl:for-each&gt;
There is nothing to loop here: your context-node 'Check' has just 1 attribute URL2, so this should be enough:
&lt;a&gt;
...
&lt;xsl:attribute name=&quot;href&quot;&gt;
&lt;xsl:value-of select=&quot;@URL2&quot;/&gt;
&lt;/xsl:attribute&gt;
...
&lt;/a&gt;

Also, sometimes I get a table row output for cat=2 even though, there isn't a cat=2 in the xml file.
Yes, for simplicity I made the nodelist $AllCats with unique Cats, and looped trough without bothering wether there would be Checks for each Type/Cat combination.
The easiest solution would be to test if there are checks for each combination when you make your header. A bit more sophisticated might be to make your nodelist $AllCats again for each $Type.
 
Hey jel,

Guilty as charged :)

Now that I know not to loop through attributes if I am already at the location, I still can't get the extra table header output to go away. You mentioned two options and I couldn't get any one of them working. Would it be possible to show how its done?

One other point that I was stuck on that I was hoping maybe you would know how was regarding the Detail Entity (see xml file at top of page) I wanted to output the values of this entity and all of its children (head &amp; row) in another table which I wanted displayed on a separate html page. I wanted to create a third hyperlink which would pop open this new page showing only the relevent details for that check. I'm guessing that I have to pass the check ID parameters but I'm quite unsure as how to output the detail entity and its children in a separate table.

Once again thanks for your help.
 
Oops, I completely missed you last post, so to make up: here's a new try.
In this one I skip the Cat-header if no Checks apply.
About opening another page: can't help you there, as the way you pass variables depends on the way you open your page. You can add <xsl:parameter name="ParamType"> in the stylesheet, and if you set it while parsing you can use it in x-path expressions.
However: as your xml already contains all the info you need to display these details, I simply added a kind of drop-down list. Here goes:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
  <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:template match="/">
    <!-- MAIN PAGE TEMPLATE -->
    <html>
      <head>
        <title>Scan Results</title>
        <SCRIPT language ="javascript">
        function OpenDetail(key){
          eval("DetailOpened"+key +".style.display=''");
          eval("DetailClosed"+key +".style.display='none'");
        }
        function CloseDetail(key){
          eval("DetailOpened"+key +".style.display='none'");
          eval("DetailClosed"+key +".style.display=''");
        }
        </SCRIPT>
        <STYLE>
            BODY{FONT-FAMILY: Arial, Helvetica, Sans Serif; COLOR: black; FONT-SIZE: 12px;background-Color:White;}
            TR.rowEven {background-color: #A1BDEA; }
            TR.rowOdd {background-color: #EFEFEF;}
            TD{FONT-FAMILY: Arial, Helvetica, Sans Serif; COLOR: Black; FONT-SIZE: 12px; Font-weight:normal;}
            .headerText{FONT-FAMILY: Arial, Helvetica, Sans Serif; COLOR: #628ABB; FONT-SIZE: 22px; Font-weight:bold;}
            .subHeaderText{FONT-FAMILY: Arial, Helvetica, Sans Serif; COLOR: Black; FONT-SIZE: 14px; Font-weight:bold;}
            .tableHeaderText{FONT-FAMILY: Arial, Helvetica, Sans Serif; COLOR: Black; FONT-SIZE: 14px; Font-weight:bold;}
            .titleText{FONT-FAMILY: Arial, Helvetica, Sans Serif; COLOR: Black; FONT-SIZE: 12px; Font-weight:bold;}
            .linkText{Text-decoration:none;}
        </STYLE>
      </head>
      <body>
        <xsl:apply-templates/>
        <!-- Call Sub Templates -->
      </body>
    </html>
  </xsl:template>

  <xsl:template match="SecScan">
    <span class="headerText">View Scan Report</span>
    <br/>
    <br/>
    <br/>
    <xsl:variable name="AllTypes" select="Check[not(@Type=preceding::Check/@Type)]/@Type"/>
    <xsl:variable name="AllCats" select="Check[not(@Cat=preceding::Check/@Cat)]/@Cat"/>
    <xsl:for-each select="$AllTypes">
      <xsl:sort order="ascending" select="."/>
      <xsl:variable name="Type" select="."/>
      <xsl:choose>
        <xsl:when test="$Type &lt; 5">
          <p>
            <span class="subHeaderText">
              <xsl:text>Scan Type </xsl:text>
              <xsl:value-of select="$Type"/>
            </span>
          </p>
        </xsl:when>
        <xsl:otherwise>
          <p>
            <span class="subHeaderText">Additional Scan Results</span>
          </p>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:for-each select="$AllCats">
        <xsl:sort order="ascending" select="."/>
        <xsl:variable name="Cat" select="."/>
        <xsl:if test="//Check[@Type=$Type and @Cat=$Cat]">
          <xsl:choose>
            <xsl:when test="$Cat= 1">
              <p>
                <span class="titleText">Category 1</span>
              </p>
            </xsl:when>
            <xsl:otherwise>
              <p>
                <span class="titleText">Other Category</span>
              </p>
            </xsl:otherwise>
          </xsl:choose>
          <table width="100%" border="0" cellspacing="0" cellpadding="8" bgcolor="#A1BDEA">
            <tr>
              <td width="40" class="tableHeaderText">Score</td>
              <td width="150" class="tableHeaderText">Issue</td>
              <td width="*%" class="tableHeaderText">Results</td>
            </tr>
            <xsl:for-each select="//Check[@Type=$Type and @Cat=$Cat]">
              <xsl:sort order="ascending" select="@Grade"/>
              <tr>
                <xsl:choose>
                  <xsl:when test="position() mod 2 = 0">
                    <xsl:attribute name="class">rowEven</xsl:attribute>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:attribute name="class">rowOdd</xsl:attribute>
                    <xsl:attribute name="style"/>
                  </xsl:otherwise>
                </xsl:choose>
                <xsl:apply-templates select=".">
                  <xsl:with-param name="pos" select="position()"/>
                </xsl:apply-templates>
              </tr>
            </xsl:for-each>
          </table>
        </xsl:if>
      </xsl:for-each>
      <!-- $AllCats -->
    </xsl:for-each>
    <!-- $AllTypes-->
  </xsl:template>
  <!-- SecScan -->

  <xsl:template match="Check">
    <xsl:param name="pos"/>
    <td width="40" align="center" valign="top">
      <xsl:choose>
        <xsl:when test="@Grade &lt;= 2">
          <img src="X_Red.gif"/>
        </xsl:when>
        <xsl:when test="@Grade &lt;=4">
          <img src="X_Yellow.gif"/>
        </xsl:when>
        <xsl:when test="@Grade=5">
          <img src="Check_Green.gif"/>
        </xsl:when>
        <xsl:otherwise></xsl:otherwise>
      </xsl:choose>
    </td>
    <td width="150" align="left" valign="top">
      <xsl:value-of select="@Name"/>
    </td>
    <td width="*%" align="left" valign="top">
      <xsl:value-of select="Advice"/>
      <br/>
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="150">
            <a>
              <xsl:attribute name="class">linkText</xsl:attribute>
              <xsl:attribute name="href">
                <xsl:value-of select="@URL1"/>
              </xsl:attribute>
              <xsl:attribute name="target">_blank</xsl:attribute>
What was scanned
            </a>
          </td>
          <td>
            <a>
              <xsl:attribute name="class">linkText</xsl:attribute>
              <xsl:attribute name="href">
                <xsl:value-of select="@URL2"/>
              </xsl:attribute>
              <xsl:attribute name="target">_blank</xsl:attribute>
How to correct this
            </a>
          </td>
        </tr>
      </table>
      <xsl:apply-templates>
        <xsl:with-param name="key" select="concat(@Type,@Cat,$pos)"/>
      </xsl:apply-templates>
    </td>
  </xsl:template>

  <xsl:template match="Detail">
    <xsl:param name="key"/>
    <table width="100%">
      <xsl:attribute name="id">
        <xsl:value-of select ="concat('DetailClosed',$key)"/>
      </xsl:attribute>
      <tr>
        <td/>
        <td/>
        <td width="50pt">
          <img src="plus.gif">
            <xsl:attribute name="onclick">
              <xsl:value-of select="concat('OpenDetail(',$key,');')"/>
            </xsl:attribute>
          </img>
        </td>
      </tr>
    </table>
    <table width="100%" style="display: none;" bgcolor="#cbd6ea">
      <xsl:attribute name="id">
        <xsl:value-of select ="concat('DetailOpened',$key)"/>
      </xsl:attribute>
      <tr>
        <td class="titleText">
          <xsl:value-of select="Head/Col[position()=1]"/>
        </td>
        <td class="titleText">
          <xsl:value-of select="Head/Col[position()=2]"/>
        </td>
        <td width="50pt">
          <img src="min.gif">
            <xsl:attribute name="onclick">
              <xsl:value-of select="concat('CloseDetail(',$key,');')"/>
            </xsl:attribute>
          </img>
        </td>
      </tr>
      <xsl:for-each select="Row">
        <tr>
          <td>
            <xsl:value-of select="Col[position()=1]"/>
          </td>
          <td>
            <xsl:value-of select="Col[position()=2]"/>
          </td>
        </tr>
      </xsl:for-each>
    </table>
  </xsl:template>
</xsl:stylesheet>
 
Thanks jel!

I like your javascript function to show and hide the details. Worked beautifully. Really appreciate your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top