title: Get all preceding/following sibling text content
body: <p>Consider the following XML:</p>
  
  <pre><code>&lt;paratext ID="p34"&gt;&lt;bold&gt;pass&lt;/bold&gt; &lt;bold&gt;pass&lt;/bold&gt;&lt;/paratext&gt;
  &lt;paratext ID="p35"&gt;&lt;bold&gt;pass&lt;/bold&gt;&lt;/paratext&gt;
  &lt;paratext ID="p36"&gt;foo &lt;bold&gt;pass&lt;/bold&gt; bar&lt;/paratext&gt;
  &lt;paratext ID="p37"&gt;foo&lt;bold&gt; pass &lt;/bold&gt;bar&lt;/paratext&gt;
  &lt;paratext ID="p38"&gt;&lt;bold&gt;fail&lt;/bold&gt;&lt;bold&gt;fail&lt;/bold&gt;&lt;/paratext&gt;
  &lt;paratext ID="p39"&gt;foo&lt;bold&gt;fail&lt;/bold&gt;bar&lt;/paratext&gt;
  </code></pre>
  
  <p>p34 should pass because there is non-alpha between the letters of the bold tags<br>
  p35 should pass because there are no alpha chars on the outside of the bold tags<br>
  p36 should pass because there is non-alpha between the bold text and other text<br>
  p37 should pass because there is non-alpha between the bold text and other text<br>
  p38 should fail because there are no alpha chars between the bold alpha chars<br>
  p39 should fail because there are no alpha chars between the bold text and "foo" or "bar"</p>
  
  <p>My attempt to do this via schematron has been this:</p>
  
  <pre><code>&lt;iso:rule context="//jd:csc|//jd:bold|//jd:ital|//jd:underscore"&gt;
   &lt;iso:assert test="   
      string-length(preceding-sibling::text()) = 0
      or      
      matches(substring(preceding-sibling::text(), string-length(preceding-sibling::text())), '[^a-zA-Z]')
      or
      matches(substring(.,1,1), '[^a-zA-Z]')
      "&gt;
      {WS1046} An .alpha character cannot both immediately preceed and follow &amp;lt;&lt;iso:value-of select="name()"/&gt;&amp;gt; tag
   &lt;/iso:assert&gt;
   &lt;iso:assert test="  
      string-length(following-sibling::text()) = 0
      or
      matches(substring(following-sibling::text(), 1,1), '[^a-zA-Z]')
      or
      matches(substring(., string-length(.)), '[^a-zA-Z]')
      "&gt;
      {WS1046} An .alpha character cannot both immediately preceed and follow &amp;lt;/&lt;iso:value-of select="name()"/&gt;&amp;gt; tag
   &lt;/iso:assert&gt;
  &lt;/iso:rule&gt;
  </code></pre>
  
  <p>The problem with this is that it only looks at the direct child text nodes of the parent of the current context. As such, p38 would not fail as there are no direct child text nodes. Also, something like <code>b&lt;foo&gt;bar &lt;bold&gt;pass&lt;/bold&gt;</code> would fail because it would only see the "b" in <code>preceding-sibling::text()</code> and would not see the <code>"foo "</code>.</p>
  
  <p>I've also tried <code>::*/text()</code> instead of <code>::text()</code>, but then I run into a similar issue because I only see text within sibling elements and do not get the direct sibling text-nodes. I need to get both things together, does anyone know how?</p>
  
  <hr>
  
  <p>For example, in this xml:</p>
  
  <pre><code>&lt;paratext ID="p1"&gt;hello &lt;foo&gt;bar&lt;/foo&gt; &lt;bold&gt;THIS&lt;/bold&gt; &lt;foo&gt;bar&lt;/foo&gt;goodbye&lt;/paratext&gt;
  </code></pre>
  
  <p>When the context rule hits <code>&lt;bold&gt;THIS&lt;/bold&gt;</code> and is checking preceding, I would like it to see <code>"hello bar "</code> and when checking the following I would like it to see <code>" bargoodbye"</code>.</p>