Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I take it that "the text I want to match against will span several tags" means something like this:</p> <pre><code> In &lt;i&gt;this&lt;/i&gt; example, I want to match "In this example". In &lt;i&gt;&lt;b&gt;this&lt;/b&gt;&lt;/i&gt; example, I also want to match "In this example". And &lt;i&gt;in &lt;b&gt;this&lt;/b&gt;&lt;/i&gt; example, it's clear I have to ignore case too. </code></pre> <p>This seems like an especially hard problem because the transformation you're talking about can result in XML that's not well-formed - e.g. look what happens if you try to put tags around the substring here:</p> <pre><code>In this &lt;i&gt;example, putting tags around "in this example"&lt;/i&gt; will break things. &lt;i&gt;And in this&lt;/i&gt; example, you have a similar problem. </code></pre> <p>To produce well-formed output, you'd probably need it to look like:</p> <pre><code>&lt;bold&gt;In this &lt;i&gt;example&lt;/i&gt;&lt;bold&gt;&lt;i&gt;, putting tags around "in this example"&lt;/i&gt; will break things. &lt;i&gt;And &lt;bold&gt;in this&lt;/bold&gt;&lt;/i&gt;&lt;bold&gt; example&lt;/bold&gt;, you have a similar problem. </code></pre> <p>In theory, every character you're matching could be in a different element:</p> <pre><code>Almost like &lt;i&gt;&lt;u&gt;i&lt;/u&gt;&lt;u&gt;n&lt;/u&gt; &lt;/i&gt;&lt;u&gt;th&lt;/u&gt;is&lt;i&gt;&lt;i&gt;&lt;u&gt; ex&lt;/i&gt;am&lt;/i&gt;ple.&lt;/i&gt; </code></pre> <p>You have basically two problems here, and neither is simple:</p> <ol> <li><p>Search a stream of XML for a substring, ignoring everything that's not a text node, and return the start and end positions of the substring within the stream.</p></li> <li><p>Given two arbitrary indexes into an XML document, create an element enclosing the text between those indexes, closing (and reopening) any elements whose tags span either but not both of the two indexes.</p></li> </ol> <p>It's pretty clear to me that XSLT and regular expressions won't help you here. I don't think using a DOM will help you here, either. In fact I don't think that there's an answer to the second problem that doesn't involve writing a parser.</p> <p>This isn't really an answer, I know.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload