错误:检测到 X 位于命名空间 Y 中,但无法从架构文档中引用此命名空间中的组件 [英] Error: It was detected that X is in namespace Y, but components from this namespace are not referenceable from schema document

查看:28
本文介绍了错误:检测到 X 位于命名空间 Y 中,但无法从架构文档中引用此命名空间中的组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个 xsd 元素有什么问题?

What's wrong in this xsd elements?

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:complexType name="MessageInfoType">
        <xsd:sequence>
            <xsd:element minOccurs="0" maxOccurs="1" name="TimeStamp" type="xsd:string" />
        </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="GetData">
        <xsd:annotation>
            <xsd:documentation>Send data</xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element minOccurs="1" name="MessageInfo" type="xsd:MessageInfoType" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

出现错误 MessageInfoType 未声明.

Getting error MessageInfoType is not declared.

推荐答案

错误信息,

src-resolve.4.2:解析组件xsd:MessageInfoType"时出错.它检测到xsd:MessageInfoType"在命名空间中'http://www.w3.org/2001/XMLSchema',但是来自这里的组件命名空间不能从架构文档中引用XSD 文件名.如果这是不正确的命名空间,可能是 'xsd:MessageInfoType' 的前缀需要被改变.如果这是正确的命名空间,则适当的'import' 标签应该添加到XSD 文件名.

src-resolve.4.2: Error resolving component 'xsd:MessageInfoType'. It was detected that 'xsd:MessageInfoType' is in namespace 'http://www.w3.org/2001/XMLSchema', but components from this namespace are not referenceable from schema document XSD filename. If this is the incorrect namespace, perhaps the prefix of 'xsd:MessageInfoType' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to XSD filename.

当组件被引用但未在给定命名空间中找到时发生.

occurs when a component is referenced but not found in the given namespace.

在您的情况下,您通过向 type="xsd:MessageInfoType" 添加不必要的命名空间前缀和不必要的默认命名空间前缀来阻止成功引用 MessageInfoType在 XSD 根元素上.

In your case, you've prevented successful referencing of the MessageInfoType by adding an unnecessary namespace prefix to type="xsd:MessageInfoType" and an unnecessary default namespace prefix on the XSD root element.

如何解决:xsd:schema 中删除默认命名空间声明,并从 type="xsd:MessageInfoType" 中删除命名空间前缀> 关于MessageInfo的声明:

How to fix: Remove the default namespace declaration from xsd:schema, and remove the namespace prefix from type="xsd:MessageInfoType" on the declaration of MessageInfo:

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema elementFormDefault="qualified"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:complexType name="MessageInfoType">
    <xsd:sequence>
      <xsd:element name="TimeStamp" type="xsd:string"
                   minOccurs="0" maxOccurs="1" />
    </xsd:sequence>
  </xsd:complexType>
  <xsd:element name="GetData">
    <xsd:annotation>
      <xsd:documentation>Send data</xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="MessageInfo" type="MessageInfoType"
                     minOccurs="1" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

然后错误信息就会消失.

Then the error message will go away.

这篇关于错误:检测到 X 位于命名空间 Y 中,但无法从架构文档中引用此命名空间中的组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