xml - XSLT 2.0 if condition -
need on xslt 2.0 transformation.
input xml :
<employee> <post>manager</post> </employee>
pseudo code :
if(employee/post = 'manager') associate/high = 'band' else associate/low = 'band'
output xml :
<associate> <high>band</high> </associate> <associate> <low>band</low> </associate>
construct element dynamically xsl:element
. other that, pseudo code pretty accurate.
xslt stylesheet
<?xml version="1.0" encoding="utf-8" ?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="2.0"> <xsl:output method="xml" omit-xml-declaration="yes" encoding="utf-8" indent="yes" /> <xsl:template match="employee"> <associate> <xsl:element name="{if (post = 'manager') 'high' else 'low'}"> <xsl:value-of select="'band'"/> </xsl:element> </associate> </xsl:template> </xsl:transform>
xml output
<associate> <high>band</high> </associate>
Comments
Post a Comment