我正在尝试使用 XSLT 将多项选择题类型的 QTI 标准 xml 转换为 XHTML 文件。我发现从“simpleChoice”标签值中删除第一个“p”标签有困难。
以下是我试图转换为 XHTML 的 QTI
<?xml version="1.0" encoding="utf-8"?>
<assessmentItem xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p1 http://www.imsglobal.org/xsd/imsqti_v2p1.xsd" identifier="choice" title="Item Title will come here" adaptive="false" timeDependent="false" xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier">
<correctResponse>
<value>ChoiceA</value>
</correctResponse>
</responseDeclaration>
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="integer">
<defaultValue>
<value>0</value>
</defaultValue>
</outcomeDeclaration>
<itemBody>
<div id="item">
<div id="instruction">Select the correct options</div>
<choiceInteraction responseIdentifier="RESPONSE" shuffle="false" maxChoices="1">
<prompt>
<div id="stem">
<p>Question will appear here</p>
</div>
</prompt>
<simpleChoice identifier="ChoiceA"><p> answer's first P tag</p> <p> answer's second P tag</p> <p> answer's third P tag</p> <p> answer's forth P tag</p> and text without p tag</simpleChoice>
<simpleChoice identifier="ChoiceB"><p> answer's first P tag</p> <p> answer's second P tag</p> <p> answer's third P tag</p> <p> answer's forth P tag</p> and text without p tag</simpleChoice>
<simpleChoice identifier="ChoiceC"><p> answer's first P tag</p> <p> answer's second P tag</p> <p> answer's third P tag</p> <p> answer's forth P tag</p> and text without p tag</simpleChoice>
<simpleChoice identifier="ChoiceD"><p> answer's first P tag</p> <p> answer's second P tag</p> <p> answer's third P tag</p> <p> answer's forth P tag</p> and text without p tag</simpleChoice>
<simpleChoice identifier="ChoiceE"><p> answer's first P tag</p> <p> answer's second P tag</p> <p> answer's third P tag</p> <p> answer's forth P tag</p> and text without p tag</simpleChoice>
</choiceInteraction>
</div>
</itemBody>
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct" />
</assessmentItem>
我正在查看选项的以下输出
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div id="option1">
<label>A.</label>
<div class="optionContent">answer's first P tag<p> answer's second P tag</p> <p> answer's third P tag</p> <p> answer's forth P tag</p> and text without p tag</div>
</div>
<div id="option2">
<label>B.</label>
<div class="optionContent">answer's first P tag<p> answer's second P tag</p> <p> answer's third P tag</p> <p> answer's forth P tag</p> and text without p tag</div>
</div>
<div id="option3">
<label>C.</label>
<div class="optionContent">answer's first P tag<p> answer's second P tag</p> <p> answer's third P tag</p> <p> answer's forth P tag</p> and text without p tag</div>
</div>
<div id="option4">
<label>D.</label>
<div class="optionContent">answer's first P tag<p> answer's second P tag</p> <p> answer's third P tag</p> <p> answer's forth P tag</p> and text without p tag</div>
</div>
<div id="option5">
<label>E.</label>
<div class="optionContent">answer's first P tag<p> answer's second P tag</p> <p> answer's third P tag</p> <p> answer's forth P tag</p> and text without p tag</div>
</div>
</body>
</html>
我需要的期望输出是从“simpleChoice”标签中删除第一个“p”标签。
我曾尝试使用以下样式来做到这一点
<xsl:for-each select="//simpleChoice[$vCurrentIndex]/*">
<xsl:choose>
<xsl:when test="local-name() = 'p' and position() = 1">
<xsl:apply-templates select="node()|@*" mode="children" />
</xsl:when>
<xsl:otherwise>
<xsl:element name="{local-name()}">
<xsl:apply-templates select="node()|@*" mode="children" />
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
这样做后,我得到以下输出。输出不考虑任何不在 P 标签内的值。仅获取三个 P 标签的输出。
<div class="optionContent">answer's second P tag<p> answer's third P tag</p> <p> answer's forth P tag</p></div>
你的帮助真的会帮助我。提前致谢