Note that there are some explanatory texts on larger screens.

plurals
  1. POXSLT mixed content node
    primarykey
    data
    text
    <p>I have a quite stupid question. How can I make sure that my XML mixed content node doesn't get mixed up? I have, say, an XML structure resembling this.</p> <pre><code>&lt;root&gt; &lt;book&gt; &lt;title&gt;Stuff&lt;/title&gt; &lt;description&gt; This book is &lt;i&gt;great&lt;/i&gt; if you need to know about stuff. I suggest &lt;link ref="Things"&gt;this one&lt;/link&gt; if you need to know about things. &lt;/description&gt; &lt;/book&gt; [other books] &lt;/root&gt; </code></pre> <p>I need the final content to look like this</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> <p>But I can't extract the portions of the text node, I always grab the whole thing. I'm using the descendant axis. Any clue what I'm doing wrong?</p> <p>Here is my xslt:</p> <pre><code>&lt;xsl:template match="description/*"&gt; &lt;xsl:for-each select="following-sibling::*"&gt; &lt;xsl:choose&gt; &lt;xsl:when test="name(.)='link'"&gt; &lt;a href="{@ref}"&gt;&lt;xsl:value-of select="."/&gt;&lt;/a&gt; &lt;/xsl:when&gt; &lt;xsl:when test="name(.)='em'"&gt; &lt;em&gt;&lt;xsl:value-of select="."/&gt;&lt;/em&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt;&lt;p&gt;&lt;xsl:value-of select="."/&gt;&lt;/p&gt;&lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; </code></pre> <p>Please note that the enclosed XML and resulting html are merely examples, I have to deal with a bigger structure which I'm not enclosing in, for sake of clarity.</p>
    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.
 

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