I have got lists with two types of list markers, namely numeric (1., 2., 3., etc.) and alphabetic "a)", "b)", "c)", etc. or "aa)", "bb)", "cc)", etc. I want to check whether each item of a list is numbered subsequently according to its list marker type.

This means in numeric lists a subsequent item should be numbered as n+1 plus a dot, where n is the number in the current item's term and n+1 would be the number in its parent::item/following-sibling::*[1]/self::item/term.

In alphabetic lists the parent::item/following-sibling::*[1]/self::item/term should contain the next letter(s) in alphabetical order from the current item/term plus a closing parenthesis. So for example after "b)" would follow "c)" and after "cc)" would follow "dd)".

I do not want to change the numbering, but just check and document the errors found and ideally their locations.

The input format would look like this:

<list>
  <item>
    <term>1.</term>
    <para>jhjhjh hjkjkjkj</para>
  </item>
  <item>
    <term>3.</term>
    <para>jhjhjh hjkjkjkj</para>
  </item>
  <item>
    <term>4.</term>
    <para>jhjhjh hjkjkjkj</para>
  </item>
</list>

Or:

<list>
  <item>
    <term>a)</term>
    <para>jhjhjh hjkjkjkj</para>
  </item>
  <item>
    <term>b)</term>
    <para>jhjhjh hjkjkjkj</para>
  </item>
  <item>
   <term>d)</term>
   <para>jhjhjh hjkjkjkj</para>
  </item>
</list>

Or:

<list>
  <item>
    <term>aa)</term>
    <para>jhjhjh hjkjkjkj</para>
  </item>
  <item>
    <term>cc)</term>
    <para>jhjhjh hjkjkjkj</para>
  </item>
  <item>
    <term>dd)</term>
    <para>jhjhjh hjkjkjkj</para>
  </item>
</list>

These input samples deliberately contain errors that should be detected and located.

Please note that in the samples I had to use <para> instead of <p>, but in the Perl script, it should be <p>-elements.


In reply to Check numbering of list items by LexPl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.