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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use xsl and display in 2 column table

Status
Not open for further replies.

mmormann

MIS
Sep 5, 2003
3
US
I have an xml file which I want to use xsl to put certain information in a table. I only want to extract particular ID's and put them in the table. The problem I am having is how to know when to put in a <tr> table return to get
the table into 2 columns with the coding in my xsl file. I would like the output to look like below in a table with 2 columns for only the ID's or data I want to pick
out:

Base Unit Module
Unit Airflow RPM
Unit Height Unit Weight


Any help would be greatly appreciated.

Below is the xml file.

<?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?>
<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;unit.xsl&quot;?>
<Performance_Data>
<Perf_Module nID=&quot;2004656&quot; name=&quot;Base Unit Module&quot;>
<Perf_Category nID=&quot;31&quot; name=&quot;Unit Airflow&quot;>
</Perf_Category>
<Perf_Category nID=&quot;21&quot; name=&quot;Unit Length&quot;>
</Perf_Category>
<Perf_Category nID=&quot;53&quot; name=&quot;Unit Weight&quot;>
</Perf_Category>
<Perf_Category nID=&quot;4&quot; name=&quot;Unit Width&quot;>
</Perf_Category>
<Perf_Category nID=&quot;55&quot; name=&quot;Unit Height&quot;>
</Perf_Category>
<Perf_Category nID=&quot;2014727&quot; name=&quot;ESP&quot; >
</Perf_Category>
<Perf_Category nID=&quot;20&quot; name=&quot;RPM&quot;>
</Perf_Category>
<Perf_Category nID=&quot;2&quot; name=&quot;Total Static Pres.&quot; shortCode=&quot;TSP&quot;>
</Perf_Category>
<Perf_Category nID=&quot;18&quot; name=&quot;SEFF&quot;>
</Perf_Category>
</Perf_Module>
</Performance_Data>



 
Try comparing
Code:
position()
with
Code:
count() div 2
, ie
Code:
<xsl:template match=&quot;your_id_matching_expression_here&quot;>
  <xsl:choose>
    <xsl:when test=&quot;not(position() mod (count() div 2))&quot;>
      <tr>
        <xsl:call-template name=&quot;your_template_name&quot; select=&quot;.&quot; />
      </tr>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name=&quot;your_template_name&quot; select=&quot;.&quot; />
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top