Optimizing my XSLT selector

chaotic

New Member
i'm using the orbeon form builder and want to add a value to the class attribute of some elements. To do this i'm using the code below, but i would like to know how to optimize this code. It must be possible to combine each 2 template tags, because the only difference is that is case 1 i set the class attribute to a value, and in case 2 i add some text to the class attribute..Maybe it is even possible to combine all this code into 1 template tag? (one with multiple selectors (match) and with the set/append class attribute?\[code\]Case 1: <xsl:template match="xforms:input/@id"> <xsl:attribute name="id" select="."/> <xsl:attribute name="class">tsbinput-<xsl:value-of select="."/></xsl:attribute> </xsl:template> Case 2: <xsl:template match="xforms:input/@class"> <xsl:attribute name="class"><xsl:value-of select="."/> tsbinput-<xsl:value-of select="../@id"/></xsl:attribute> </xsl:template>Case 1: <xsl:template match="fr:number/@id"> <xsl:attribute name="id" select="."/> <xsl:attribute name="class">tsbinput-<xsl:value-of select="."/></xsl:attribute> </xsl:template> Case 2: <xsl:template match="fr:number/@class"> <xsl:attribute name="class"><xsl:value-of select="."/> tsbinput-<xsl:value-of select="../@id"/></xsl:attribute> </xsl:template>Case 1: <xsl:template match="fr:textcount/@id"> <xsl:attribute name="id" select="."/> <xsl:attribute name="class">tsbinput-<xsl:value-of select="."/></xsl:attribute> </xsl:template> Case 2: <xsl:template match="fr:textcount/@class"> <xsl:attribute name="class"><xsl:value-of select="."/> tsbinput-<xsl:value-of select="../@id"/></xsl:attribute> </xsl:template>\[/code\]Please help me. Thanks, Nico
 
Back
Top