xslt - Edit two xml files -


i have xml file this:

 <completeppcallback>  <messageid>9133235059913398501</messageid>  <keyb>keybkeybkeyb</keyb>  <filename>c:\temp\log\smkffcompleteproductionplan.xml</filename>  </completeppcallback> 

where tag 'filename' path xml file. example of file:

 <soapenv:envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>         <soapenv:body>             <ns2:completeproductionplan                 xmlns='http://servicemanagement/ois_services_v01.00/common' xmlns:ns2='http://servicemanagement/technicalordermanagement/productionfulfillment_v01.00/types'>                 <ns2:messageid>                     <value>9133235059913398501_9133235059913398860</value>                 </ns2:messageid>             </ns2:completeproductionplan>         </soapenv:body>     </soapenv:envelope> 

now need create xsl file copy second xml file , change value of messageid first xml file. this:

<xsl:stylesheet version="1.0"     xmlns:xsl="http://www.w3.org/1999/xsl/transform"     xmlns:ns2="http://servicemanagement/technicalordermanagement/productionfulfillment_v01.00/types"     xmlns:common="http://servicemanagement/ois_services_v01.00/common"     exclude-result-prefixes="ns2 common">      <xsl:output indent="yes" method="xml" encoding="utf-8" omit-xml-declaration="yes" />       <xsl:variable name="providerxmlpath">         <xsl:value-of select="//filename" />     </xsl:variable>      <xsl:variable name="providermessageid">         <xsl:value-of select="document($providerxmlpath)//ns2:messageid/common:value" />     </xsl:variable>      <copy>         <xsl:copy-of select="document($providerxmlpath)"/>      </copy>      <xsl:template match="/">         <firsttag>             <xsl:choose>                 <xsl:when test='$providermessageid=//messageid'>                     <tag>                         <xsl:text>equal</xsl:text>                     </tag>                 </xsl:when>                 <xsl:otherwise>                     <tag>                         <xsl:text>different</xsl:text>                     </tag>                 </xsl:otherwise>             </xsl:choose>         </firsttag>     </xsl:template> </xsl:stylesheet> 

how can change value of copy xml file?

edit. output xml want get:

<soapenv:envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>             <soapenv:body>                 <ns2:completeproductionplan                     xmlns='http://servicemanagement/ois_services_v01.00/common'     xmlns:ns2='http://servicemanagement/technicalordermanagement/productionfulfillment_v01.00/types'>                     <ns2:messageid>                         <value>9133235059913398501</value>                     </ns2:messageid>                 </ns2:completeproductionplan>             </soapenv:body>         </soapenv:envelope> 

second update:

now have xml: <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">     <soapenv:body>         <ns2:completeproductionplan             xmlns="http://servicemanagement/ois_services_v01.00/common"             xmlns:ns2="http://servicemanagement/technicalordermanagement/productionfulfillment_v01.00/types">             <ns2:messageid>                 <value>9133235059913398501_9133235059913398860</value>             </ns2:messageid>             <ns2:productionplan>                 <entitykey>                     <keya>9c4332b3-e60d-466b-9ab8-1187e98582e9</keya>                 </entitykey>                 <state>                     <value>readyforcompletion</value>                 </state>                 <service>                     <entitykey>                         <keyb>f51c2436-1a8e-4411-9a95-4eed04bcb412</keyb>                     </entitykey>                     <specification>                         <specificationname>access_line</specificationname>                         <specificationid>access_line</specificationid>                         <characteristic>                             <characteristicid>specificationtype</characteristicid>                             <characteristicvalue>rfs</characteristicvalue>                         </characteristic>                     </specification>                 </service>                 <service>                     <entitykey>                         <keyb>29b81be7-94e0-47e7-82f7-884ad57755d7</keyb>                     </entitykey>                     <specification>                         <specificationname>workforce_recherche</specificationname>                         <specificationid>workforce_recherche</specificationid>                         <characteristic>                             <characteristicid>specificationtype</characteristicid>                             <characteristicvalue>rfs</characteristicvalue>                         </characteristic>                     </specification>                     </service>             </ns2:productionplan>         </ns2:completeproductionplan>     </soapenv:body> </soapenv:envelope> 

