A <div>
не может быть потомком <xml:choose>
, но я хочу, чтобы <li>
s повторялось & mdash; другими словами, не их родитель <div>
с или <ul>
с.
Ниже вы найдете мой пример ввода, XSLT и пример требуемого вывода.
Input
<?xml version="1.0" encoding="utf-8" ?>
<Collection>
<Content>
<Html>
<root>
<news>
<title>Item 1</title>
<publication-date>2010-04-16</publication-date>
<article-content>
<p>Aliquam mollis porttitor auctor. Aenean laoreet justo sed ipsum lobortis eleifend. In ac mollis neque. Donec rutrum turpis vel quam mattis eu vestibulum arcu tincidunt.</p>
</article-content>
</news>
</root>
</Html>
</Content>
<Content>
<Html>
<root>
<news>
<title>Item 2</title>
<publication-date>2010-04-19</publication-date>
<article-content>
<p>Aliquam mollis porttitor auctor. Aenean laoreet justo sed ipsum lobortis eleifend. In ac mollis neque. Donec rutrum turpis vel quam mattis eu vestibulum arcu tincidunt.</p>
</article-content>
</news>
</root>
</Html>
</Content>
</Collection>
XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*" />
<xsl:template match="/Collection/Content" xml:space="preserve">
<div id="latest-news" class="module clear">
<h2>Latest News</h2>
<xsl:choose>
<xsl:when test="position() = 1">
<div id="featured-story">
<h3>
<a href="#tk">
<xsl:copy-of select="Html/root/news/title/node()" />
</a>
</h3>
<p class="publish-date">
<xsl:copy-of select="Html/root/news/publication-date/node()" />
</p>
<xsl:copy-of select="Html/root/news/article-content/node()" />
<p class="more">
<a href="#tk">Read more</a>
</p>
</div>
</xsl:when>
<xsl:when test="position() > 1 and position() < 6">
<div id="summaries" class="column-1">
<ul>
<li>
<h3>
<a href="#tk">
<xsl:copy-of select="Html/root/news/title/node()" />
</a>
</h3>
<p class="publish-date">
<xsl:copy-of select="Html/root/news/publication-date/node()" />
</p>
<xsl:copy-of select="Html/root/news/article-content/node()" />
<p class="more">
<a href="#tk">Read more</a>
</p>
</li>
</ul>
</div>
</xsl:when>
<xsl:otherwise>
<div id="links" class="column-2">
<ul>
<li>
<p class="publish-date">
<xsl:copy-of select="Html/root/news/publication-date/node()" />
</p>
<h3>
<a href="#tk">
<xsl:copy-of select="Html/root/news/title/node()" />
</a>
</h3>
<p class="more">
<a href="#tk">Read more</a>
</p>
</li>
</ul>
</div>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:template>
</xsl:stylesheet>
выход
<div id="latest-news" class="module clear">
<h2>Latest News</h2>
<div id="featured-story">
<h3><a href="#tk">[Item 1]</a></h3>
<p class="publish-date">July 7, 2010</p>
<p>[Article content, in form of an extended summary]</p>
<p class="more">
<a href="#tk">Read more</a>
</p>
</div>
<div id="summaries" class="column-1">
<ul>
<li>
<h3><a href="#tk">[Item 2]</a></h3>
<p class="publish-date">July 7, 2010</p>
<p>[Article content, in short summary format]</p>
</li>
<li>
<h3><a href="#tk">[Item 3 and so on]</a></h3>
<p class="publish-date">July 7, 2010</p>
<p>[Article content, in short summary format]</p>
</li>
</ul>
</div>
<div id="links" class="column-2">
<ul>
<li>
<h3><a href="#tk">[Item 6]</a></h3>
<p class="publish-date">July 7, 2010</p>
</li>
<li>
<h3><a href="#tk">[Item 7 and so on]</a></h3>
<p class="publish-date">July 7, 2010</p>
</li>
</ul>
</div>
</div>