xslt - 如何使用 XSLT 将现有 HTML 文本复制到新部分?
问题描述
我正在尝试编写一个 XSLT 脚本,它将<section property="ktp:explanation-section" typeof="ktp:feedback" class="ktp-explanation-section" data-title="Feedback">
从下面的 html 复制本节中的文本:
<ol class="ktp-answer-set">
<li property="ktp:answer" typeof="ktp:Answer">“I cough in the morning, but it stops.”
<section property="ktp:explanation" typeof="ktp:Explanation" class="ktp-explanation jasper-exclude">
<section property="ktp:explanation-section" typeof="ktp:feedback" class="ktp-explanation-section" data-title="Feedback">
<p>Captopril is an angiotensin-converting enzyme inhibitor (ACE-I) that has a dry, hacking, persistent cough as an adverse effect. The client reports a morning cough that may or may not be associated with the medication.</p>
</section>
</section>
</li>
<li property="ktp:answer" typeof="ktp:AnswerCorrect">“I am waiting to learn the results of my pregnancy test.”
<section property="ktp:explanation" typeof="ktp:Explanation" class="ktp-explanation jasper-exclude">
<section property="ktp:explanation-section" typeof="ktp:feedback" class="ktp-explanation-section" data-title="Feedback">
<p>ACE-Is are contraindicated in pregnancy. There is a black box warning that states ACE-I can cause injury and even death to a developing fetus. Since the client reports waiting for the results of a pregnancy test, this should be reported immediately to the health care provider.</p>
</section>
</section>
</li>
</ol>
进入一个如下所示的新部分:
<section property="ktp:explanation-section" typeof="ktp:feedback" data-title="Feedback" class="ktp-explanation-section atom-exclude">
<p class="atom-exclude">1)
<span class="mark-false">INCORRECT</span> – Captopril is an angiotensin-converting enzyme inhibitor (ACE-I) that has a dry, hacking, persistent cough as an adverse effect. The client reports a morning cough that may or may not be associated with the medication.
</p>
<p class="atom-exclude">2)
<span class="mark-true">CORRECT</span> – ACE-Is are contraindicated in pregnancy. There is a black box warning that states ACE-I can cause injury and even death to a developing fetus. Since the client reports waiting for the results of a pregnancy test, this should be reported immediately to the health care provider.
</p>
</section>
我需要在我的 XSLT 脚本中包含哪些内容才能将该文本复制到新部分中?我可以用 1)、2) 等给每个人编号吗?
在我使用的样式表下方:
<xsl:template match="xhtml:section[@property = 'ktp:explanation']">
<xsl:param name="content-item-name"/>
<!-- Tab 1: Decision Tree -->
<section>
<xsl:apply-templates select="@*"/>
<xsl:choose>
<xsl:when test="$content-item-name = $input-qid">
<section property="ktp:explanation-section" typeof="ktp:feedback" data-title="Feedback"
class="ktp-explanation-section atom-exclude">
<xsl:for-each select="//xhtml:section[property='ktp:explanation-section']/p">
<p class="atom-exclude">
<xsl:apply-templates select="@*"/>
</p>
</xsl:for-each>
</section>
<xsl:apply-templates select="node() except xhtml:section[@data-title = 'Feedback']"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</section>
</xsl:template>
解决方案
推荐阅读
- vue.js - 如何使用 vue 路由器打开对话框(设置组件状态)?
- html - 如何单独更改数组中的颜色?
- shell - 基于过滤器在awk中打印列的子字符串
- kubernetes - kubeadm搭建的k8s集群如何重启kubernetes kube-scheduler
- c++ - 我收到一个模板错误,我不知道为什么
- angular - 一系列 HTTP 请求没有按顺序出现。然后可能会在最后一个请求上显示旧请求
- email - 即使在域上设置了 SPF 和 DKIM,钓鱼邮件如何通过?
- iphone - 在 iPhone 上使用 OWASP ZAP 检测 protobuf REST api
- vue.js - Vue.js 属性或方法“addToCart”未在实例上定义
- java - 在任何位置包含至少一个字母数字字符的字符串的 Java 正则表达式