How to convert the xml and xslt into proper HTML table? | XML / XSL / XSLT / XPath | Forum
10:26 am
June 20, 2010
OfflineHello,
I have an XML file with some information and corresponding XSLT and XSD
files. I need to convert this XML to user friendly HTML table, but the
problem is that XSLT contains general description and no instructions
about XML to HTML conversion. Do I need to write my own parser or maybe
there are existing solutions to make this conversion?
These are parts ot this files (they are too big):
XML:
−
<Consumers>
−
<s>
−
<PVS>
<status>NotVerified</status>
</PVS>
−
<CAIS>
−
<Consumer>
−
<Address>
<addressCurrPrev>0</addressCurrPrev>
<buildingNbr>401</buildingNbr>
<country>FR</country>
<endDate/>
<flatNbr>56</flatNbr>
<homeTelNbr>555 77 88</homeTelNbr>
<houseNbr/>
<line1/>
<line2>ABC</line2>
<line3>DEF</line3>
<line4>GHI</line4>
<postcode>191011</postcode>
<regionCode>02</regionCode>
<startDate>19950101000000</startDate>
<type>1</type>
</Address>
−
Thank you.
10:51 am
June 17, 2010
OfflineHere is an example of xsl for your xml format to display proper html table.
XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="//Consumers">
<table border="1" cellpadding="2" cellspacing="2">
<tr>
<td>Status: <xsl:value-of select="s/PVS/status" /></td>
</tr>
<tr>
<td>
<table>
<xsl:apply-templates select="s/CAIS/Consumer/Address" />
</table>
</td>
</tr>
</table>
</xsl:template>
<xsl:template match="s/CAIS/Consumer/Address">
<tr>
<td>Address Current/Previous:</td><td><xsl:value-of select="addressCurrPrev" /></td>
</tr>
<tr>
<td>Building No:</td><td><xsl:value-of select="buildingNbr" /></td>
</tr>
<tr>
<td>Country:</td><td><xsl:value-of select="country" /></td>
</tr>
</xsl:template>
</xsl:stylesheet>
XML:
<?xml-stylesheet href="test.xsl"?>
<EnquiryResponse>
<Consumers>
<s>
<PVS>
<status>NotVerified</status>
</PVS>
<CAIS>
<Consumer>
<Address>
<addressCurrPrev>0</addressCurrPrev>
<buildingNbr>401</buildingNbr>
<country>FR</country>
<endDate/>
<flatNbr>56</flatNbr>
<homeTelNbr>555 77 88</homeTelNbr>
<houseNbr/>
<line1/>
<line2>ABC</line2>
<line3>DEF</line3>
<line4>GHI</line4>
<postcode>191011</postcode>
<regionCode>02</regionCode>
<startDate>19950101000000</startDate>
<type>1</type>
</Address>
</Consumer>
</CAIS>
</s>
</Consumers>
</EnquiryResponse>
Most Users Ever Online: 11
Currently Online:
6 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
poster: 13
scorpio: 6
kumar.ganesh: 5
varung: 5
emilyk: 4
me.shann: 3
Member Stats:
Guest Posters: 0
Members: 15
Moderators: 0
Admins: 1
Forum Stats:
Groups: 1
Forums: 19
Topics: 16
Posts: 38
Newest Members: alex_c, nandhajj, me.shann, senthil, soumyaRaghuveer, kumar.ganesh
Moderators:
Administrators: admin (0)
Log In
Register
Home

