Note that there are some explanatory texts on larger screens.

plurals
  1. POSimplest way of outputting a single XML tag into HTML tag
    text
    copied!<p>Is there a simple way to format that single <code>heading</code> and turn those heading tags into h3 tags in XSLT?</p> <pre><code>&lt;webpage&gt; &lt;heading&gt;Header&lt;/heading&gt; &lt;p&gt; paragraph &lt;a href="http://www.google.com"&gt;google&lt;/a&gt; more paragraph&lt;/p&gt; &lt;ul&gt; &lt;li&gt;item1&lt;/li&gt; &lt;li&gt;item2&lt;/li&gt; &lt;li&gt;item3&lt;/li&gt; &lt;li&gt;item4&lt;/li&gt; &lt;li&gt;item5&lt;/li&gt; &lt;li&gt;item6&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;more paragraph&lt;a href="http://www.potato.com"&gt;potato.com&lt;/a&gt;&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;heading&gt;heading&lt;/heading&gt; &lt;p&gt; here comes a list:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;item1&lt;/li&gt; &lt;li&gt;item2&lt;/li&gt; &lt;li&gt;item3&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;/webpage&gt; </code></pre> <p>The goal is to turn it into this</p> <pre><code> &lt;h3&gt;Header&lt;/h3&gt; &lt;p&gt; paragraph &lt;a href="http://www.google.com"&gt;google&lt;/a&gt; more paragraph&lt;/p&gt; &lt;ul&gt; &lt;li&gt;item1&lt;/li&gt; &lt;li&gt;item2&lt;/li&gt; &lt;li&gt;item3&lt;/li&gt; &lt;li&gt;item4&lt;/li&gt; &lt;li&gt;item5&lt;/li&gt; &lt;li&gt;item6&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;more paragraph&lt;a href="http://www.potato.com"&gt;potato.com&lt;/a&gt;&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;h3&gt;heading&lt;/h3&gt; &lt;p&gt; here comes a list:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;item1&lt;/li&gt; &lt;li&gt;item2&lt;/li&gt; &lt;li&gt;item3&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; &lt;p&gt;more paragraph&lt;/p&gt; </code></pre> <p>This seems like it should work, but it does not:</p> <pre><code> &lt;xsl:variable name="webpage" select="document('webpage.xml')/webpage"&gt; &lt;xsl:template match="@*|node()"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*|node()"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="/webpage/heading"&gt; &lt;h3&gt; &lt;xsl:value-of select="."/&gt; &lt;/h3&gt; &lt;/xsl:template&gt; &lt;/xsl:variable&gt; </code></pre>
 

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