Étant donnée une entrée comme ce qui suit:Appliquer des modèles aux éléments adjacents?
<p>Some information about the proceeding source listing:</p>
<code language="CSharp"><![CDATA[ ... ]]></code>
<code language="AnotherLanguage"><![CDATA[ ... ]]></code>
<p>This is a different example which perhaps applies to just one language:</p>
<code language="CSharp"><![CDATA[ ... ]]></code>
<p>Another example:</p>
<code language="CSharp"><![CDATA[ ... ]]></code>
<code language="AnotherLanguage"><![CDATA[ ... ]]></code>
<code language="YetAnotherLanguage"><![CDATA[ ... ]]></code>
En utilisant XSLT 1.0, comment puis-je groupe l'élément <code>
adjacent comme suit:
<p>Some information about the proceeding source listing:</p>
<div class="source-selector">
<ul class="tabs">
<li class="tab" data-language="CSharp">CSharp</li>
<li class="tab" data-language="AnotherLanguage">AnotherLanguage</li>
</ul>
<div data-language="CSharp">
<pre>...</pre>
</div>
<div data-language="AnotherLanguage">
<pre>...</pre>
</div>
</div>
<p>This is a different example which perhaps applies to just one language:</p>
<div class="source-selector">
<ul class="tabs">
<li class="tab" data-language="CSharp">CSharp</li>
</ul>
<div data-language="CSharp">
<pre>...</pre>
</div>
</div>
<p>Another example:</p>
<div class="source-selector">
<ul class="tabs">
<li class="tab" data-language="CSharp">CSharp</li>
<li class="tab" data-language="AnotherLanguage">AnotherLanguage</li>
<li class="tab" data-language="YetAnotherLanguage">YetAnotherLanguage</li>
</ul>
<div data-language="CSharp">
<pre>...</pre>
</div>
<div data-language="AnotherLanguage">
<pre>...</pre>
</div>
<div data-language="YetAnotherLanguage">
<pre>...</pre>
</div>
</div>
C'est ce que j'ai au moment qui ne fonctionne pas correctement parce que tout le code source est groupé dans un seul sélecteur après tout autre contenu (comme les paragraphes dans cet exemple).
<!-- Display paragraphs first -->
<xsl:apply-templates select="*[not(name() = 'code')]"/>
<!-- Display consecutive source code within selector -->
<div class="source-selector">
<ul class="tabs">
<xsl:for-each select="code">
<li class="tab" data-language="{@language}"><include item="{@language}Label"/></li>
</xsl:for-each>
</ul>
<xsl:for-each select="code">
<div data-language="{@language}">
<pre><xsl:copy-of select="node()"/></pre>
</div>
</xsl:for-each>
</div>
Parfait, merci! C'est une technique soignée. –