我必须使用 XSLT 从一个 XML (XHTML) 文件转换为另一个。转换规则如下:
- id="t0b" 和 "t1b" 的值必须分别替换为 id="ta0b8" 和 "ta3b8"。
<input type="radio" name="o0" id="t0"/>
必须替换为<input type="radio" name="key0b8" value="0" id="ta0q" class="block" />
(同样在文件中)
输入文件:
<?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>
输出文件:
<?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>
当只有一个块时,我可以<div class="q">CODE HERE</div>
通过使用身份模板和论坛中的建议进行修改,但是当该块被重复多次并具有不同的属性值时,我无法这样做。请帮助我完成这项任务。感谢您。