Я добился некоторого прогресса благодаря ответу Мартина.
То, как у меня сейчас получается, скрипт работает правильно, когда присутствует номер идентификатора, но когда идентификатор отсутствует, он удаляет весь контент на странице. Как я могу это исправить?
Вот мой текущий скрипт:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xpath-default-namespace="http://www.w3.org/1999/xhtml">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- provide location of update table -->
<xsl:param name="QIDlist">NCQ0866</xsl:param>
<!-- use to pinpoint selected QIDs for transformation -->
<xsl:variable name="input-qid" select="tokenize($QIDlist, '\s+')"/>
<xsl:template match="/">
<xsl:apply-templates
select="node()[//span[@property = 'atom:content-item-name' and @class = 'ktp-meta' and @data-value = $input-qid]]"/>
</xsl:template>
<!-- identity transform -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="p/@class[. = 'atom-exclude']"> </xsl:template>
<xsl:template match="h1/@class[. = 'atom-exclude']"> </xsl:template>
</xsl:stylesheet>
Я пытаюсь сделать глобальное изменение, когда класс atom-exclude удален из этих абзацев:
<p class="atom-exclude">1) <span class="mark-false">INCORRECT</span> – The nurse should not start the series over again. The hepatitis B immunization is a set of three injections. The children should be scheduled for the second and third injections.</p>
И эти H1:
<h1 class="atom-exclude">Think Like a Nurse: Clinical Decision-Making</h1>
Но только по определенным вопросам, которые имеют конкретное значение data-item-name-name:
<section property="ktp:metadata" class="ktp-meta"><span property="atom:content-item-name" class="ktp-meta" data-value="NCQ0866"></span></section>