如果input.xml具有键值对,则这可能是大文件,因此运行时输出应该生成键成为输出标记名称,值将是使用xslt的值 Input.xml文件
<keyValueStr>
<key>memberId </key>
<value>12345</value>
</keyValueStr>
<keyValueStr>
<key>mbrAccountNumber</key>
<value>CO12345</value>
</keyValueStr>
<keyValueStr>
<key>grId</key>
<value>4568667</value>
</keyValueStr>
<keyValueStr>
<key>abc </key>
<value>111111</value>
</keyValueStr>
<keyValueStr>
<key>def</key>
<value>22222</value>
</keyValueStr>
<keyValueStr>
<key>ghi</key>
<value>33333</value>
</keyValueStr>
**output should like this:**
<memberMinimumInfoRequest>
<memberid>12345</memberId>
<mbrAccountNumber>CO12345</mbrAccountNumber>
<grId>4568667</grId>
<abc>111111</abc>
<def>22222</def>
<ghi>33333</ghi>
</memberMinimumInfoRequest>
答案 0 :(得分:0)
如果每个成员的信息都以MemberId
键开头,那么在包含元素的模板中,您可以使用xsl:for-each-group
(http://www.w3.org/TR/xslt20/#xsl-for-each-group)来选择每个成员。信息和处理它,例如:
<xsl:for-each-group select="keyValueStr"
group-starting-with="keyValueStr[. eq 'memberId ']">
<memberMinimumInfoRequest>
<xsl:apply-templates select="current-group()" />
</memberMinimumInfoRequest>
</xsl:for-each-group>
(&#39; memberId&#39;?)
中是否应该有空格?