on 01-09-2023 1:40 PM
Hi Expert.
I want to copy xml node and update value on specific element from higher same node name using xslt mapping.
original data
<S_QTY> <C_C186> <D_6063>21</D_6063> <D_6060>1</D_6060> </C_C186> </S_QTY>
expect outcome
<S_QTY> <C_C186> <D_6063>21</D_6063> <D_6060>1</D_6060> </C_C186> </S_QTY>
<S_QTY> <C_C186> <D_6063>12</D_6063> <D_6060>1</D_6060> ---> D_6060 field should be copy value above D_6060.
</C_C186>
</S_QTY>
Below is my xslt code
<xsl:template match="S_QTY"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> <S_QTY> <C_C186> <D_6063>21</D_6063> <xsl:variable name="v3" select="string(S_QTY/C_C186/D_6063/D_6060/text())='12'" /> <xsl:if test="string($v3)='true'"> <D_6060> <xsl:value-of select="S_QTY/C_C186/D_6063/D_6060/text()" /> </D_6060> </xsl:if> </C_C186> </S_QTY> </xsl:template>
D_6060 value was not updated as below.
<S_QTY> <C_C186> <D_6063>21</D_6063> <D_6060>1</D_6060> </C_C186> </S_QTY>
<S_QTY> <C_C186> <D_6063>12</D_6063> <D_6060></D_6060> ---> D_6060 field should be copy value above D_6060.
</C_C186>
</S_QTY>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
65 | |
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.