我有一组通用的标签,需要用不同的包装元素包装。示例输入 XML 就像 -
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<a>Hello there</a>
<code>FJ-123-99</code>
<isPopular>True</isPopular>
<timestamp>2019-10-17 07:57:23</timestamp>
<pop>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<about>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</about>
</pop>
<classic>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<about>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</about>
</classic>
<retro>
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<about>
<company>RCA</company>
<price>9.90</price>
<year>1982</year>
</about>
</retro>
</catalog>
样本输出
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<a type="primary">Hello there</a>
<typeCode>FJ12399</typeCode>
<isPopular>Y</isPopular>
<timestamp>20191017:075723</timestamp>
<pop>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<about>
<organization>Columbia</organization>
<amount>10.90</amount>
<releaseTime>1985</releaseTime>
</about>
</pop>
<classic>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<about>
<organization>CBS Records</organization>
<amount>9.90</amount>
<releaseTime>1988</releaseTime>
</about>
</classic>
<retro>
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<about>
<organization>USA</organization>
<amount>9.90</amount>
<releaseTime>1982</releaseTime>
</about>
</retro>
</catalog>
在这里,<title>
<artist>
和对于像和<about>
之类的主要包装器很常见。<pop>
<retro>
<classic>
我的问题是如何将这些通用模板应用到我的主要包装器中,我能够进行所有转换,例如转换时间戳、删除连字符、更改标签名称。