我有以下XML:
<Metro>
<MeasurementList>
<Measurement>
<MeasurementX>
<Prop1>bla</Prop1>
<AcqSettingsRef>#1212</AcqSettingsRef>
</MeasurementX>
<MeasurementY>
<Prop1>bla</Prop1>
<AcqSettingsRef>#1213</AcqSettingsRef>
</MeasurementY>
</Measurement>
<Measurement>
<MeasurementX>
<Prop1>bla</Prop1>
<AcqSettingsRef>#1212</AcqSettingsRef>
</MeasurementX>
<MeasurementY>
<Prop1>bla</Prop1>
<AcqSettingsRef>#1214</AcqSettingsRef>
</MeasurementY>
</Measurement>
<Measurement>
<MeasurementX>
<Prop1>bla</Prop1>
<AcqSettingsRef>#1215</AcqSettingsRef>
</MeasurementX>
<MeasurementY>
<Prop1>bla</Prop1>
<AcqSettingsRef>#1216</AcqSettingsRef>
</MeasurementY>
</Measurement>
</MeasurementList>
<References>
<AcqSettings>
<Id>1212</Id>
<Prop2>bla</Prop2>
<Prop3>bla33</Prop3>
</AcqSettings>
<AcqSettings>
<Id>1213</Id>
<Prop2>bla</Prop2>
<Prop3>bla34</Prop3>
</AcqSettings>
<AcqSettings>
<Id>1214</Id>
<Prop2>bla</Prop2>
<Prop3>bla35</Prop3>
</AcqSettings>
<AcqSettings>
<Id>1215</Id>
<Prop2>bla</Prop2>
<Prop3>bla36</Prop3>
</AcqSettings>
<AcqSettings>
<Id>1216</Id>
<Prop2>bla</Prop2>
</AcqSettings>
</References>
</Metro>
我必须将<Prop3>
内的<AcqSettings>
标签移动到它自己的元素标签并添加一个ID
。还必须将此ID
添加到另一个元素中,以便将它们链接起来。另外,<Prop3>
可能不存在,并且一个<AcqSettings>
可能具有多个链接。
期望的文件应该是这个。
<Metro>
<MeasurementList>
<Measurement>
<MeasurementX>
<Prop1>bla<Prop1>
<AcqSettingsRef>#1212</AcqSettingsRef>
<SensSettingsRef>#33</SensSettingsRef>
</MeasurementX>
<MeasurementY>
<Prop1>bla<Prop1>
<AcqSettingsRef>#1213</AcqSettingsRef>
<SensSettingsRef>#34</SensSettingsRef>
</MeasurementY>
</Measurement>
<Measurement>
<MeasurementX>
<Prop1>bla<Prop1>
<AcqSettingsRef>#1212</AcqSettingsRef>
<SensSettingsRef>#33</SensSettingsRef>
</MeasurementX>
<MeasurementY>
<Prop1>bla<Prop1>
<AcqSettingsRef>#1214</AcqSettingsRef>
<SensSettingsRef>#35</SensSettingsRef>
</MeasurementY>
</Measurement>
<Measurement>
<MeasurementX>
<Prop1>bla<Prop1>
<AcqSettingsRef>#1215</AcqSettingsRef>
<SensSettingsRef>#36</SensSettingsRef>
</MeasurementX>
<MeasurementY>
<Prop1>bla<Prop1>
<AcqSettingsRef>#1216</AcqSettingsRef>
</MeasurementY>
</Measurement>
</MeasurementList>
<References>
<AcqSettings>
<Id>1212</Id>
<Prop2>bla<Prop2>
</AcqSettings>
<AcqSettings>
<Id>1213</Id>
<Prop2>bla<Prop2>
</AcqSettings>
<AcqSettings>
<Id>1214</Id>
<Prop2>bla<Prop2>
</AcqSettings>
<AcqSettings>
<Id>1215</Id>
<Prop2>bla<Prop2>
</AcqSettings>
<AcqSettings>
<Id>1216</Id>
<Prop2>bla<Prop2>
</AcqSettings>
<SensSettings>
<Id>33</Id>
<Prop3>bla33<Prop3>
</SensSettings>
<SensSettings>
<Id>34</Id>
<Prop3>bla34<Prop3>
</SensSettings>
<SensSettings>
<Id>35</Id>
<Prop3>bla35<Prop3>
</SensSettings>
<SensSettings>
<Id>36</Id>
<Prop3>bla36<Prop3>
</SensSettings>
</References>
</Metro>
我可以使用'generate-id'生成ID
,但是我不确定如何将其添加到新元素和<MeasurementX/Y>
元素中以进行链接。另外,这必须在XSLT版本1中完成。