I’m having one problem, for one project I have two packages (A and B) containing some .xml,.gif,.js,.html files etc. My task is to convert from package A to B. For step one transformation of one XML to another one was required which I did with XSLT. Second step was to include the missing javascripts file from folder(package) B to A, which I did using a java program. Now my third task is modify the .html files of package A to include those javascripts elements and other elements (one submit button also) which I have copied from B. So can anyone please help me out that how can I do this transformation.
HTML of package A (Source)-
<?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" />
<title>eXe</title>
<style type="text/css">
@import url(base.css);
@import url(content.css);
</style>
<script type="text/javascript" src="common.js"></script>
</head>
<body>
<div id="outer">
<div id="main">
<div id="nodeDecoration">
<p id="nodeTitle">
Part 1</p>
</div>
<div class="TrueFalseIdevice" id="id12">
<script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="libot_drag.js"></script>
<div class="iDevice emphasis1">
......
.......
</div></html>
HTML of Package B (Required)-
<?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>
<title>eXe</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import url(base.css);
@import url(content.css);
</style>
<script type="text/javascript" src="common.js"></script>
</head>
<!--TO BE INCLUDED-->
<script type="text/javascript" src="APIWrapper.js"></script>
<script type="text/javascript" src="SCOFunctions.js"></script>
<!---->
<body onload="loadPage()" onunload="unloadPage()"><div id="outer">
<div id="main">
<div id="nodeDecoration">
<p id="nodeTitle">
Part 1</p></div>
<div class="QuizTestIdevice" id="id8">
.....
......
.......
<!--This submit button also has to be included-->
<br/><input type="submit" name="submitB" value="SUBMIT ANSWERS"/>
......
......
....
</div></html>
You could parse the HTML to an XML infoset (There are several HTML parsers available, including TagSoup), transform using XSLT, and serialize back to HTML using the HTML output mode of XSLT.
Or you could try to deal with this using regular expressions, hoping you can find a suitable one for each of the relevant sections in the source HTML.