• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

Add Parentheses Around Each Numbered List Item - please HELP!

Greetings!

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">
<LI>
<xsl:apply-templates/>
</LI>
</OL>

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,
Jamie


0
jmc430
Asked:
jmc430
  • 3
  • 2
1 Solution
 
Geert BormansCommented:
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 :-)
Cheers!
0
 
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:

<TABLE>
<TR>
<TD>
<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>
</xsl:if>
<dd/>
</div>
</TD>
<TD>
<div align="left">
<xsl:apply-templates/>
</div>
</TD>
</TR>
</TABLE>

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

Thanks so much for helping me!
Jamie
0
 
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! :)
0
 
Geert BormansCommented:
<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

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

<xsl:template match="para">
   <xsl:value-of select="countpreceding-sibling::para + 1)"/>
</xsl:template>
0
 
Geert BormansCommented:
well, seems my last post took me to long to write :-)
welcome
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now