我想用X-path(/ DST / CDGCreateTreeRequest / newNode / transaction)中定义的另一个事务标记替换整个Transaction(/ DST / CDGCreateTree / DST / AWD / case / transaction) 并删除(/ DST / CDGCreateTreeRequest / newNode / transaction)的元素
你能帮我解决这个问题吗?
输入xml:
<?xml version="1.0" encoding="UTF-8"?>
<DST>
<CDGCreateTree>
<userID>%%%%%%</userID>
<password>%%%%%</password>
<hostAddress>%%%%%%%</hostAddress>
<hostPort>12955</hostPort>
<DST>
<currentJobName>PQContactComplete</currentJobName>
<AWD>
<case>
<businessArea>CSAAQA</businessArea>
<type>CALL</type>
<status>CREATED</status>
<recordType>C</recordType>
<OUID>%%%%%%</OUID>
<CKEY>2014012103.25.07.561840T01</CKEY>
<PRVC>N</PRVC>
<STRT>2014070700.28.41.043000</STRT>
<STPT>2014070711.06.43.000000</STPT>
<CMOO>Happy</CMOO>
<CMED>Phone</CMED>
<MLOB />
<FDID>ANTHONY1900</FDID>
<RMEM>ANTHONY1900</RMEM>
<transaction>
<businessArea>CSAAQA</businessArea>
<type>ISSUE</type>
<status>CREATED</status>
<worklist>false</worklist>
<recordType>T</recordType>
<CFLG>2</CFLG>
<OUID>DT77214</OUID>
<SBJT>Member</SBJT>
<ITYP>MS Care1st Member</ITYP>
<ICT1>Demographic Change</ICT1>
<ICT2>Adoption</ICT2>
<ICT3 />
<ICT4 />
<ICT5 />
<STRT>2014070710.59.00.000000</STRT>
<STPT>2014070711.04.09.000000</STPT>
<RCAL>CREATED</RCAL>
<RGRP>JK212A0001</RGRP>
<RATH />
<RMEM>ANTHONY1900</RMEM>
<RPRV>JKCCRE</RPRV>
<RCLM />
<RTYP>PCP</RTYP>
<MLOB>J9J8J701</MLOB>
<UIID>20140707110409DT77214</UIID>
<CBDS />
<CEDS />
<ABDS />
<AEDS />
<FDID>ANTHONY1900</FDID>
<comments>%%%%$%</comments>
</transaction>
</case>
</AWD>
</DST>
</CDGCreateTree>
<CDGCreateTreeRequest>
<newNode>
<transaction relate="Y" id="2014072100.50.35.618900T01">
<id>2014072100.50.35.618900T01</id>
<createTime time="Y">20140721T00:50:35:61890005:00</createTime>
<businessArea>CSAAQA</businessArea>
<type>ISSUE</type>
<workStep status="TOVBR">VBR Labeling</workStep>
<status>TOVBR</status>
<queue>SYSTEM</queue>
<priority>999</priority>
<priorityIncrease>0</priorityIncrease>
<VIP>N</VIP>
<assignedTo>SYSTEM</assignedTo>
<lockedBy>SYSTEM</lockedBy>
<amount>0.0000</amount>
<amountType />
<suspended>N</suspended>
<process>Y</process>
<customScreen>WRKXMPL</customScreen>
<iconName />
<FDID>ANTHONY1900</FDID>
<ICT1>Demographic Change</ICT1>
<ICT2>Adoption</ICT2>
<ITYP>MS Care1st Member</ITYP>
<MLOB>J9J8J701</MLOB>
<OUID>DT77214</OUID>
<RCAL>CREATED</RCAL>
<RGRP>JK212A0001</RGRP>
<RMEM>ANTHONY1900</RMEM>
<RPRV>JKCCRE</RPRV>
<RTYP>PCP</RTYP>
<SBJT>Member</SBJT>
<STPT>2014070711.04.09.000000</STPT>
<STRT>2014070710.59.00.000000</STRT>
<UIID>20140707110409DT77214</UIID>
<CFLG>2</CFLG>
<permission>Update</permission>
<externalSystem>
<host />
<executable />
<parameters />
<procedure />
</externalSystem>
<commentsExist>Y</commentsExist>
</transaction>
</newNode>
</CDGCreateTreeRequest>
</DST>
Expected xml:
<?xml version="1.0" encoding="UTF-8"?>
<DST>
<CDGCreateTree>
<userID>%%%%%%</userID>
<password>%%%%%</password>
<hostAddress>%%%%%%%</hostAddress>
<hostPort>12955</hostPort>
<DST>
<currentJobName>PQContactComplete</currentJobName>
<AWD>
<case>
<businessArea>CSAAQA</businessArea>
<type>CALL</type>
<status>CREATED</status>
<recordType>C</recordType>
<OUID>%%%%%%</OUID>
<CKEY>2014012103.25.07.561840T01</CKEY>
<PRVC>N</PRVC>
<STRT>2014070700.28.41.043000</STRT>
<STPT>2014070711.06.43.000000</STPT>
<CMOO>Happy</CMOO>
<CMED>Phone</CMED>
<MLOB />
<FDID>ANTHONY1900</FDID>
<RMEM>ANTHONY1900</RMEM>
<transaction relate="Y" id="2014072100.50.35.618900T01">
<id>2014072100.50.35.618900T01</id>
<createTime time="Y">20140721T00:50:35:61890005:00</createTime>
<businessArea>CSAAQA</businessArea>
<type>ISSUE</type>
<workStep status="TOVBR">VBR Labeling</workStep>
<status>TOVBR</status>
<queue>SYSTEM</queue>
<priority>999</priority>
<priorityIncrease>0</priorityIncrease>
<VIP>N</VIP>
<assignedTo>SYSTEM</assignedTo>
<lockedBy>SYSTEM</lockedBy>
<amount>0.0000</amount>
<amountType />
<suspended>N</suspended>
<process>Y</process>
<customScreen>WRKXMPL</customScreen>
<iconName />
<FDID>ANTHONY1900</FDID>
<ICT1>Demographic Change</ICT1>
<ICT2>Adoption</ICT2>
<ITYP>MS Care1st Member</ITYP>
<MLOB>J9J8J701</MLOB>
<OUID>DT77214</OUID>
<RCAL>CREATED</RCAL>
<RGRP>JK212A0001</RGRP>
<RMEM>ANTHONY1900</RMEM>
<RPRV>JKCCRE</RPRV>
<RTYP>PCP</RTYP>
<SBJT>Member</SBJT>
<STPT>2014070711.04.09.000000</STPT>
<STRT>2014070710.59.00.000000</STRT>
<UIID>20140707110409DT77214</UIID>
<CFLG>2</CFLG>
<permission>Update</permission>
<externalSystem>
<host />
<executable />
<parameters />
<procedure />
</externalSystem>
<commentsExist>Y</commentsExist>
</transaction>
</case>
</AWD>
</DST>
</CDGCreateTree>
<CDGCreateTreeRequest>
<newNode/>
</CDGCreateTreeRequest>
</DST>
答案 0 :(得分:0)
尝试这样的事情:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:variable name="targetNode" select="DST/CDGCreateTreeRequest/newNode/transaction"/>
<xsl:template match="transaction[not(ancestor::newNode)]">
<xsl:copy-of select="$targetNode"/>
</xsl:template>
<xsl:template match="transaction[ancestor::newNode]"/>
<xsl:template match="newNode">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>