1

SOAP 環境から XML をコピーしようとしていますが、これを正常に完了することができました。次に、すべての XMLNS を削除したいと思いますが、これも正常に完了することができました。ただし、XML ペイロードの途中から XSI 属性を選択し、XSI=TYPE フィールドのコンテンツを含む新しいフィールドを XML に作成しようとしています。私がやろうとしていることを示します:

サンプル XML:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <notifications xmlns="http://soap.sforce.com/2005/09/outbound">
            <ActionId>04kf000000000FfAAI</ActionId>
            <SessionId xsi:nil="true"/>
            <Notification>
                <Id>04lf00000000xvQAAQ</Id>
                <sObject xsi:type="sf:Account" xmlns:sf="urn:sobject">
                    <sf:Id>001f0000006UzdCAAS</sf:Id>
                    <sf:Customer_Number__c>dummy1234</sf:Customer_Number__c>
                    <sf:FirstName>Test</sf:FirstName>
                    <sf:LastModifiedDate>2012-10-15T10:59:54.000Z</sf:LastModifiedDate>
                    <sf:LastName>Test</sf:LastName>
                </sObject>
            </Notification>
        </notifications>
    </soapenv:Body>
</soapenv:Envelope>

現在の XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:r="http://soap.sforce.com/2005/09/outbound"
    exclude-result-prefixes="r">

    <xsl:output method="xml" indent="yes"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="/">
        <xsl:apply-templates select="/soap:Envelope//r:notifications"/>
    </xsl:template>

    <xsl:template match ="*" >
        <xsl:element name ="{local-name()}" >
            <xsl:apply-templates select ="@* | node()" />
        </xsl:element>
    </xsl:template>

</xsl:stylesheet>

出力:

<?xml version="1.0" encoding="utf-8"?>
<notifications>
   <ActionId>04kf000000000FfAAI</ActionId>
   <SessionId>true</SessionId>
   <Notification>
      <Id>04lf00000000xvQAAQ</Id>
      <sObject>tableName<Id>001f0000006UzdCAAS</Id>
         <Customer_Number__c>dummy1234</Customer_Number__c>
         <FirstName>Test</FirstName>
         <LastModifiedDate>2012-10-15T10:59:54.000Z</LastModifiedDate>
         <LastName>Test</LastName>
      </sObject>
   </Notification>
</notifications>

XSI:TYPE のコンテンツを sObject に入れるだけなので、これは正しくありません。たとえば、これが目的の出力である独自のフィールドが必要です。

<?xml version="1.0" encoding="utf-8"?>
<notifications>
   <ActionId>04kf000000000FfAAI</ActionId>
   <SessionId>true</SessionId>
   <Notification>
      <Id>04lf00000000xvQAAQ</Id>
      <sObject>
         <tableName>tableName</tableName>
         <Id>001f0000006UzdCAAS</Id>
         <Customer_Number__c>dummy1234</Customer_Number__c>
         <FirstName>Test</FirstName>
         <LastModifiedDate>2012-10-15T10:59:54.000Z</LastModifiedDate>
         <LastName>Test</LastName>
      </sObject>
   </Notification>
</notifications>
4

1 に答える 1