如何使用 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>[email protected]</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>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章