【发布时间】:2013-05-16 07:21:55
【问题描述】:
我正在尝试通过以下方式将多个 XML 文件合并为一个:
假设我有一个 XML 文件,名为 fruit.xml:
<fruit>
<apples>
<include ref="apples.xml" />
</apples>
<bananas>
<include ref="bananas.xml" />
</bananas>
<oranges>
<include ref="oranges.xml" />
</oranges>
</fruit>
以及从fruit.xml 引用的后续XML 文件,例如apples.xml:
<fruit>
<apples>
<apple type="jonagold" color="red" />
<... />
</apples>
</fruit>
等等...我想将它们合并到 1 个 XML 文件中,如下所示:
<fruit>
<apples>
<apple type="jonagold" color="red" />
<... />
</apples>
<bananas>
<banana type="chiquita" color="yellow" />
<... />
</bananas>
<oranges>
<orange type="some-orange-type" color="orange" />
<... />
</oranges>
</fruit>
我想根据fruits.xml 的<include> 元素中的ref 属性的值动态确定“子”文件(如apples.xml、bananas.xml 等),然后包含它们在输出中。
这是否可以使用 XSLT?
【问题讨论】: