Jump to content

How to get childrens in complex output with xsl

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...