如何让XSLT脚本绕过特定文本?
如何告诉XSLT脚本不要复制包含“策略:”的段落 对不起,所有的代码,但这应该包括所有的信息,给我的问题 这是我的XSLT模板:如何让XSLT脚本绕过特定文本?,xslt,Xslt,如何告诉XSLT脚本不要复制包含“策略:”的段落 对不起,所有的代码,但这应该包括所有的信息,给我的问题 这是我的XSLT模板: <xsl:when test="xhtml:li[@property = 'ktp:answer']"> <xsl:for-each select="xhtml:li[@property = 'ktp:answer']"> &
<xsl:when test="xhtml:li[@property = 'ktp:answer']">
<xsl:for-each select="xhtml:li[@property = 'ktp:answer']">
<xsl:variable name="answerNum" select="position()"/>
<xsl:variable name="feedbackPara"
select="../following-sibling::xhtml:section[@property = 'ktp:explanation']/xhtml:section[@property = 'ktp:explanation-section'][1]/xhtml:p[$answerNum]"/>
<xsl:variable name="feedbackParaText"
select="../following-sibling::xhtml:section[@property = 'ktp:explanation']/xhtml:section[@property = 'ktp:explanation-section'][1]/xhtml:p[$answerNum]/text()[string-length(normalize-space()) > 1][preceding-sibling::xhtml:span[contains(@class, 'mark-')[last()]] | preceding-sibling::xhtml:b[1]]"/>
<xsl:variable name="correctSpan"
select="../following-sibling::xhtml:section[@property = 'ktp:explanation']/xhtml:section[@property = 'ktp:explanation-section'][1]/xhtml:p[$answerNum]/xhtml:span"/>
<!--<xsl:variable name="tokenizefeedbackPara">
<xsl:value-of select="tokenize(normalize-space($feedbackPara), '\s')"/>
</xsl:variable>-->
<li>
<xsl:apply-templates select="@* | node()"/>
<xsl:choose>
<xsl:when
test="//xhtml:span[@property = 'ktp:interactionType'][node() = 'single-select' or node() = 'multiple-select']">
<section property="ktp:explanation" typeof="ktp:Explanation"
class="ktp-explanation jasper-exclude">
<xsl:attribute name="data-uuid">
<xsl:call-template name="assignID"/>
</xsl:attribute>
<section property="ktp:explanation-section"
typeof="ktp:feedback" data-title="Feedback"
class="ktp-explanation-section">
<xsl:attribute name="data-uuid">
<xsl:call-template name="assignID"/>
</xsl:attribute>
<p>
<xsl:attribute name="data-uuid">
<xsl:call-template name="assignID"/>
</xsl:attribute>
<xsl:choose>
<xsl:when
test="$feedbackPara[xhtml:b | xhtml:span | xhtml:i | xhtml:sup | xhtml:sub]">
<xsl:choose>
<xsl:when test="$feedbackPara[xhtml:i | xhtml:sup | xhtml:sub]">
<xsl:apply-templates
select="$feedbackPara/node()[position() > 2] except $correctSpan"
/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="
substring-after($feedbackParaText, functx:substring-before-match(
$feedbackParaText, '[A-Z0-9]'))"
/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="substring-after($feedbackPara, ') ')"/>
</xsl:otherwise>
</xsl:choose>
</p>
</section>
</section>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</li>
</xsl:for-each>
</xsl:when>
这是我得到的输出。对于答案选择1,它在“策略:”之后输出内容。我需要它跳过策略段落,只包括以1)、2)、3)和4)开头的段落
厨师沙拉、饼干和冰
茶。
召回那些
蛋白质含量高。
烤鱼、奶油番茄汤
上面是磨碎的奶酪和奶油冻。
厨师沙拉含有火腿和奶酪,它们含有蛋白质。饼干和冰镇饼干
茶不含蛋白质。选择的大多数食物不含蛋白质。
花生酱和果冻三明治,
薯条和水果饮料。
所有选择的食物都含有蛋白质。添加脱脂牛奶可以增加蛋白质含量
适当的食物,在食物中加入磨碎的奶酪,使用花生酱作为铺盖
在水果和蔬菜上,使用酸奶作为水果和蛋糕的配料。
土耳其生菜三明治
西红柿、土豆沙拉和牛奶。
花生酱含有蛋白质,但其他食物不含蛋白质
这是所需的输出,将答案选项1)的解释置于正确答案选项下:
<ol class="ktp-answer-set">
<li property="ktp:answer" typeof="ktp:Answer">Chef salad, crackers, and iced
tea.
<section property="ktp:explanation" typeof="ktp:Explanation" class="ktp-explanation jasper-exclude">
<section property="ktp:explanation-section" typeof="ktp:feedback" data-title="Feedback" class="ktp-explanation-section">
<p>A chef salad contains pieces of ham and cheese, which have protein. Crackers and iced tea do not contain protein. The majority of foods selected do not contain protein.
</p>
</section>
</section>
</li>
<li property="ktp:answer" typeof="ktp:AnswerCorrect">Broiled fish, cream of tomato soup
topped with grated cheese, and custard.
<section property="ktp:explanation" typeof="ktp:Explanation" class="ktp-explanation jasper-exclude">
<section property="ktp:explanation-section" typeof="ktp:feedback" data-title="Feedback" class="ktp-explanation-section">
<p>All foods selected contain protein. Protein can be increased by adding skim milk to appropriate foods, adding grated cheese to foods, using peanut butter as a spread on fruits and vegetables, using yogurt as a topping for fruit and cake.
</p>
</section>
</section>
</li>
<li property="ktp:answer" typeof="ktp:Answer">Peanut butter and jelly sandwich,
chips, and fruit drink.
<section property="ktp:explanation" typeof="ktp:Explanation" class="ktp-explanation jasper-exclude">
<section property="ktp:explanation-section" typeof="ktp:feedback" data-title="Feedback" class="ktp-explanation-section">
<p>Peanut butter contains protein, but the other foods do not.
</p>
</section>
</section>
</li>
<li property="ktp:answer" typeof="ktp:Answer">Turkey sandwich with lettuce and
tomato, potato salad, and milk.
<section property="ktp:explanation" typeof="ktp:Explanation" class="ktp-explanation jasper-exclude">
<section property="ktp:explanation-section" typeof="ktp:feedback" data-title="Feedback" class="ktp-explanation-section">
<p>Turkey and milk contain protein, but potato salad very little if any.</p>
</section>
</section>
</li>
</ol>
厨师沙拉、饼干和冰
茶。
厨师沙拉含有火腿和奶酪,它们含有蛋白质。饼干和冰茶不含蛋白质。选择的大多数食物不含蛋白质。
烤鱼、奶油番茄汤
上面是磨碎的奶酪和奶油冻。
所有选择的食物都含有蛋白质。在适当的食物中添加脱脂牛奶,在食物中添加磨碎的奶酪,在水果和蔬菜上涂抹花生酱,在水果和蛋糕上添加酸奶,可以增加蛋白质含量。
花生酱和果冻三明治,
薯条和水果饮料。
花生酱含有蛋白质,
<ol class="ktp-answer-set">
<li property="ktp:answer" typeof="ktp:Answer">Chef salad, crackers, and iced
tea.
<section property="ktp:explanation" typeof="ktp:Explanation" class="ktp-explanation jasper-exclude">
<section property="ktp:explanation-section" typeof="ktp:feedback" data-title="Feedback" class="ktp-explanation-section">
<p>A chef salad contains pieces of ham and cheese, which have protein. Crackers and iced tea do not contain protein. The majority of foods selected do not contain protein.
</p>
</section>
</section>
</li>
<li property="ktp:answer" typeof="ktp:AnswerCorrect">Broiled fish, cream of tomato soup
topped with grated cheese, and custard.
<section property="ktp:explanation" typeof="ktp:Explanation" class="ktp-explanation jasper-exclude">
<section property="ktp:explanation-section" typeof="ktp:feedback" data-title="Feedback" class="ktp-explanation-section">
<p>All foods selected contain protein. Protein can be increased by adding skim milk to appropriate foods, adding grated cheese to foods, using peanut butter as a spread on fruits and vegetables, using yogurt as a topping for fruit and cake.
</p>
</section>
</section>
</li>
<li property="ktp:answer" typeof="ktp:Answer">Peanut butter and jelly sandwich,
chips, and fruit drink.
<section property="ktp:explanation" typeof="ktp:Explanation" class="ktp-explanation jasper-exclude">
<section property="ktp:explanation-section" typeof="ktp:feedback" data-title="Feedback" class="ktp-explanation-section">
<p>Peanut butter contains protein, but the other foods do not.
</p>
</section>
</section>
</li>
<li property="ktp:answer" typeof="ktp:Answer">Turkey sandwich with lettuce and
tomato, potato salad, and milk.
<section property="ktp:explanation" typeof="ktp:Explanation" class="ktp-explanation jasper-exclude">
<section property="ktp:explanation-section" typeof="ktp:feedback" data-title="Feedback" class="ktp-explanation-section">
<p>Turkey and milk contain protein, but potato salad very little if any.</p>
</section>
</section>
</li>
</ol>
<section property="ktp:explanation-section" typeof="ktp:summary" data-title="Summary" class="ktp-explanation-section">
<p><b>Strategy:</b> Recall foods that are high in protein.
</p>
<p>1) A chef salad contains pieces of ham and cheese, which have protein. Crackers and
iced tea do not contain protein. The majority of foods selected do not contain protein.
</p>
<p>2) <b>CORRECT</b> — All foods selected contain protein. Protein can be increased by adding skim milk
to appropriate foods, adding grated cheese to foods, using peanut butter as a spread
on fruits and vegetables, using yogurt as a topping for fruit and cake.
</p>
<p>3) Peanut butter contains protein, but the other foods do not.</p>
<p>4) Turkey and milk contain protein, but potato salad very little if any.</p>
</section>
<xsl:template match="x:section">
<xsl:apply-templates select="x:p"/>
</xsl:template>
<xsl:template match="x:p[contains(., 'Strategy')]"/>
<xsl:template match="x:p">
<xsl:copy-of select="."/>
</xsl:template>