構文のヘルプが必要です
CMS からいくつかのタイトル情報 (音楽、テレビ、コメディ) を取得しています。xsl でチェックを実行して、どのタイトルが表示されるかを確認し、適切なコンテンツ (私の場合は一連のチェックボックス) をレンダリングする必要があります。
タイトルに基づいて、さまざまな XSL コードをレンダリングしたいと考えています。Title = TV の場合はこの XSL を表示し、Title = Music の場合は代わりにこの XSL をレンダリングします。
これまでのところ私のコードですが、XSL if ステートメント内に XSL when ステートメントがあるため、エラーがスローされます。
<xsl:template name="PrintTitles">
<xsl:param name="ids"/>
<xsl:if test="$ids">
<xsl:variable name="itm_id" select="substring-before($ids, '|')"/>
<!-- xsl:if -->
<xsl:if test="$itm_id">
<!-- Variable item & title -->
<xsl:variable name="itm" select="sc:item($itm_id,.)"/>
<xsl:variable name="title" select="sc:fld('Title', $itm)"/>
<div class="related-genre-types-{position()}" style="display:none;"><xsl:value-of select="sc:fld('Title', $itm)"/></div>
<div class="music-choices" style="display:block;">
<!-- Displays title -->
<div class="choices-title"><xsl:value-of select="sc:fld('Title', $itm)"/></div>
<div class="choices-checkboxes">
<!-- where I try to use the 'when conditional' throws error because this is inside of <xsl:if test="$itm_id">-->
<!-- if title = TV then render this -->
<xsl:when test="title = TV">
<xsl:for-each select="$TVGenres/item">
<div class="category_box">
<input type="checkbox" id="getf{sc:fld('@id',.)}" name="getfItem" value="{sc:fld('title',.)}" />
<label for="get{sc:fld('@id',.)}"><xsl:value-of select="sc:fld('title',.)" /></label>
</div>
</xsl:for-each>
</xsl:when>
<!-- if title = Music then render this -->
<xsl:when test="title = Music">
<xsl:for-each select="$MusicGenres/item">
<div class="category_box">
<input type="checkbox" id="getf{sc:fld('@id',.)}" name="getfItem" value="{sc:fld('title',.)}" />
<label for="get{sc:fld('@id',.)}"><xsl:value-of select="sc:fld('title',.)" /></label>
</div>
</xsl:for-each>
</xsl:when>
<!-- if title = Comedy then render this -->
<xsl:when test="title = Comedy">
<xsl:for-each select="$ComedyGenres/item">
<div class="category_box">
<input type="checkbox" id="getf{sc:fld('@id',.)}" name="getfItem" value="{sc:fld('title',.)}" />
<label for="get{sc:fld('@id',.)}"><xsl:value-of select="sc:fld('title',.)" /></label>
</div>
</xsl:for-each>
</xsl:when>
</div>
<div class="clearfix"></div>
</div>
</xsl:if>
<xsl:call-template name="PrintTitles">
<xsl:with-param name="ids" select="substring-after($ids, '|')"/>
</xsl:call-template>
</xsl:if>
ご覧いただきありがとうございます。