0
对于XSLT来说非常新颖,并且在转换XML时需要一些帮助。以下XML可以有多个“行”标签XSLT通过重复节点将节点中的值复制到另一节点
<?xml version="1.0" encoding="UTF-8"?>
<ns1:row>
<ns1:City>BALTIMORE</ns1:City>
<ns1:Miscdata>
<ns1:Building>
<ns1:VendorCode>123</ns1:VendorCode>
<ns1:Value>2</ns1:Value>
</ns1:Building>
<ns1:Building>
<ns1:VendorCode>345</ns1:VendorCode>
<ns1:Value>8</ns1:Value>
</ns1:Building>
</ns1:Miscdata>
</ns1:row>
<ns1:row>
<ns1:City>FREMONT</ns1:City>
<ns1:Miscdata>
<ns1:Building>
<ns1:VendorCode>332</ns1:VendorCode>
<ns1:Value>4</ns1:Value>
</ns1:Building>
<ns1:Building>
<ns1:VendorCode>342</ns1:VendorCode>
<ns1:Value>14</ns1:Value>
</ns1:Building>
<ns1:Building>
<ns1:VendorCode>323</ns1:VendorCode>
<ns1:Value>233</ns1:Value>
</ns1:Building>
</ns1:Miscdata>
</ns1:row>
上述XML中“VendorCode”标签中的值需要复制到“Value”标签。输出XML是
<?xml version="1.0" encoding="UTF-8"?>
<ns1:row>
<ns1:City>BALTIMORE</ns1:City>
<ns1:Miscdata>
<ns1:Building>
<ns1:VendorCode>123</ns1:VendorCode>
<ns1:Value>123</ns1:Value>
</ns1:Building>
<ns1:Building>
<ns1:VendorCode>345</ns1:VendorCode>
<ns1:Value>345</ns1:Value>
</ns1:Building>
</ns1:Miscdata>
</ns1:row>
<ns1:row>
<ns1:City>FREMONT</ns1:City>
<ns1:Miscdata>
<ns1:Building>
<ns1:VendorCode>332</ns1:VendorCode>
<ns1:Value>332</ns1:Value>
</ns1:Building>
<ns1:Building>
<ns1:VendorCode>342</ns1:VendorCode>
<ns1:Value>342</ns1:Value>
</ns1:Building>
<ns1:Building>
<ns1:VendorCode>323</ns1:VendorCode>
<ns1:Value>323</ns1:Value>
</ns1:Building>
</ns1:Miscdata>
</ns1:row>
非常感谢你马丁。有效! –