How to avoid duplicate code

I am writing a chunk of code with similiar structure in XSL. Based on some condition in this case postion of the data i change the color, so that each row displays data in different color.
The problem is that similiar code has been duplicated . Is there some way to elimnate the duplicate code i want to know which techinque is best to rewrite this. If i need to use a Javascript, how do i activate the function when we use xsl:if
Who is Participating?
Chad HaneyConnect With a Mentor Chief Technology OfficerCommented:
Could go this route with xsl:params

      <xsl:param name="style">blue</xsl:param>
      <xsl:param name="style">green</xsl:param>

<tr class="$style">
Michel PlungjanIT ExpertCommented:
Perhaps if hyou show the code we can see if it is possble to only have the code once
vishey68Author Commented:
I will have something like



Michel PlungjanIT ExpertCommented:
Oh, I thought you wanted to avoid duplicating the JAVASCRIPT code.
I call xsl markup but of course it can be seen as scripting...

Have a read here and see if you can just use CSS
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.