[
Lists Home |
Date Index |
Thread Index
]
- From: Peter Johansson <qtxpjoh@aom.ericsson.se>
- To: xml-dev@ic.ac.uk
- Date: Mon, 23 Aug 1999 16:25:06 +0200
I'm trying to transform a xmldocument to HTML and I'm just stuck with this
problem. Hope U have patience with my question :-)
I have this XML file:
<myml>
<items>
<item>
<id>hej</id>
<domain>nisse</value>
<params>
<param>
<name> hup</name>
<value> 22</value>
</param>
<param>
<name> huj</name>
<value> 23</value>
</param>
<param>
<name> hopp</name>
<value> 24</value>
</param>
</params>
<====== My problem is here when i need to go one level deeper in my
<items>
<====== xml-stucture.
<item>
<id>hej:hej1</id>
<domain>nisse</value>
<params>
<param>
<name> hubba</name>
<value> 25</value>
</param>
<param>
<name> bubba</name>
<value> 26</value>
</param>
</params>
</item>
</items>
</myml>
What kind of xsl code do I need to be able to display the deeper level?
Should I use a <xsl:if> statement to be able to do items again i the
deeper level and in that case, how will the syntax look like?
My current XSL file is shown below if it might be of any help. Now it
prints:
id: hej domain:nisse
name value
hup 22
huj 23
hopp 24
it does not continue with:
id hej:hej1 domain:nisse
name value
hubba 25
bubba 26
What can I put in my xsl file to make this happen??
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
<xsl:template match="/">
<html>
<head>
<title>***
cnaml filen ***</title>
</head>
<body bgcolor="ffff00">
<P> <font
face="Times, serif" color="blue" size="3">**XML-listan**</font></P>
<xsl:apply-templates
select="cnaml" />
</body>
</html>
</xsl:template>
<xsl:template match="myml">
<xsl:apply-templates select="items"
/>
</xsl:template>
<xsl:template match="items">
<xsl:apply-templates select="item" />
</xsl:template>
<xsl:template match="item">
<table BORDER="3" CELLSPACING="1" CELLPADDING="1">
<tr><p>
<td>
<font face="Times, bold" color="purple" size="3">
IDENTITY:<xsl:value-of select="id"/>
</font>
</td>
<td>
<font face="Times, bold" color="purple" size="3">
DOMAIN: <xsl:value-of select="domain"/>
</font>
</td>
</p>
</tr>
</table>
<xsl:apply-templates select="params"/>
</xsl:template>
<xsl:template match="params">
<table BORDER="3" CELLSPACING="1"
CELLPADDING="1">
<th>Name</th>
<th>Value</th>
<xsl:apply-templates select="param"/>
</table>
</xsl:template>
<xsl:template match="param">
<tr>
<td>
<font face="Times, serif" color="blue" size="2">
<xsl:value-of select="name"/>
</font>
</td>
<td>
<font face="Times, serif" color="green" size="2">
<xsl:value-of select="value"/>
</font>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
Hope this question is OK for this list, it si something I have been
stuck with for a while and I hope someone might look in to it. By the way
I use XT to transform from XML to HTML
//Peter
|