目前我正在使用 XSLT 将 QTI 转换为 XHTML。
我有一个标签,其中可能有一些 html 标签。目前在以下示例中,我正在关注 QTI xml
<?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>D</value>
</correctResponse>
</responseDeclaration>
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="integer">
<defaultValue>
<value>0</value>
</defaultValue>
</outcomeDeclaration>
<itemBody>
<div id="item">
<choiceInteraction responseIdentifier="RESPONSE" shuffle="false" maxChoices="1">
<prompt>Question text appears here?</prompt>
<simpleChoice identifier="A">
<img src="a.gif" height="75px" width="75px" id="img0" alt=""></img>
</simpleChoice>
<simpleChoice identifier="B">
<img src="b.gif" height="75px" width="75px" id="img1" alt=""></img>
</simpleChoice>
<simpleChoice identifier="C">
<img src="c.gif" height="75px" width="75px" id="img2" alt=""></img>
</simpleChoice>
<simpleChoice identifier="D">
<img src="d.gif" height="75px" width="75px" id="img3" alt=""></img>
</simpleChoice>
<simpleChoice identifier="E">
<img src="e.gif" height="75px" width="75px" id="img4" alt=""></img>
</simpleChoice>
</choiceInteraction>
</div>
</itemBody>
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct" />
</assessmentItem>
我想检查 simpleChoice 标签是否有任何 img 标签作为子节点,然后我想将样式添加到<div class='content'>
输出标签,如下所示,如果 simpleChoice 标签没有 img 标签作为子节点,我想跳过样式属性到<div class='content'>
输出标签。
<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="wrapper">
<div id="item">
<div id="qtn">Question text appears here?</div>
<div id="inx">
<div id="ih1">
<div id="mc1">
<label id="l1">A.</label>
<div class="content" style='vertical-align:middle;display:inline-block'>
<img src="a.gif" height="75px" width="75px" id="img0" alt=""/>
</div>
</div>
</div>
<div id="ih2">
<div id="mc2">
<label id="l2">B.</label>
<div class="content" style='vertical-align:middle;display:inline-block'>
<img src="b.gif" height="75px" width="75px" id="img1" alt=""/>
</div>
</div>
</div>
<div id="ih3">
<div id="mc3">
<label id="l3">C.</label>
<div class="content" style='vertical-align:middle;display:inline-block'>
<img src="c.gif" height="75px" width="75px" id="img2" alt=""/>
</div>
</div>
</div>
<div id="ih4">
<div id="mc4">
<label id="l4">D.</label>
<div class="content" style='vertical-align:middle;display:inline-block'>
<img src="d.gif" height="75px" width="75px" id="img3" alt=""/>
</div>
</div>
</div>
<div id="ih5">
<div id="mc5">
<label id="l5">E.</label>
<div class="content" style='vertical-align:middle;display:inline-block'>
<img src="e.gif" height="75px" width="75px" id="img4" alt=""/>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>