Add Parentheses Around Each Numbered List Item - please HELP!


Is it feasible to add parentheses around numbered list items in XSLT?

I have a template that basically works like this for all ordered lists:

a.  Some AA text
b.  Some BB text
c.  Some CC text

The XSLT that handles this looks like this:

<OL type="a">

Now, however, there have been requests to envelope the numbered list items within parentheses, and to remove the trailing periods after the letter, so that the ordered list looks like this:

(a)   Some AA text
(b)   Some BB text
(c)   Some CC text

I've surfed the web for hours in the hopes of finding a way to resolve this issue, to no avail.  

Is this impossible?  I made some fruitless attempts to put "(" and ")" characters around the <li> tags, and tried to hardcode it in using a pseudo-counter to count the list items and then output the counter values, but none of my resolutions have worked.

I am tearing my hair out because I assumed this would be relatively trivial to do yet I am at a complete and total loss...

Any advice or guidance is greatly appreciated!  

Please help me!

Best regards,

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Gertone (Geert Bormans)Information ArchitectCommented:
Hi Jamie,

this one is though.
You would basically need some CSS2 properties that aren't supported by any browser yet
marker, marker-offset...

The only way to tackle this is
- give the <LI> a style attribute (style="display: block;") The list items will then display as a block. You should play with margins and padding then.
maybe you can make it <dfn> and <dd> elements instead of <li>, if that is acceptable
- after that you have to calculate the item numbering yourself... the format can be controlled with the xsl:count element,
put a "(" before and a ")" after yourself

sorry but browsers don't support what they could have yet :-)

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
jmc430Author Commented:
Hi Geert!

Thanks for responding!

How do I count the values of <LI>?  I tried doing self:://theNameOfTheParentElementForLiTags, but it only gives the grand total of the element itself..

I am using this now:

<div align="left">
<xsl:if test="count(//para)>1">
<xsl:text disable-output-escaping="yes">(</xsl:text>
<xsl:value-of select="count(//para)"/>
<xsl:text disable-output-escaping="yes">)</xsl:text>
<div align="left">

But this is only outputting "(22)" values instead of incrementing them  ... what am I doing wrong?

Thanks so much for helping me!
jmc430Author Commented:
Hi Geert!!

Thanks for pointing me in the right direction... I  got it working.

Thanks so much again for all of your help!  I really really appreciate everything! :)
Gertone (Geert Bormans)Information ArchitectCommented:
<xsl:value-of select="count(//para)"/>

this will count all the para elements of course

you should do the count in the processing of the para element

<div align="left">
<xsl:apply-templates select="para"/>

<xsl:template match="para">
   <xsl:value-of select="countpreceding-sibling::para + 1)"/>
Gertone (Geert Bormans)Information ArchitectCommented:
well, seems my last post took me to long to write :-)
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

From novice to tech pro — start learning today.