i want replace value of 'keyb' tag last code example value 'keyb' tag("keybkeybkeyb") first xml example if child tag 'specificationname' equal workforce_recherche value. can identity template? have several tags 'keyb' , 'specificationname' need change 1 value properties described above.

i want get:

<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">     <soapenv:body>         <ns2:completeproductionplan             xmlns="http://servicemanagement/ois_services_v01.00/common"             xmlns:ns2="http://servicemanagement/technicalordermanagement/productionfulfillment_v01.00/types">             <ns2:messageid>                 <value>9133235059913398501</value>             </ns2:messageid>             <ns2:productionplan>                 <entitykey>                     <keya>9c4332b3-e60d-466b-9ab8-1187e98582e9</keya>                 </entitykey>                 <state>                     <value>readyforcompletion</value>                 </state>                 <service>                     <entitykey>                         <keyb>f51c2436-1a8e-4411-9a95-4eed04bcb412</keyb>                     </entitykey>                     <specification>                         <specificationname>access_line</specificationname>                         <specificationid>access_line</specificationid>                         <characteristic>                             <characteristicid>specificationtype</characteristicid>                             <characteristicvalue>rfs</characteristicvalue>                         </characteristic>                     </specification>                 </service>                 <service>                     <entitykey>                         <keyb>keybkeybkeyb</keyb>                     </entitykey>                     <specification>                         <specificationname>workforce_recherche</specificationname>                         <specificationid>workforce_recherche</specificationid>                         <characteristic>                             <characteristicid>specificationtype</characteristicid>                             <characteristicvalue>rfs</characteristicvalue>                         </characteristic>                     </specification>                     </service>             </ns2:productionplan>         </ns2:completeproductionplan>     </soapenv:body> </soapenv:envelope> 

after using copy-of there no way change thing.

therefore:
use identity transform second file.
make content of first file accessible variable (if need more 1 value this. if 1 value should changed can use variable providermessageid).
, special templates values should changed depending on first file. (e.g ns2:messageid/common:value)

try this:

<xsl:stylesheet version="1.0"     xmlns:xsl="http://www.w3.org/1999/xsl/transform"     xmlns:ns2="http://servicemanagement/technicalordermanagement/productionfulfillment_v01.00/types"     xmlns:common="http://servicemanagement/ois_services_v01.00/common"     exclude-result-prefixes="ns2 common">      <xsl:output indent="yes" method="xml" encoding="utf-8" omit-xml-declaration="yes" />      <xsl:variable name="providerxmlpath">         <xsl:value-of select="//filename" />     </xsl:variable>      <xsl:variable name="completeppcallback" select="completeppcallback" />      <xsl:variable name="providermessageid">         <xsl:value-of select="document($providerxmlpath)//ns2:messageid/common:value" />     </xsl:variable>      <xsl:template match="@*|node()">         <xsl:copy>             <xsl:apply-templates select="@*|node()"/>         </xsl:copy>     </xsl:template>      <xsl:template match="ns2:messageid/common:value">         <xsl:copy>             <xsl:value-of select="$completeppcallback/messageid"/>         </xsl:copy>     </xsl:template>      <xsl:template match="/">         <xsl:apply-templates select="document($providerxmlpath)/*" />     </xsl:template> </xsl:stylesheet> 

update generated output:

<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">     <soapenv:body>         <ns2:completeproductionplan xmlns="http://servicemanagement/ois_services_v01.00/common"                                      xmlns:ns2="http://servicemanagement/technicalordermanagement/productionfulfillment_v01.00/types">             <ns2:messageid>                 <value>9133235059913398501</value>             </ns2:messageid>         </ns2:completeproductionplan>     </soapenv:body> </soapenv:envelope> 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -