XML : Concatenation of node values based on a condition in XSLT

I have the following xml.

  <?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>                 <response>                    <PQIssueHistory>                       <AWD10SP7_1orhigher>Y</AWD10SP7_1orhigher>                       <hostAddress>10.193.XXX.78</hostAddress>                       <hostPort>12955</hostPort>                       <userID>7X606</userID>                       <password>Qfgjf@123</password>                       <issue>                          <CRDATTIM>2015-07-29-04.27.15.461040</CRDATTIM>                          <RECORDCD>T</RECORDCD>                          <CRNODE>01</CRNODE>                          <ORIGUSERID>DT77214</ORIGUSERID>                       </issue>                    </PQIssueHistory>                    <results>                       <row>                          <RECTYP>HISTORY</RECTYP>                       </row>                       <row>                          <date>2015-08-18</date>                          <time>04:04:58-05:00</time>                       </row>                    </results>                 </response>              </PQ>           </whiteboard>           <jobReturn>              <taskName>TransformNode</taskName>              <description>TransformNode Succeeded</description>              <value>0</value>           </jobReturn>        </response:performJobResponse>     </SOAP:Body>  </SOAP:Envelope>    

I need to check whether any <row> has <date> and <time>, if so, I need to concatenate the values of <date> and <time> and assign the newly generated value to a new tag <CRDATTIM> </CRDATTIM>.

For example: <CRDATTIM>2015-08-18-04:04:58-05:00</CRDATTIM>

Final resultant xml should be as below:

    <?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>                 <response>                    <PQIssueHistory>                       <AWD10SP7_1orhigher>Y</AWD10SP7_1orhigher>                       <hostAddress>10.193.XXX.78</hostAddress>                       <hostPort>12955</hostPort>                       <userID>7X606</userID>                       <password>Qfgjf@123</password>                       <issue>                          <CRDATTIM>2015-07-29-04.27.15.461040</CRDATTIM>                          <RECORDCD>T</RECORDCD>                          <CRNODE>01</CRNODE>                          <ORIGUSERID>DT77214</ORIGUSERID>                       </issue>                    </PQIssueHistory>                    <results>                       <row>                          <RECTYP>HISTORY</RECTYP>                       </row>                       <row>                          <CRDATTIM>2015-08-18-04:04:58-05:00</CRDATTIM>                       </row>                    </results>                 </response>              </PQ>           </whiteboard>           <jobReturn>              <taskName>TransformNode</taskName>              <description>TransformNode Succeeded</description>              <value>0</value>           </jobReturn>        </response:performJobResponse>     </SOAP:Body>  </SOAP:Envelope>    

No comments:

Post a Comment