I have to convert from one XML (XHTML) file to another using XSLT. The rules of transformation are:
- The values of id=”t0b” and “t1b” have to be replaced with id=”ta0b8″ and “ta3b8” respectively.
<input type="radio" name="o0" id="t0"/>has to be replaced with<input type="radio" name="key0b8" value="0" id="ta0q" class="block" />(And likewise in the file)
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="iDev">
<div class="q">
<div id="t0b" class="block">1<span style="color">TEXT1</span>
</div><br />
T <input type="radio" name="o0" id="t0"/>
F <input type="radio" name="op0" id="f0"/>
<div id="sfb"></div>
</div><br />
<div class="q">
<div id="t1b" class="block">2<span style="color">TEXT2</span>
</div><br />
T <input type="radio" name="o1" id="t1" />
F <input type="radio" name="op1" id="f1" />
<div id="sfb"></div>
</div>
</div>
</body>
</html>
Output 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="iDev">
<div class="q">
<div id="ta0b8" class="block">1<span style="color">TEXT1</span>
</div><br />
T<input type="radio" name="key0b8" value="0" id="ta0q" />
F<input type="radio" name="key0b8" value="1" id="ta1q" />
<div id="sfb"></div>
</div><br />
<div class="q">
<div id="ta3b8" class="block">2 <span style="color">TEXT2</span>
</div><br />
T<input type="radio" name="key3b8" value="0" id="ta0q3" />
F<input type="radio" name="key3b8" value="1" id="ta1q3" />
<div id="sfb"></div>
</div>
</div>
</body>
</html>
I’m able to modify when there is only one block of <div class="q">CODE HERE</div> by using identity template and the suggestions in the forum but when the block is repeated multiple times with different values of its attributes then I’m not able to do so. Please help me out in achieving this task. Thanking you.
Rule 1 can be implemented by …
… and similarly for the other div element.
Rule 2 can be implemented by …