Logical

This self-testing system worked quite well while I was in initial development of the regular expression and various sub-portions thereof, but pretty quickly (well, not that quickly — it took longer than I care to admit to move from initial development to refinement) it became necessary to test the regular expression against an array of possible selectors. Luckily

So, in addition to the few dozen scenarios I had dreamt up, I incorporated thousands of selectors from real CSS files and test suites. Since my tests would (deliberately) examine any selector attribute, not just one on a tei:rendition element, I was even able to make test cases consistent (each test on an selector of a rendition) and simultaneously retain the provenance of each test by using an appropriate namespace for the rendition.

Example 3, “XSLT schema, debugging” is an extract of the generated XSLT showing a few of the namespaces used, and three test selectors for each of those namespaces. The actual generated XSLT includes the validation portions discussed above, and tens to hundreds of test selectors for each of over a half dozen namespaces.

Example 3. XSLT schema, debugging

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:sb="http://bauman.zapto.org/ns-for-testing-CSS"
  xmlns:wpt="https://github.com/web-platform-tests/wpt"
  xmlns:w3c="https://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/"
  xmlns:wo="http://wwo.wwp-test.northeastern.edu/WWO/css/wwo/wwo.css"
  xmlns:pt="https://github.com/benfrain/css-performance-tests"    
  version="3.0">

  <!-- This pgm written 2019-06-02T09:57:25 by
       ./CSS3_selector_regex_generator.perl -->

  <!-- ========= debugging ========= -->
  <!--
  legend:
    pt = performance test suite
    wpt = W3C web platform tests for CSS
    w3c = W3C test suite, last retrieved 2019-06-01
    wo = WWO CSS stylesheet, i.e. for Women Writers Online textbase viewing site
    sb = dreamt up by yours truly
  -->
  <!--
  Note: the wpt and w3c sets are very very similar, but not quite
    identical; it is not clear to me there is any real advantage in
    running both, but I am interested in having a lot of test cases
    too see how fast this is, too. Thus both are included.
    -->
  <!-- ********* -->
  <wpt:rendition selector="li,p "/>
  <wpt:rendition selector="p "/>
  <wpt:rendition selector="p[title$='bar'] "/>
  <!-- ********* -->
  <w3c:rendition selector='   stub ~ [|attribute^=start]:not([|attribute~=mid])
                           [|attribute*=dle][|attribute$=end] ~ t '/>
  <w3c:rendition selector='   #two:first-child '/>
  <w3c:rendition selector='   #three:last-child '/>
  <!-- ********* -->
  <pt:rendition selector='[data-select]'/>
  <pt:rendition selector='a[data-select]'/>
  <pt:rendition selector='[data-select="link"]'/>
  <!-- ********* -->
  <sb:rendition selector=":not(:lang(en))"/>
  <sb:rendition selector=":not( :lang(   en-GB ))"/>
  <sb:rendition selector="    :lang(en-GB-x-HPf)"/>
  <!-- ********* -->
  <wo:rendition selector="#popup > div.note.content .bibl-sref "/>
  <wo:rendition selector='#popup > div.note.content .bibl-sref span[class~="moo"],
#popup > div.note.content .bibl-sref-parenless span[class~="moo"] '/>
  <wo:rendition selector=""/>
  <!-- ========= end debugging ========= -->

</xsl:stylesheet>