aspose file tools
The moose likes Struts and the fly likes learn xsl to html creation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "learn xsl to html creation" Watch "learn xsl to html creation" New topic
Author

learn xsl to html creation

amit k bhardwaj
Greenhorn

Joined: Jul 29, 2010
Posts: 3
this is a excellent code to under xsl to html transformation

:: all code is self expalnatory

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method = "html" indent = "yes"/>
<xsl:template match="/">
<html>
<head>
</head>
<body>
<h1><I><xsl:value-of select= "content/entity/@name"/></I></h1>
<hr/>
<font color='#888888'>
<xsl:value-of select= "content/entity/country"/>
>
<xsl:value-of select= "content/entity/sector"/>
</font>
<br/>
<br/>
<xsl:for-each select="content/ratingCategory">
<xsl:if test = "@ratingTypeCode = 'ICR'">
<xsl:if test = "rating/name= 'Final'">
<xsl:choose>
<xsl:when test = "not(rating/creditWatch = 'Y')">
<b><font color='blue'><center><xsl:value-of select = "rating/outlook"/> / <xsl:value-of select = "rating/ratingCode"/></center></font></b>
</xsl:when>
<xsl:when test = "rating/creditWatch = 'Y'">
<center>CW:<xsl:value-of select = "rating/outlook"/> / <xsl:value-of select = "rating/ratingCode"/></center>
</xsl:when>
</xsl:choose>
</xsl:if>
</xsl:if>
</xsl:for-each>
<br/>
<p><xsl:value-of select= "content/comments"/></p>
<br></br>
<b><table border="1" align='center'>
<tr><th></th><th><b><font color='#009900'>Existing</font></b></th><th><b><font color='#009900'>Recommended</font></b></th><th><b><font color='#009900'>Final</font></b> </th></tr>
<xsl:for-each select="content/ratingCategory">
<tr>
<td><b><font color='#A80000'><xsl:value-of select = "@ratingTypeName"/></font></b></td>
<td align='center'>
<xsl:if test = "rating/name = 'Existing'">
<xsl:choose>
<xsl:when test = "not(rating/creditWatch = 'Y')">
<xsl:value-of select = "rating/outlook"/> / <xsl:value-of select = "rating/ratingCode"/>
</xsl:when>
<xsl:when test = "rating/creditWatch = 'Y'">
CW:<xsl:value-of select = "rating/outlook"/> / <xsl:value-of select = "rating/ratingCode"/>
</xsl:when>
</xsl:choose>
</xsl:if>
</td>
<td align='center'>
<xsl:if test = "rating/name = 'Recommended'">
<xsl:choose>
<xsl:when test = "not(rating/creditWatch = 'Y')">
<xsl:value-of select = "rating/outlook"/> / <xsl:value-of select = "rating/ratingCode"/>
</xsl:when>
<xsl:when test = "rating/creditWatch = 'Y'">
CW:<xsl:value-of select = "rating/outlook"/> / <xsl:value-of select = "rating/ratingCode"/>
</xsl:when>
</xsl:choose>
</xsl:if>
</td>
<td align='center'>
<xsl:if test = "rating/name = 'Final'">
<xsl:choose>
<xsl:when test = "not(rating/creditWatch = 'Y')">
<xsl:value-of select = "rating/outlook"/> / <xsl:value-of select = "rating/ratingCode"/>
</xsl:when>
<xsl:when test = "rating/creditWatch = 'Y'">
CW:<xsl:value-of select = "rating/outlook"/> / <xsl:value-of select = "rating/ratingCode"/>
</xsl:when>
</xsl:choose>
</xsl:if>
</td>
</tr>
</xsl:for-each>
</table>
</b>
<br/>
<br/>
<b>
<P align="left">Recommended By:
<br></br>
<br/>
Chairman :
<xsl:for-each select="content/entity/committeeMember/memberInfo">
<xsl:if test = "role = 'chairman'">
<xsl:value-of select = "@name"/>
</xsl:if>
</xsl:for-each>
<br/>
Voters :
<xsl:for-each select="content/entity/committeeMember/memberInfo">
<xsl:if test = "role = 'voter'">
<xsl:value-of select = "@name"/>;
</xsl:if>
</xsl:for-each>
</P>
</b>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: learn xsl to html creation
 
Similar Threads
Code Allignment In Xml Spy Editor
Remove unwanted space before and after the table using javascript
How to get XSL table with alternating rows highlighted
Cross Browser Compatibility Issues
Handling Nested tables in xsl:fo for saving a document in RTF