使用文档 DTD 我做了以下事情:
文件.xsl:
<!DOCTYPE xsl:stylesheet[
<!ENTITY red "rgb(255,0,0)">
]>
<xsl:stylesheet>
[...]
<xsl:attribute name="color">&red;</xsl:attribute>
[...]
</xsl:stylesheet>
我想将所有内容都更改为 XML-Schema。所以我尝试了:
文件.xsd:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="red" type="xs:token" fixed="rgb(255,0,0)" />
</xsd:schema>
文件.xsl:
<xsl:stylesheet
xmlns:defs="http://www.w3.org/2001/XMLSchema-instance"
defs:noNamespaceSchemaLocation="file.xsd">
[...]
<xsl:attribute name="color"><defs:red/></xsl:attribute>
[...]
</xsl:stylesheet>
现在通过 Xalan red 解析文件不像 DTD 版本那样被翻译。我的错误在哪里?解析过程中是否不读取 Schema 文件?