How to group items in an XSLT variable
===

I'm processing a source HTML file that holds tabular data in an unstructured way. Basically it's a bunch of absolutely positioned `div`s. My goal is to rebuild some sort of structured XML data. So far, using XSLT 2.0 I was able to produce an XML looking like this:

    <data>
        <line top="44">
             <item left="294">Some heading text</item>
        </line>
        <line top="47">
             <item left="718">A</item>
             <item left="764">Section heading</item>
        </line>
        <line top="78">
            <item left="92">Data</item>
            <item left="144">Data</item>
            <item left="540">Data</item>
            <item left="588">Data</item>
        </line>
        <line top="101">
            <item left="61">B</item>
            <item left="144">Section heading</item>
        </line>
        <line top="123">
            <item left="92">Data</item>
            <item left="144">Data</item>
        </line>
    <data>

However, what I need to do next is group lines into sections. Each section starts with a line whose first item contains a single letter A – Z. My approach is to hold all the `<line>` elements in a `$lines` variable and then use `xsl:for-each-group` with `group-starting-with` attribute to identify the element starting a new section.

The respective XSLT fragment looks like this:

    <xsl:for-each-group select="$lines/line" group-starting-with="...pattern here...">
        <section>
            <xsl:copy-of select="current-group()"/>
        </section>
    </xsl:for-each-group>

The problem is I can't figure out a working pattern to identify section starts. The best I could do was ensuring that `//line/item[1]/text()[matches(., '^[A-Z]$')]` works when used separately in an XPath evaluator. However, I can't seem to derive a working version to be used with `group-starting-with`.