【问题标题】:validation errors on validating xhtml11-model-1.xsd验证 xhtml11-model-1.xsd 时的验证错误
【发布时间】:2013-11-08 07:38:45
【问题描述】:

在生成 XML 文件时,我使用 OMG 定义的 xsd 文件。通过 Internet 进行验证需要很长时间。因此,我下载了所有这些文件以进行本地验证。这适用于简单的情况。但在未来,必须验证更复杂的结构。这包括验证 xhtml 结构。从http://www.w3.org/MarkUp/SCHEMA 下载的大多数 xsd 文件都有验证错误。在尝试解决它们时,我专注于文件 xhtml11-model-1.xsd 开始,因为该文件包含许多其他 xsd 文件使用的基本定义。初始下载文件显示 71 个验证错误!下载的文件没有声明目标名称空间,因此我添加了声明。这样做将错误数量减少到 4 个。但此时我被卡住了。我根本没有找到任何方法来纠正剩余的错误。我选择其中一个作为孤立案例进行分析。请参阅下面的代码。 attributeGroup name="xhtml.dir.attrib" 的声明可以在文件 xhtml-bdo-1.xsd 中找到。但是这个文件没有通过验证,因此我将声明复制到我的测试文件中,以便将所有内容放在一个地方。但是在使用 eclipse Kepler 验证这个简单的案例时,我在 xhtml.dir.attrib 的引用中得到以下错误:

<xs:attributeGroup ref="xhtml.dir.attrib" />
s4s-elt-must-match.1: The content of 'xhtml.I18n.extra.attrib' must match (annotation?, ((attribute | attributeGroup)*, anyAttribute?)). A problem was found starting at: attributeGroup.

怎么了?当声明显示正确时,为什么引用会声明错误。这是eclipse验证器的问题吗?我的误会?我应该简单地忽略这些验证错误吗?为什么从 w3.org 下载的 xsd 文件没有 targetNamespace 声明,因为它似乎需要验证和使用这些文件? 感谢您的任何提示。

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3.org/1999/xhtml/datatypes/" 
xmlns:xh11d="http://www.w3.org/1999/xhtml/datatypes/" 
elementFormDefault="qualified" >

<xs:attributeGroup name="xhtml.dir.attrib">
    <xs:annotation>
        <xs:documentation>
            "dir" Attribute from Bi Directional Text (bdo) Module
        </xs:documentation>
    </xs:annotation>
    <xs:attribute name="dir">
        <xs:simpleType>
            <xs:restriction base="xs:NMTOKEN">
                <xs:enumeration value="ltr" />
                <xs:enumeration value="rtl" />
            </xs:restriction>
        </xs:simpleType>
    </xs:attribute>
</xs:attributeGroup>

<xs:attributeGroup name="xhtml.I18n.extra.attrib">
    <xs:annotation>
        <xs:documentation>Extended I18n attribute</xs:documentation>
    </xs:annotation>
    <xs:attributeGroup ref="xhtml.dir.attrib" />
    <xs:attribute name="lang" type="xh11d:LanguageCode" />
</xs:attributeGroup>
</xs:schema>

【问题讨论】:

    标签: xml eclipse validation xsd


    【解决方案1】:

    对于您提供的特定 sn-p,如果您只是确保有一个与您的 targetNamespace 匹配的默认命名空间(我刚刚在another post 中对此进行了解释)并且您使别名为“xh11d”的命名空间可用于您的 XSD 处理器(不知何故,通过目录或直接xs:import)。

    我会说你不应该忽视验证错误,至少在你可以做出明智的决定之前不要忽视。

    我会下载 XSD,然后我自己看看;如果有什么有价值的事情发生,我会在这里告诉你。

    【讨论】:

    • 在我的 sn-p 添加默认命名空间时,错误消失了。到目前为止,提示是正确的。修改为:w3.org/2001/XMLSchema" xmlns="w3.org/1999/xhtml" targetNamespace="w3.org/1999/xhtml" xmlns:xh11d="w3.org/1999/xhtml/datatypes" elementFormDefault="qualified"> w3.org/1999/xhtml/datatypes" schemaLocation="xhtml-datatypes-1.xsd"/> 但这对原始xsd并没有真正的帮助,问题是,我为什么要从w3站点修改xsd?
    • 我想这些文件是公开的,已经过彻底的测试,为什么它们在 w3 站点工作而不是在本地工作?此外,我观察到循环依赖,这真的没有帮助!您如何处理此类案件?
    • 我个人认为这些文件没有经过彻底的测试。至少根据我可用的工具(基于 .NET 和 Java),一些 XSD 是无效的。 (我仍在研究它......例如,我在 aria-attributes-1.xsd 文件中的 aria-relevant 属性中得到一个 cvc-enumeration-invalid 的默认值......)循环依赖关系不好打包...但这应该不是问题...如果您删除所有架构位置并将所有文件手动放在架构集合中...循环依赖关系消失了,而内容仍然正确...
    • 感谢您确认我的发现。我已经开始将所有这些文件放在本地,并相应地更改架构位置。这是一项费力又无聊的工作。我讨厌 inutil 工作,所以对我来说重要的是,听取第三方的意见,不要犯错。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多