我需要合并两个 XML 文件。
我尝试根据Merge 2 XML files based on attribute values using XSLT? 中的答案编写 XSLT 样式表?,但我没有成功。
_a1.xml
<?xml version="1.0" encoding="UTF-8"?>
<ExtData>
<table bName="B SERs" id="BSER">
<Col bName="Bus" id="BUS">
<CoreCol coreEName="SER" coreHref="../_a2.xml" corebName="Bus" coreId="BUS"/>
</Col>
<Col bName="Ser" id="NAME">
<CoreCol coreEName="SER" coreHref="../_a2.xml" corebName="Ser" coreId="NAME"/>
</Col>
<Col bName="ID" id="ID">
<CoreCol coreEName="SER" coreHref="../_a2.xml" corebName="SerId" coreId="UCMDB_ID"/>
</Col>
</table>
</ExtData>
_a2.xml
<?xml version="1.0" encoding="UTF-8"?>
<ExtData>
<table bName="B SERs" id="BSER">
<Col EName="SER" bName="Bus" Id="BUS"/>
<Col EName="SER" bName="Ser" Id="NAME"/>
<Col EName="SER" bName="SerId" Id="DB_ID"/>
<Col EName="SER" bName="SerDate" Id="date"/>
<Col EName="SER" bName="Person" Id="Manager"/>
<Col EName="SER" bName="desc" Id="desc"/>
</table>
</ExtData>
并且输出需要是:
<?xml version="1.0" encoding="UTF-8"?>
<ExtData>
<table bName="B SERs" id="BSER">
<Col bName="Bus" id="BUS">
<CoreCol coreEName="SER" coreHref="../_a2.xml" corebName="Bus" coreId="BUS"/>
</Col>
<Col bName="Ser" id="NAME">
<CoreCol coreEName="SER" coreHref="../_a2.xml" corebName="Ser" coreId="NAME"/>
</Col>
<Col bName="ID" id="ID">
<CoreCol coreEName="SER" coreHref="../_a2.xml" corebName="SerId" coreId="UCMDB_ID"/>
</Col>
<Col bName="" id="">
<CoreCol coreEName="SER" coreHref="../_a2.xml" corebName="SerDate" coreId="date"/>
</Col>
<Col bName="" id="">
<CoreCol coreEName="SER" coreHref="../_a2.xml" corebName="Person" coreId="Manager"/>
</Col>
<Col bName="" id="">
<CoreCol coreEName="SER" coreHref="../_a2.xml" corebName="desc" coreId="desc"/>
</Col>
</table>
</ExtData>
是否可以用 XSLT 做这样的事情?