Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>&lt;xsl:apply-templates&gt;</code> is your friend:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" &gt; &lt;xsl:output method="html" /&gt; &lt;xsl:template match="root"&gt; &lt;h1&gt;List of books&lt;/h1&gt; &lt;xsl:apply-templates /&gt; &lt;/xsl:template&gt; &lt;!-- a &lt;book&gt; consists of its &lt;title&gt; and &lt;description&gt; --&gt; &lt;xsl:template match="book"&gt; &lt;xsl:apply-templates select="title" /&gt; &lt;xsl:apply-templates select="description" /&gt; &lt;/xsl:template&gt; &lt;!-- &lt;title&gt; is turned into a &lt;h2&gt; --&gt; &lt;xsl:template match="title"&gt; &lt;h2&gt; &lt;a name="{.}"/&gt; &lt;xsl:value-of select="." /&gt; &lt;/h2&gt; &lt;/xsl:template&gt; &lt;!-- &lt;description&gt; is turned into a &lt;p&gt; --&gt; &lt;xsl:template match="description"&gt; &lt;p&gt; &lt;xsl:apply-templates /&gt; &lt;/p&gt; &lt;/xsl:template&gt; &lt;!-- default rule: copy any node beneath &lt;description&gt; --&gt; &lt;xsl:template match="description//*"&gt; &lt;xsl:copy&gt; &lt;xsl:copy-of select="@*" /&gt; &lt;xsl:apply-templates /&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;!-- override rule: &lt;link&gt; nodes get special treatment --&gt; &lt;xsl:template match="description//link"&gt; &lt;a href="#{@ref}"&gt; &lt;xsl:apply-templates /&gt; &lt;/a&gt; &lt;/xsl:template&gt; &lt;!-- default rule: ignore any unspecific text node --&gt; &lt;xsl:template match="text()" /&gt; &lt;!-- override rule: copy any text node beneath description --&gt; &lt;xsl:template match="description//text()"&gt; &lt;xsl:copy-of select="." /&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>The following output is generated for your input XML (<em>Note: I piped it through tidy for the sake of readability. Non-relevant white-space was removed in the process</em>):</p> <pre><code>&lt;h1&gt;List of books&lt;/h1&gt; &lt;h2&gt;&lt;a name="Stuff"&gt;Stuff&lt;/h2&gt; &lt;p&gt;This book is &lt;i&gt;great&lt;/i&gt; if you need to know about stuff. I suggest &lt;a href="#Things"&gt;this one&lt;/a&gt; if you need to know about things.&lt;/p&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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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