I am new to xslt, Can some one help me to this scenario. If both field values are same clear one filed value. below scenario First EMP EE_WORKMOBPH should not have any value in return.
`
<?xml version="1.0" encoding="UTF-8"?>
<root>
<emp>
<EE_WORKMOBPH>123</EE_WORKMOBPH>
<EE_MOBPH>123</EE_MOBPH>
</emp>
<emp>
<EE_WORKPH>345</EE_WORKPH>
<EE_WORKMOBPH>678</EE_WORKMOBPH>
</emp>
</root>
`
Expected Result: `
<?xml version="1.0" encoding="UTF-8"?>
<root>
<emp>
<EE_WORKMOBPH></EE_WORKMOBPH>
<EE_MOBPH>123</EE_MOBPH>
</emp>
<emp>
<EE_WORKPH>345</EE_WORKPH>
<EE_WORKMOBPH>678</EE_WORKMOBPH>
</emp>
</root>
`
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<!-- TODO: Auto-generated template -->
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:strip-space elements="*"/>
<xsl:template match="root/emp/ee_workmobph/text()">
<xsl:if test="ee_workbobph = ee_mobph">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
CodePudding user response:
AFAICT, you want do:
XSLT 3.0
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:mode on-no-match="shallow-copy"/>
<xsl:template match="EE_WORKMOBPH[.=../EE_MOBPH]/text()"/>
</xsl:stylesheet>