Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to strip tags context-dependent?
    primarykey
    data
    text
    <p>Suppose I have a source example document like this:</p> <pre><code>&lt;html&gt; &lt;b&gt;&lt;i&gt;&lt;u&gt;TestBIU&lt;/u&gt;&lt;/i&gt;&lt;/b&gt; &lt;i&gt;&lt;b&gt;&lt;u&gt;TestIBU&lt;/u&gt;&lt;/b&gt;&lt;/i&gt; &lt;i&gt;&lt;u&gt;&lt;b&gt;TestIUB&lt;/b&gt;&lt;/u&gt;&lt;/i&gt; &lt;b&gt;&lt;u&gt;&lt;i&gt;TestBUI&lt;/i&gt;&lt;/u&gt;&lt;/b&gt; &lt;u&gt;&lt;i&gt;&lt;b&gt;TestUIB&lt;/b&gt;&lt;/i&gt;&lt;/u&gt; &lt;u&gt;&lt;b&gt;&lt;i&gt;TestUBI&lt;/i&gt;&lt;/b&gt;&lt;/u&gt; &lt;u&gt;TestU&lt;/u&gt; &lt;i&gt;TestI&lt;/i&gt; &lt;b&gt;TestB&lt;/b&gt; &lt;u&gt;&lt;b&gt;TestUB&lt;/b&gt;&lt;/u&gt; &lt;/html&gt; </code></pre> <p>I need a XSLT-Template that produces this:</p> <pre><code>&lt;html&gt; &lt;b&gt;&lt;i&gt;TestBIU&lt;/i&gt;&lt;/b&gt; &lt;i&gt;&lt;b&gt;TestIBU&lt;/b&gt;&lt;/i&gt; &lt;i&gt;&lt;b&gt;TestIUB&lt;/b&gt;&lt;/i&gt; &lt;b&gt;&lt;i&gt;TestBUI&lt;/i&gt;&lt;/b&gt; &lt;i&gt;&lt;b&gt;TestUIB&lt;/b&gt;&lt;/i&gt; &lt;b&gt;&lt;i&gt;TestUBI&lt;/i&gt;&lt;/b&gt; &lt;u&gt;TestU&lt;/u&gt; &lt;i&gt;TestI&lt;/i&gt; &lt;b&gt;TestB&lt;/b&gt; &lt;b&gt;TestUB&lt;/b&gt; &lt;/html&gt; </code></pre> <p>So, it should remove the underline tag when it occurs in combination with italic and/or bold tags. When only underlined, it should remain. Any ideas how to solve this particular problem?</p> <p>Here is my attempt, but if fails for TestUIB and TestUBI:</p> <pre><code>&lt;xsl:template match="/"&gt; &lt;html&gt; &lt;xsl:apply-templates /&gt; &lt;/html&gt; &lt;/xsl:template&gt; &lt;xsl:template match="b/u"&gt; &lt;xsl:apply-templates /&gt; &lt;/xsl:template&gt; &lt;xsl:template match="i/u"&gt; &lt;xsl:apply-templates /&gt; &lt;/xsl:template&gt; &lt;xsl:template match="u/i"&gt; &lt;i&gt;&lt;xsl:apply-templates /&gt;&lt;/i&gt; &lt;/xsl:template&gt; &lt;xsl:template match="u/b"&gt; &lt;b&gt;&lt;xsl:apply-templates /&gt;&lt;/b&gt; &lt;/xsl:template&gt; &lt;xsl:template match="b | u | i"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="* | text()"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; </code></pre>
    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.
 

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