470,874 Members | 1,859 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,874 developers. It's quick & easy.

Dynamic Rows and Columns in XSL Table

Hi,

I am trying to create a table in XSL in which the number of columns depends on a given XML. For example, the XML below needs to have three columns, each with the title of the corresponding <Name> (but the number of columns needs to depend on the number of <FormulaValue> elements present a given XML).

I appreciate all help...I've been trying to figure this out for days.

Thank you,
Christine


XSL code:

[HTML]

<Step>
<FormulaValue>
<Name>CIP_FEED_PUMP_SPEED</Name>
<Display>false</Display>
<Value/>
<Real>75</Real>
<EngineeringUnits></EngineeringUnits>
</FormulaValue>

<FormulaValue>
<Name>CIP_XFER_PUMP_SPEED</Name>
<Display>false</Display>
<Value/>
<Real>35</Real>
<EngineeringUnits></EngineeringUnits>
</FormulaValue>

<FormulaValue>
<Name>FEED_FLOW_RATE</Name>
<Display>false</Display>
<Value/>
<Real>5.7</Real>
<EngineeringUnits></EngineeringUnits>
</FormulaValue>
</Step>

[/HTML]
Jun 13 '07 #1
1 5987
Dököll
2,364 Expert 2GB
Hello, Christine!

I believe you're off to a great start. I will include an old code here, you can strip it for own use. Took this in college many moons ago. Please also delete some of it. I am including it all so when you try it, it works:

XML

[HTML]
<?xml version="1.0"?>
<!-- File Name: apartmentlist.xml -->

<?xml-stylesheet type="text/xsl" href="ApartmentSearch.xsl"?>

<RENTALUNITS>
<LISTING>
<APARTMENT>Konner Ridge</APARTMENT>
<ADDRESS>23 Monroe St.</ADDRESS>
<PHONE>256-5533</PHONE>
<BEDROOMS>3</BEDROOMS>
<BATHS>2</BATHS>
<VACANCY>2</VACANCY>
</LISTING>
<LISTING>
<APARTMENT>Konner Ridge</APARTMENT>
<ADDRESS>23 Monroe St.</ADDRESS>
<PHONE>256-5533</PHONE>
<BEDROOMS>1</BEDROOMS>
<BATHS>1</BATHS>
<VACANCY>2</VACANCY>
</LISTING>
<LISTING>
<APARTMENT>River Side Apartments</APARTMENT>
<ADDRESS>400 St. Joe River Rd.</ADDRESS>
<PHONE>395-4474</PHONE>
<BEDROOMS>1</BEDROOMS>
<BATHS>1</BATHS>
<VACANCY>2</VACANCY>
</LISTING>
<LISTING>
<APARTMENT>White Oak Apartments</APARTMENT>
<ADDRESS>900 W. 111th St</ADDRESS>
<PHONE>398-4123</PHONE>
<BEDROOMS>2</BEDROOMS>
<BATHS>2</BATHS>
<VACANCY>1</VACANCY>
</LISTING>
<LISTING>
<APARTMENT>Moore Woods Apartments</APARTMENT>
<ADDRESS>200 N. 1st St.</ADDRESS>
<PHONE>695-0695</PHONE>
<BEDROOMS>2</BEDROOMS>
<BATHS>1</BATHS>
<VACANCY>2</VACANCY>
</LISTING>
<LISTING>
<APARTMENT>Rhodes Manner Apartments</APARTMENT>
<ADDRESS>1000 Welsh Ave</ADDRESS>
<PHONE>395-3305</PHONE>
<BEDROOMS>4</BEDROOMS>
<BATHS>2</BATHS>
<VACANCY>2</VACANCY>
</LISTING>
</RENTALUNITS>

[/HTML]

XSL

[HTML]
<?xml version="1.0"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
Database search
<center>
<a href="Uhome.html"><img border="0" src="GoHome.bmp" alt="Click here to go home"></img></a>
<h2>Browse Availability</h2>
</center>
<xsl:for-each select="RENTALUNITS/LISTING">
<xsl:sort select="APARTMENT" />
<p>
<span style="font-style:italic; font-weight: 900; color: #ff6633">
<xsl:value-of select="ADDRESS" />
</span>
<xsl:text> </xsl:text>
<span style="font-variant:small-caps; font-weight:bold">
<xsl:value-of select="PHONE"/>
</span>
</p>
<p style="margin-left: 3%">
<span style="font-weight:bold">Number of Bedrooms/Baths </span>
<xsl:value-of select="BEDROOMS" /> bedrooms and <xsl:value-of select="BATHS"/> baths.
Number of vacancies:
<span style="font-style:italic; font-weight: bold; color:#009999">
<xsl:value-of select="VACANCY" />
</span>
</p>
</xsl:for-each>
</xsl:template>
</xsl:transform>
[/HTML]

Save these in the same folder, double click the XML file and see it come to life.

Hope this helps...

Dököll
Jun 14 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Bass Pro | last post: by
2 posts views Thread by jainharsh | last post: by
reply views Thread by Eniac | last post: by
2 posts views Thread by DaveL | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.