如何使用XSLT将不同的名称空间添加到XML负载中



我有一个简单的XML Payload请求,我需要添加多个命名空间。我试了很多,但运气不好。你能帮助如何转换XML请求吗,

有效载荷

<insert>
<u_email_domain>Test.eu</u_email_domain>
<u_cost_center>costcenter123</u_cost_center>
<u_department>ItDepartment</u_department>
<u_family_name>Donald</u_family_name>
<u_first_name>Trump</u_first_name>
<u_foreseen_end_date/>
<u_hris_id>1000091</u_hris_id>
<u_job_title>Manager</u_job_title>
<u_location>newyork</u_location>
<u_manager_hris_id>10000421</u_manager_hris_id>
<u_notification_recipients>dummy@email.com</u_notification_recipients>
<u_vip>NO</u_vip>
</insert>

预期结果

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://www.service-now.com/u_hr_is">
<soapenv:Body>
<u:insert>
<u:u_email_domain>Test.eu</u:u_email_domain>
<u:u_cost_center>costcenter123</u:u_cost_center>
<u:u_department>ItDepartment</u:u_department>
<u:u_family_name>Donald</u:u_family_name>
<u:u_first_name>Trump</u:u_first_name>
<u:u_hris_id>1000091</u:u_hris_id>
<u:u_job_title>Manager</u:u_job_title>
<u:u_location>newyork</u:u_location>
<u:u_manager_hris_id>10000421</u:u_manager_hris_id>
<u:u_vip>NO</u:u_vip>
</u:insert>
</soapenv:Body>`enter code here`
</soapenv:Envelope>

Try this:
<?xml version="1.0"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="/insert">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://www.service-now.com/u_hr_is">
<soapenv:Body>
<u:insert>
<u:u_email_domain>
<xsl:value-of select="u_email_domain"/>
</u:u_email_domain>
<u:u_cost_center>
<xsl:value-of select="u_cost_center"/>
</u:u_cost_center>
<u:u_department>
<xsl:value-of select="u_department"/>
</u:u_department>
<u:u_family_name>
<xsl:value-of select="u_family_name"/>
</u:u_family_name>
<u:u_first_name>
<xsl:value-of select="u_first_name"/>
</u:u_first_name>
<u:u_hris_id>
<xsl:value-of select="u_hris_id"/>
</u:u_hris_id>
<u:u_job_title>
<xsl:value-of select="u_job_title"/>
</u:u_job_title>
<u:u_location>
<xsl:value-of select="u_location"/>
</u:u_location>
<u:u_manager_hris_id>
<xsl:value-of select="u_manager_hris_id"/>
</u:u_manager_hris_id>
<u:u_vip>
<xsl:value-of select="u_vip"/>
</u:u_vip>
</u:insert>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
</xsl:stylesheet>

最新更新