是否有人知道如何使用xslt轉換去除xml中所有子節點的內容。使用xslt清除xml中的所有子節點和節點值
源代碼
<TotalResponse id="TE2146D7766F24FE683090325091EE0B4">
<TotalCovIA27_CrimeResponse id="T8550FBBC76364CA699158D4087059F9A">
<CovIA27_CrimeResponse>
<instance>
<CovGroupType>i8BE0F604FF6F44AEB3C36271DCBB7204</CovGroupType>
<CovID>r67F85BB6345E4D3893C25D1B47FA7E32</CovID>
<CovType>add</CovType>
</instance>
</CovIA27_CrimeResponse>
</TotalCovIA27_CrimeResponse>
<TotalCovIA28_CrimeResponse id="T257F4902E7214C58ABD9258860CB6C24">
<CovIA28_CrimeResponse>
<instance>
<CovGroupType>i2880CCCAB9D045A3A7FFFCB6AE0C05C7</CovGroupType>
<CovID>rED310B0934534A8BA1CA2B5CB0BA77E5</CovID>
<CovType>modify</CovType>
</instance>
<change>
<ChangeFieldID>IA28ForgeryAndAlterationInput.Limit</ChangeFieldID>
<ChangeNewValue>131334</ChangeNewValue>
</change>
</CovIA28_CrimeResponse>
</TotalCovIA28_CrimeResponse>
</TotalResponse>
預期輸出1
<TotalResponse id="TE2146D7766F24FE683090325091EE0B4">
<TotalCovIA27_CrimeResponse id="T8550FBBC76364CA699158D4087059F9A">
<CovIA27_CrimeResponse>
<instance>
<CovGroupType></CovGroupType>
<CovID></CovID>
<CovType></CovType>
</instance>
</CovIA27_CrimeResponse>
</TotalCovIA27_CrimeResponse>
<TotalCovIA28_CrimeResponse id="T257F4902E7214C58ABD9258860CB6C24">
<CovIA28_CrimeResponse>
<instance>
<CovGroupType></CovGroupType>
<CovID></CovID>
<CovType></CovType>
</instance>
<change>
<ChangeFieldID></ChangeFieldID>
<ChangeNewValue></ChangeNewValue>
</change>
</CovIA28_CrimeResponse>
</TotalCovIA28_CrimeResponse>
</TotalResponse>
預期輸出2
<TotalResponse id="TE2146D7766F24FE683090325091EE0B4">
<TotalCovIA27_CrimeResponse id="T8550FBBC76364CA699158D4087059F9A">
<CovIA27_CrimeResponse>
<instance\>
</CovIA27_CrimeResponse>
</TotalCovIA27_CrimeResponse>
<TotalCovIA28_CrimeResponse id="T257F4902E7214C58ABD9258860CB6C24">
<CovIA28_CrimeResponse>
<instance/>
<change/>
</CovIA28_CrimeResponse>
</TotalCovIA28_CrimeResponse>
</TotalResponse>
無論是出put會滿足我的要求,但我更喜歡輸出1.
注意: Total Response是根據其他xslt的輸出而變化的動態父根名稱。
你首先必須澄清你想要的。您的(或您的XSL處理器)如何識別要修改的元素?你甚至需要識別它們嗎?例如,從文檔中去除所有'text()'節點是否可以接受?你有什麼嘗試過? –