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

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -