自定义XML Schema中无法解析'xhtml.div.type'符号问题求解
问题排查与解决方案
你遇到的类型无法解析报错是由两处命名空间配置错误导致的:
- 命名空间导入配置错误:
xs:import标签的namespace属性需要填写你要引入的schema的目标命名空间,而非schema文件的访问地址。xhtml-blkstruct-1.xsd对应的目标命名空间是标准XHTML命名空间http://www.w3.org/1999/xhtml,你当前错误填写为了schema文件的URL。 - 前缀绑定错误:你给
xh11blk前缀绑定的地址是schema文件的URL,应该改为绑定上述正确的XHTML标准命名空间,才能正确匹配到目标类型。
修正后的完整Schema代码
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xs:schema id="story" elementFormDefault="qualified" targetNamespace="https://example.com" xmlns="https://example.com" xmlns:tns="https://example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xh11blk="http://www.w3.org/1999/xhtml" > <xs:import namespace="http://www.w3.org/1999/xhtml" schemaLocation="https://www.w3.org/MarkUp/SCHEMA/xhtml-blkstruct-1.xsd"/> <xs:complexType mixed="true" name="CustomXHTML"> <xs:complexContent> <xs:extension base="xh11blk:xhtml.div.type"/> </xs:complexContent> </xs:complexType> </xs:schema>
修正后IDE即可正常解析xhtml.div.type类型,你可以直接基于这个扩展类型自定义对应的XHTML元素。
内容的提问来源于stack exchange,提问作者davidmpaz
相关产品推荐
相关产品推荐

