Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A complete xslt solution could look like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="xml" indent="yes" /&gt; &lt;xsl:template match="/"&gt; &lt;xsl:apply-templates /&gt; &lt;/xsl:template&gt; &lt;xsl:template match="root"&gt; &lt;root&gt; &lt;xsl:call-template name="for.loop"&gt; &lt;xsl:with-param name="i" select="1" /&gt; &lt;xsl:with-param name="count" select="4" /&gt; &lt;xsl:with-param name="answer" select="substring-after(//NTE_NotesAndCommentsSegment_2[position() = 1]/NTE_3_Comment, '?')" /&gt; &lt;/xsl:call-template&gt; &lt;/root&gt; &lt;/xsl:template&gt; &lt;xsl:template name="for.loop"&gt; &lt;xsl:param name="i" /&gt; &lt;xsl:param name="count" /&gt; &lt;xsl:param name="answer" /&gt; &lt;xsl:if test="$i &amp;lt;= $count"&gt; &lt;NTE_NotesAndCommentsSegment_2&gt; &lt;NTE_1_SetIdNotesAndComments&gt; &lt;xsl:value-of select="$i" /&gt; &lt;/NTE_1_SetIdNotesAndComments&gt; &lt;NTE_2_SourceOfComment&gt;&lt;/NTE_2_SourceOfComment&gt; &lt;NTE_3_Comment&gt; &lt;xsl:choose&gt; &lt;xsl:when test="$answer = ''"&gt; &lt;xsl:value-of select="concat('Question ', $i, ' ? *Blank*')" /&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="concat('Question ', $i, ' ? ', $comment)"/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/NTE_3_Comment&gt; &lt;/NTE_NotesAndCommentsSegment_2&gt; &lt;/xsl:if&gt; &lt;!-- Repeat the loop until finished --&gt; &lt;xsl:if test="$i &amp;lt;= $count"&gt; &lt;xsl:call-template name="for.loop"&gt; &lt;xsl:with-param name="i" select="$i + 1" /&gt; &lt;xsl:with-param name="count" select="$count"&gt; &lt;xsl:with-param name="comment" select="substring-after(//NTE_NotesAndCommentsSegment_2[position() = $i + 1]/NTE_3_Comment, '?')" /&gt; &lt;/xsl:call-template&gt; &lt;/xsl:if&gt; &lt;/xsl:template&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:stylesheet&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