我有以下XML文档:
<?xml version="1.0" encoding="UTF-8"?>
<cars>
<car body="Wagon">
<text>Red</text>
</car>
<car body="Sedan">
<text>Yellow</text>
</car>
<car body="Sedan">
<text></text>
</car>
<car body="Wagon">
<textlist>
<text>Red</text>
<text>Green</text>
<text>Black</text>
<text>Blue</text>
</textlist>
</car>
<car body="Sedan">
<textlist>
<text>Yellow</text>
<text>Orange</text>
</textlist>
</car>
<car body="Fastback">
<textlist>
<text>Yellow</text>
<text>Red</text>
<text>Green</text>
<text>Black</text>
<text>Blue</text>
</textlist>
</car>
<car body="Fastback">
<textlist>
<text>Pink</text>
<text>Red</text>
<text>Orange</text>
</textlist>
</car>
</cars>
使用XSLT 1.0我需要将XML文档转换成这种格式:
<?xml version="1.0" encoding="UTF-8"?>
<cars>
<car type="Wagon">Red</car>
<car type="Sedan">Yellow</car>
<car type="Wagon">Green</car>
<car type="Wagon">Black</car>
<car type="Wagon">Blue</car>
<car type="Sedan">Orange</car>
</cars>
注意:
- 体=“快背”被排除
- 重复被排除在外(红色货车出现了两次)
- 文本清单多个项目投入作为输出XML单个元素
- 忽略空值