【发布时间】:2021-10-27 02:49:57
【问题描述】:
下面是我将用于转换的示例输入 XML 文件。需要是转换后的XML输出
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="test1">
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
<cd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="test2">
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<country>USA</country>
<company>RCA</company>
<price>9.90</price>
<year>1982</year>
</cd>
<cd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="test1">
<title>Still got the blues</title>
<artist>Gary Moore</artist>
<country>UK</country>
<company>Virgin records</company>
<price>10.20</price>
<year>1990</year>
</cd>
<cd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="test2">
<title>Eros</title>
<artist>Eros Ramazzotti</artist>
<country>EU</country>
<company>BMG</company>
<price>9.90</price>
<year>1997</year>
</cd>
</catalog>
我需要编写一个 XSL 转换器,这样我就可以只遍历具有 xsi:type="test1" 的目录/cd
输出 XML 应该如下所示
<catalog>
<cd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="test1">
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
<cd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="test1">
<title>Still got the blues</title>
<artist>Gary Moore</artist>
<country>UK</country>
<company>Virgin records</company>
<price>10.20</price>
<year>1990</year>
</cd>
</catalog>
非常感谢任何帮助。
干杯
【问题讨论】:
-
请就您在尝试完成此操作时遇到的困难提出一个具体问题。否则看起来你只是在找人为你编写代码。