I have a small problem with xml and xsl. Starting in Dev, I have always tried to stay away but then I had no choice. I need to display a table of milestones (date + event), so I have my table with 2 columns "Event" and "Date". Nothing too difficult so far.
In fact my XML file is generated via a PHP function. The tags are inserted in the drive in code and content is provided by variables. It may not super clear, but my a priory .xml file has no problem (I indented myself after because it does not work if I did it in the PHP where I created my .xml):
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="sheet.xsl" type="text/xsl"?>
<sheethl>
<date>01-10-2009</date>
<title><![CDATA[XSL3 - Design and milestones]]></title>
<resp>Blabla</resp>
<desc><![CDATA[Establishment of design.
Testing the new code level milestones (self-generation lines).]]></desc>
<changes><![CDATA[* change1
* change2
* change3]]></changes>
<ww><![CDATA[* Who
* When]]></ww>
<milestones>
<jde>
<jdate>28-09-09</jdate>
<jevent><![CDATA[event 1]]></jevent>
</jde>
<jde>
<jdate>29-09-09</jdate>
<jevent><![CDATA[event 2]]></jevent>
</jde>
<jde>
<jdate>30-09-09</jdate>
<jevent><![CDATA[event 3]]></jevent>
</jde>
</milestones>
<fm><![CDATA[* FM1
* FM2
* FM3]]></fm>
<ep><![CDATA[* EP1
* EP2
* EP3]]></ep>
</sheethl>
Let the file .xsl:
I created a template with appropriate milestones (in doubt): Code:
Code:
<xsl:template name="milestones" match="//milestones">
<xsl:for-each select="//jde">
<tr>
<td>
<xsl:value-of select="//jevent"/>
</td>
<td>
<xsl:value-of select="//jdate"/>
</td>
</tr>
</xsl:for-each>
</xsl:template>
And here's the part of the file .xsl template where this individual is known and used:
Code:
<table id="milestones">
<tr>
<th>Event</th>
<th>Date</th>
</tr>
<xsl:call-template name="milestones"/>
</table>
All this gives me:
Event Date
Event 1 28-09-09
Event 1 28-09-09
Event 1 28-09-09
Show me in places in lines 2 and 3: "event 2" and "event 3" and "29-09-09" and "30-09-09" column for "Date"
Do you have an idea?
Bookmarks