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
vishey68Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michel PlungjanIT ExpertCommented:
Perhaps if hyou show the code we can see if it is possble to only have the code once
0
vishey68Author Commented:
I will have something like

<xsl:if......
<tr>

<td>xx</td>
<td>yy</td>

<xsl:else
<td>xx</td>
<td>yy</td>
0
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
http://www.alistapart.com/articles/zebratables/
0
Chad HaneyChief Technology OfficerCommented:
Could go this route with xsl:params

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

<tr class="$style">
    <td>xx</td>
    <td>yy</td>
</tr>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.