Jump to content

How to get childrens in complex output with xsl


Rediloris

Recommended Posts

hello to all,
I'm newbie with XML, XSL and I've been trying and I'm only getting the first 2 rows(headers) of the output desired so far.
May somebody help me in how to get output of table below with an xsl stylesheet using the XML input below.
The XML input is:
<?xml version="1.0" encoding="UTF-8"?><TUPH><KIND><ABx>Event 1</ABx><RN><MO><CDy>11</CDy><CDy>5</CDy> </MO> <MO><MJp>6</MJp><MJp>7</MJp><MJp>9</MJp> </MO> </RN><JN><MO><CDy>8</CDy> </MO> <MO><MJp>1</MJp><MJp>3</MJp> </MO> </JN> </KIND><KIND> <ABx>Event 2</ABx><RN><MO><CDy>3</CDy></MO> <MO><MJp>5</MJp></MO> </RN><JN><MO><CDy>6</CDy></MO> <MO><MJp>2</MJp></MO> </JN></KIND> </TUPH>

​The XSL I have so far is:
<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">    <xsl:output indent="yes" method="html"/> <xsl:template match="/"><html><table border="1"><tr><td></td><td>RN</td><td></td><td>JN</td><td></td> </tr><tr><td>ABx</td><td>CDy</td><td>MJp</td><td>CDy</td><td>MJp</td> </tr><xsl:apply-templates select="KIND"/> </table>        </html></xsl:template> <xsl:template match="KIND/ABx"><td>    <xsl:apply-templates select="ABx"/></td></xsl:template> </xsl:stylesheet>
The output I'm looking for is:
<html>	<table border="1">		<tr>			<td></td>			<td>RN</td>			<td></td>			<td>JN</td>			<td></td>		</tr>		<tr>			<td>ABx</td>			<td>CDy</td>			<td>MJp</td>			<td>CDy</td>			<td>MJp</td>		</tr>		<tr>			<td>Event 1</td>			<td>11</td>			<td>6</td>			<td>8</td>			<td>1</td>		</tr>		<tr>			<td></td>			<td>5</td>			<td>7</td>			<td></td>			<td>3</td>		</tr>		<tr>			<td></td>			<td></td>			<td>9</td>			<td></td>			<td></td>		</tr>		<tr>			<td>Event 2</td>			<td>3</td>			<td>5</td>			<td>6</td>			<td>2</td>		</tr>			</table>	</html>	

 

Thanks in advance for any help.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...