Как скопировать существующий текст HTML в новый раздел с помощью XSLT? - PullRequest
0 голосов
/ 31 января 2020

Я пытаюсь написать сценарий 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) и т. Д. c?

Ниже таблицы стилей, с которой мне было поручено работать:

<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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...