gpt4 book ai didi

xslt - 如何使用 XSLT 向 XML 负载添加不同的 namespace

转载 作者:行者123 更新时间:2023-12-04 17:05:40 26 4
gpt4 key购买 nike

我有一个简单的 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>

关于xslt - 如何使用 XSLT 向 XML 负载添加不同的 namespace ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64677264/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com