2016-07-08 14 views
-1

私はXSLTを使用してプロジェクトでxml応答を変換しています。XSLTを使用してxmlns、SOAP:Envelope、SOAP:Body、xmlからXSLTを使用して

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
    <SOAP:Body> 
     <response:performJobResponse xmlns:response="http://tempuri.org/" SOAP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
     <whiteboard> 
      <PQ> 
       <SOAP:Envelope SOAP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
        <SOAP:Body> 
        <response:performJobResponse SOAP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
         <whiteboard> 
          <PQ> 
           <SOAP:Envelope SOAP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
           <SOAP:Body> 
            <performJob loadfromcache="yes"> 
             <jobName>PQIssueUpdate</jobName> 
             <whiteboard> 
              <PQ> 
              <PQContact> 
               <userID>Test</userID> 
               <password>[email protected]</password> 
              </PQContact> 
              <workflowStatusComment> 
               <comment>Issue released. Routing Status changed from CATCHALL to Pharmancy. Issue updated by user DT76747.</comment> 
              </workflowStatusComment> 
              </PQ> 
             </whiteboard> 
             <requestNodeName>//PQ</requestNodeName> 
             <responseNodeName>//PQ</responseNodeName> 
             <jobDB> 
              <name>PQCustomerService</name> 
              <userID>sa</userID> 
              <password>password</password> 
             </jobDB> 
            </performJob> 
           </SOAP:Body> 
           <response> 
            <DST xml:lang="en-US"> 
             <jobName version="1.0">SRVChangeLock</jobName> 
             <trace>0</trace> 
             <readable>N</readable> 
             <AWD> 
              <userID>DT76747</userID> 
              <password>Removed for security purposes</password> 
              <transaction id="2016-07-07-02.02.19.127220T01"> 
              <createTime time="Y">2016-07-07T02:02:19:127220-05:00</createTime> 
              <assignedTo>DT76747</assignedTo> 
              <lockedBy>DT76747</lockedBy> 
              <customScreen>WRKXMPL</customScreen> 
              <workflow route="Status"> 
               <workStep status="_NEXT" next="Y" /> 
              </workflow> 
              </transaction> 
             </AWD> 
             <jobVersion>1.0</jobVersion> 
             <jobReturn jobName="SRV00017"> 
              <taskName /> 
              <description /> 
              <value>0</value> 
             </jobReturn> 
            </DST> 
           </response> 
           </SOAP:Envelope> 
          </PQ> 
         </whiteboard> 
        </response:performJobResponse> 
        </SOAP:Body> 
        <response> 
        <DST xml:lang="en-US"> 
         <jobName version="1.0">SRVObjectUpdate</jobName> 
         <trace>0</trace> 
         <readable>N</readable> 
         <AWD> 
          <userID>DT76747</userID> 
          <password>Removed for security purposes</password> 
          <transaction id="2016-07-07-02.02.19.127220T01" workSelected="false" hasChildWork="N" children="N" hasParent="Y" hasParentCase="Y" hasChildSource="N"> 
           <id>2016-07-07-02.02.19.127220T01</id> 
          </transaction> 
         </AWD> 
        </DST> 
        </response> 
       </SOAP:Envelope> 
      </PQ> 
     </whiteboard> 
     <jobReturn> 
      <value>0</value> 
     </jobReturn> 
     </response:performJobResponse> 
    </SOAP:Body> 
</SOAP:Envelope> 

私はすべてのxmlnsコンテンツ、SOAP:Envelope<SOAP:Body><response>タグに関連するコンテンツを削除したいです。

私の最後のXMLは以下のようにする必要があります:

<?xml version="1.0" encoding="UTF-8"?> 
<PQ> 
    <PQContact> 
     <userID>Test</userID> 
     <password>[email protected]</password> 
    </PQContact> 
    <workflowStatusComment> 
     <comment>Issue released. Routing Status changed from CATCHALL to Pharmancy. Issue updated by user DT76747.</comment> 
    </workflowStatusComment> 
</PQ> 

は、あなたが私を助けていただけますか?

+0

私は自分自身を修正することができるように、人々は、彼らが投票ダウンしている理由を私に知らせている場合それは素晴らしいことです。 –

答えて

1

してください、この変換を試してみてください。

<?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:response="http://tempuri.org/"> 

    <xsl:output method="xml" encoding="UTF-8" indent="yes"/> 

    <xsl:strip-space elements="*"/> 

    <xsl:template match="/"> 
     <xsl:apply-templates select="//SOAP:Body/performJob//whiteboard/node()"/> 
    </xsl:template> 

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

    <xsl:template match="@*"> 
     <xsl:copy/> 
    </xsl:template> 
</xsl:stylesheet> 
+0

これは完璧です! –

関連する問題