xml - Reducing the need for xsl:if and code duplications -


i have xslt code differs single class element. however, of internal div content.

i attempted separate out starting tag such:

 <xsl:if test="position() = 1">         <div class="position first">   </xsl:if>  <xsl:if test="position() != 1">         <div class="position">   </xsl:if> 

but ofcourse produces invalid xslt code. [the div's must closed within scope].

is there way add optional class keyword without have reduplicate internal contents?

try this:

<div class="position">    <xsl:if test="position() = 1">       <xsl:attribute name="class">position first</xsl:attribute>    </xsl:if>     </div> 

the xsl:attribute instruction should override literal attribute.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -