SharePoint サイトのリストから、行ごとに 2 つのレコードを表示したいと考えています。
XSLTを使用しています。これは私がレコードを表示したい方法です:
<tr>
<td>Record1</td>
<td>Record2</td>
</tr>
<tr>
<td>Record3</td>
<td>Record4</td>
</tr>
この仕事をするために次のコードを書きましたが、書かれている行でエラーが発生します。基本的に XSLT では、閉じずに書くことはできません。しかし、そうしないと私のロジックが機能しません。これを達成する方法はありますか?
コード
<xsl:choose>
<xsl:when test="position() mod 2 = 1">
<tr> (this is my error line)
</xsl:when>
</xsl:choose>
<td>rest of my code will come here</td>
<xsl:choose>
<xsl:when test="position() mod 2 = 0">
</tr>
</xsl:when>
</xsl:choose>
EDIT
これは、私の完全なSharePointコードがどのように見えるかです.
<xsl:template match="/" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
<table width="327" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Links</td>
</tr>
<tr>
<td>
<table width="327" border="0" cellspacing="0" cellpadding="0">
<xsl:apply-templates />
</table>
</td>
</tr>
</table>
</xsl:template>
<xsl:template match="Row" name="items">
<xsl:choose>
<xsl:when test="position() mod 2 = 1">
<tr> (this is my error line)
</xsl:when>
</xsl:choose>
<td>rest of my code will come here</td>
<xsl:choose>
<xsl:when test="position() mod 2 = 0">
</tr>
</xsl:when>
</xsl:choose>
</xsl:template>
つまり、基本的にコードは<xsl:apply-templates />
、ここから始まるコードの完全なブロック<xsl:template match="Row" name="items">
が繰り返され、行で満たされるため、ここには for ループはありません。
編集 - 完全な XSL コード
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="yes"/>
<xsl:param name="ViewAll" />
<!-- This template is the "wrapper" or "container" for the custom view. -->
<xsl:template match="/" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
<!-- This is the actual wrapper element that will be emitted -->
<table width="327" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">
<table width="327" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10" height="30" class="webpart_img1"></td>
<td width="307" height="30" class="webpart_img2">Links</td>
<td width="10" height="30" class="webpart_img3"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="1" colspan="3"></td>
</tr>
<tr>
<td width="10" height="105" class="quicklink_img1"></td>
<td width="307" height="105" class="quicklink_img1">
<table width="307" border="0" cellspacing="0" cellpadding="0">
<xsl:apply-templates />
</table>
</td>
<td width="10" height="105" class="quicklink_img1"></td>
</tr>
<tr>
<td width="10" height="6" class="quicklink_img2"></td>
<td width="307" height="6" class="quicklink_img1"></td>
<td width="10" height="6" class="quicklink_img3"></td>
</tr>
</table>
<!-- end wrapper -->
</xsl:template>
<!-- This template is for the repeating content -->
<xsl:template match="Row" name="repeat">
<tr>
<td width="16" height="21"><img src="images/mybullet.png"/></td>
<td width="142" height="21"><a href="URL" class="quicklink">Title of URL</a></td>
<td width="11"></td>
<td width="16" height="21"><img src="images/mybullet.png"/></td>
<td width="142" height="21"><a href="URL" class="quicklink">Title of URL</a></td>
</tr>
</xsl:template>
</xsl:stylesheet>
SharePoint のリストからのリンクを表示しようとしています。リストには次の 2 つの列があります。
タイトル
URL
そのため、URL をハイパーリンクとして 1 行に 2 つのタイトルを表示したいと考えています。