Note that there are some explanatory texts on larger screens.

plurals
  1. POuse xsl to output the html
    primarykey
    data
    text
    <p>The output should be html ,and out put the table of contents, following is the xml </p> <pre><code>&lt;!DOCTYPE book SYSTEM "book.dtd"&gt; &lt;book title="D"&gt; &lt;author&gt; &lt;name&gt;abc&lt;/name&gt; &lt;/author&gt; &lt;chapter title="chapter1"&gt; &lt;section title="section1.1"/&gt; &lt;section title="section1.2"&gt; &lt;section title="section1.2.1"/&gt; &lt;section title="section1.2.2"/&gt; &lt;/section&gt; &lt;section title="section3"&gt; &lt;section title="section3.1"/&gt; &lt;/section&gt; &lt;/chapter&gt; &lt;chapter title="chapter2"/&gt; &lt;/book&gt; </code></pre> <p>my template is:</p> <pre><code> &lt;xsl:template match="book" as="element(xhtml:html)"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;title&gt; &lt;xsl:value-of select="@title"/&gt; &lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt; &lt;xsl:value-of select="@title"/&gt; &lt;/h2&gt; &lt;p&gt; by &lt;xsl:value-of select="author"/&gt; &lt;/p&gt; &lt;h3&gt;Table of contents&lt;/h3&gt; &lt;ul&gt; &lt;xsl:apply-templates select="chapter"/&gt; &lt;/ul&gt; &lt;/body&gt; &lt;/html&gt; &lt;/xsl:template&gt; &lt;xsl:template match="chapter|section" as="element()*"&gt; &lt;xsl:param name ="seq" as="element(section)*"/&gt; &lt;li xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;xsl:value-of select="@title"/&gt; &lt;xsl:apply-templates select ="section"/&gt; &lt;/li&gt; &lt;/xsl:template&gt; &lt;/xsl:transform&gt; </code></pre> <p>my html is wrong</p> <pre><code> &lt;body&gt; &lt;h2&gt;D&lt;/h2&gt; &lt;p&gt; by abc &lt;/p&gt; &lt;h3&gt;Table of contents&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;chapter1 &lt;li&gt;section1.1&lt;/li&gt; &lt;li&gt;section1.2 &lt;li&gt;section1.2.1&lt;/li&gt; &lt;li&gt;section1.2.2&lt;/li&gt; &lt;/li&gt; &lt;li&gt;section3 &lt;li&gt;section3.1&lt;/li&gt; &lt;/li&gt; &lt;/li&gt; &lt;li&gt;chapter2&lt;/li&gt; &lt;/ul&gt; &lt;/body&gt; </code></pre> <p>The result should be:</p> <pre><code>&lt;body&gt; &lt;h2&gt;D&lt;/h2&gt; &lt;p&gt; by abc &lt;/p&gt; &lt;h3&gt;Table of contents&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;chapter1 &lt;ul&gt; &lt;li&gt;section1.1&lt;/li&gt; &lt;li&gt;section1.2 &lt;ul&gt; &lt;li&gt;section1.2.1&lt;/li&gt; &lt;li&gt;section1.2.2&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;section3 &lt;ul&gt; &lt;li&gt;section3.1&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;chapter2&lt;/li&gt; &lt;/ul&gt; &lt;/body&gt; </code></pre>
    singulars
    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