我的 XML 文件与 DTD 有问题。我做了定义:
<definitions>
<availableGrades>
<gradeDefinition name="Role-Playing Game" id="RPG" />
<gradeDefinition name="First Person Shooter" id="FPS" />
<gradeDefinition name="Real Time Strategy" id="RTS" />
<gradeDefinition name="Racing" id="RAC" />
<gradeDefinition name="Sport" id="SPO" />
<gradeDefinition name="Third Person Perspective" id="TPP" />
<gradeDefinition name="Logic" id="LOG" />
<gradeDefinition name="Arcade" id="ARC" />
<gradeDefinition name="Strategy" id="STR" />
<gradeDefinition name="Platform" id="PLA" />
<gradeDefinition name="Adventure" id="ADV" />
<gradeDefinition name="Fighting" id="FIG" />
<gradeDefinition name="Simulator" id="SIM" />
<gradeDefinition name="Other" id="OTH" />
</availableGrades>
并使用:
<game grade="FPS" />
在 DTD 中,我添加了 IDREF:
<!ELEMENT gradeDefinition EMPTY>
<!ATTLIST gradeDefinition
name NMTOKENS #REQUIRED
id ID #REQUIRED>
<!ATTLIST game grade IDREF #REQUIRED>
我通过 CSS 显示等级属性的值(内容:attr(等级)),但在浏览器中我看到例如 FPS。可以打印“第一人称射击游戏”而不是“FPS”(通过参考gradeDefinition 名称)?