How to convert the xml and xslt into proper HTML table? | XML / XSL / XSLT / XPath | Forum

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search:

— Forum Scope —



— Match —



— Forum Options —




Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

How to convert the xml and xslt into proper HTML table?
June 21, 2010
10:26 am
kumar.ganesh
Member
Forum Posts: 5
Member Since:
June 20, 2010
Offline

Hello,

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:

<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>

Thank you.

June 21, 2010
10:51 am
poster
Member
Forum Posts: 13
Member Since:
June 17, 2010
Offline

Here is an example of xsl for your xml format to display proper html table.

 

XSL:

 

<?xml version="1.0"?>
<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 version="1.0"?>
<?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>

Forum Timezone: UTC 5.5

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)