I have an XML(XHTML) file which I'm transforming into another XML file by using XSLT. I'm able to transform all the contents successfully but I need to include one Javascript in the output file which I'm unable to include. Can anyone please tell me that how can I include a javascript in the output file by using XSLT.
My Input file:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
</head>
<body>
<div class="TF" id="id8">
<div class="iDev">
<div class="q">
T <input type="radio" name="o0" id="t0" onclick="getFeedback()"/>
</div>
</div>
</div>
</body>
</html>
Desired Output
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
</head>
<body>
<div class="QT" id="id10">
<script type="text/javascript">
<!-- //<![CDATA[
var numQuestions = 4;
var rawScore = 0;
var actualScore = 0;
function getAnswer()
{
}
function calulate()
{
}
//]]> -->
</script>
<div class="iDev">
<div class="q">
T <input type="radio" name="o0" id="t0" onclick="getFeedback()"/>
</div>
</div>
</div>
</body>
</html>
XSLT Part:
<xsl:template match="xhtml:div[@id='id8']/@*">
<xsl:attribute name="class">QT</xsl:attribute>
<xsl:attribute name="id">id10</xsl:attribute>
<script type="text/javascript">
<![CDATA[
var numQuestions = 4;
var rawScore = 0;
var actualScore = 0;
function getAnswer()
{
}
function calulate()
{
}
]]>
</script>
</xsl:template>
I have created identity template and changed the values of attributes where-ever it was required according to the desired output but still I don't know how can I include the javascript after <div class="TF" id="id8">
this tag. Thanks!