由此:
<cs:message xmlns:cs="http://www.URL.ru">
<cs:header app-from="sql2" app-to="common/send-outgoing-message"
correlation-id="ID:10424982-83.139.14.107(f4:d7:e7:30:bf:fb)-61573-1554201529201"
destination="re1"
message-id="ID:10425004-83.139.14.107(f4:d7:e7:30:bf:fb)-61573-1554201529551"
submit-timestamp="2019-04-02 14:38:49" type="Status"/>
<cs:status status="Executed">
<cs:param name="Result" type="XML">
<cs:value>
<records>
<record number="1">
<ID>458161462</ID>
<SERVICE_ID>612911</SERVICE_ID>
<MSISDN>37477704529</MSISDN>
<BODY><mdata
data="000000DD000000040000000010B51C920005005768617473417070000101333734373737303435323900030000003139303430323130343834363030302B0001000000993C233E20596F757220576861747341707020636F64653A203937332D3735350A0A596F752063616E20616C736F20746170206F6E2074686973206C696E6B20746F2076657269667920796F75722070686F6E653A20762E77686174736170702E636F6D2F3937333735350A0A446F6E2774207368617265207468697320636F64652077697468206F74686572730A3473674C71317035735636"
description="(#) Your WhatsApp code: 973-755 You can also tap on this
link to verify your phone: v.whatsapp.com/973755 Don't share this code
with others 4sgLq1p5sV6"/></BODY>
<PRIORITY>1</PRIORITY>
<DELIVERY_REPORT>0</DELIVERY_REPORT>
<SPLITTING>null</SPLITTING>
<PREFERRED_MODULE_NAME>lcrrouter1</PREFERRED_MODULE_NAME>
<PREFERRED_USER_FROM>WhatsApp</PREFERRED_USER_FROM>
<STATUS_ID>0</STATUS_ID>
<TRANSMISSION_TRIALS>0</TRANSMISSION_TRIALS>
<IN_SMS_EXT_ID>null</IN_SMS_EXT_ID>
<CHARGING>null</CHARGING>
<WCS_CONTENT_TYPE_ID>12</WCS_CONTENT_TYPE_ID>
<FLASH_SMS>0</FLASH_SMS>
<ENCODING>0</ENCODING>
<PARTNER_CHARGE>0</PARTNER_CHARGE>
<PARTNER_ID>21927</PARTNER_ID>
</record>
<record number="2">
<ID>458161464</ID>
<SERVICE_ID>638118</SERVICE_ID>
<MSISDN>37493765423</MSISDN>
<BODY>Mekangamya ogtagorcman kod - 3137</BODY>
<PRIORITY>1</PRIORITY>
<DELIVERY_REPORT>1</DELIVERY_REPORT>
<SPLITTING>null</SPLITTING>
<PREFERRED_MODULE_NAME>armentel-smpp</PREFERRED_MODULE_NAME>
<PREFERRED_USER_FROM>9999</PREFERRED_USER_FROM>
<STATUS_ID>0</STATUS_ID>
<TRANSMISSION_TRIALS>0</TRANSMISSION_TRIALS>
<IN_SMS_EXT_ID>12345</IN_SMS_EXT_ID>
<CHARGING>1</CHARGING>
<WCS_CONTENT_TYPE_ID>10</WCS_CONTENT_TYPE_ID>
<FLASH_SMS>0</FLASH_SMS>
<ENCODING>0</ENCODING>
<PARTNER_CHARGE>0</PARTNER_CHARGE>
<PARTNER_ID>20148</PARTNER_ID>
</record>
</records>
</cs:value>
</cs:param>
</cs:status>
</cs:message>
你需要这样做:
<cs:messages xmlns:cs="http://www.URL.ru">
<cs:message xmlns:cs="http://www.URL.ru">
<cs:header charging="false" content-type="SubmitSM" delivery-notification-requested="false" data="000000DD000000040000000010B51C920005005768617473417070000101333734373737303435323900030000003139303430323130343834363030302B0001000000993C233E20596F757220576861747341707020636F64653A203937332D3735350A0A596F752063616E20616C736F20746170206F6E2074686973206C696E6B20746F2076657269667920796F75722070686F6E653A20762E77686174736170702E636F6D2F3937333735350A0A446F6E2774207368617265207468697320636F64652077697468206F74686572730A3473674C71317035735636"
description="(#) Your WhatsApp code: 973-755 You can also tap on this link to verify your phone: v.whatsapp.com/973755 Don't share this code with others 4sgLq1p5sV6" destination="lcrrouter1" direct-display="false"
out-sms-id="458161462" partner-id="21927" priority="1" real-module-name="lcrrouter1"
reply-to="@re-stat$common|Transmitted@re-stat-transmitted$common" service-id="612911"
source-ton="5" type="User" user-from="WhatsApp" user-to="37477704529"/>
<cs:body>000000DD000000040000000010B51C920005005768617473417070000101333734373737303435323900030000003139303430323130343834363030302B0001000000993C233E20596F757220576861747341707020636F64653A203937332D3735350A0A596F752063616E20616C736F20746170206F6E2074686973206C696E6B20746F2076657269667920796F75722070686F6E653A20762E77686174736170702E636F6D2F3937333735350A0A446F6E2774207368617265207468697320636F64652077697468206F74686572730A3473674C71317035735636</cs:body>
</cs:message>
<cs:message xmlns:cs="http://www.wsoft.ru">
<cs:header charging="true" content-type="PlainText" delivery-notification-requested="true"
destination="armentel-smpp" direct-display="false"
out-sms-id="458161464" partner-id="20148" priority="1" real-module-name="armentel-smpp"
reply-to="@re-stat$common|Transmitted@re-stat-transmitted$common" service-id="638118"
source-ton="0" type="User" user-from="9999" user-to="37493765423#12345"/>
<cs:body>Mekangamya ogtagorcman kod - 3137</cs:body>
</cs:message>
</cs:messages>
我只设法显示第一个文档中的值,但我不明白如何删除不必要的数据(例如 SPLITTING、SERVICE_ID,这些数据不在应该获取的文档中) ,如何更改现有数据,例如原始文档中的 CHARGING NULL ,以及所需的 =true )以及如何添加正文和标题。
我的代码:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8"/>
<xsl:template match="record">
<xsl:copy>
<xsl:for-each select="*">
<xsl:attribute name="{local-name(.)}">
<xsl:value-of select="."/>
</xsl:attribute>
<xsl:variable name="elem-name" select="local-name(.)"/>
<xsl:for-each select="@*">
<xsl:attribute name="{concat($elem-name,'-',local-name(.))}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
这是 XSLT 2.0 中的实现。
您可能需要调整 XSLT 以满足您的需要。
属性在 XML 元素中是唯一的。他们没有排序或位置的概念。
为此,我
$elem-name
向 XSLT 添加了一个变量。输入 XML
XSLT 2.0
输出 XML