Idea about creating a html file from xml+xslt in Perl

Wednesday, November 4, 2015

My aim is to generate an HTMl file from two XML and XSLT files. I have looked over net ans find no good suggestion which I could do the same way. What I understand when I add the lines



<xsl:output method="html" ..... />


I could see the output as HTML. But my goal is having a new file whic I could save it via Perl script and seeing the result. I don't know if it is possible or not. I'll be glad to know if is so.



I would be pleased if someone let me know any idea that help me.



Here are my XML and XSLT files:



<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="test.xslt"?>
<Summary>
<test name="test">
<xml_name name="ABC">
<version num="104">
<component name="APPS">
<componenet_ver>104</componenet_ver>
</component>
<component name="Ner">
<componenet_ver>1.0</componenet_ver>
</component>
<component name="HUNE">
<componenet_ver>003</componenet_ver>
</component>
<component name="FADA">
<componenet_ver>107</componenet_ver>
</component>
<component name="VEDA">
<componenet_ver>8.8</componenet_ver>
</component>
</version>
</xml_name>
</test>
</Summary>


and



<?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" version="5.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="Summary/test">
<html>
<body>
<table>
<tr bgcolor="Peru">
<th>Components</th>
<th>Versions</th>
</tr>
<xsl:for-each select="//component">
<xsl:variable name="CompomName" select="@name"/>
<xsl:variable name="VerName" select="description"/>
<tr>
<td bgcolor="aqua" name = "{$CompomName}"> </td>
<td bgcolor="aqua" name = "{$VerName}"> </td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

0 comments:

Post a Comment