Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Eclipse XSD:无法解析名称';类型';到a(n)和"x27 ;;类型定义';成分_Eclipse_Xsd_Xsd Validation - Fatal编程技术网

Eclipse XSD:无法解析名称';类型';到a(n)和"x27 ;;类型定义';成分

Eclipse XSD:无法解析名称';类型';到a(n)和"x27 ;;类型定义';成分,eclipse,xsd,xsd-validation,Eclipse,Xsd,Xsd Validation,我正在定义模式,但在eclipse中验证它时,会出现以下错误 src resolve:无法将名称“common:name”解析为(n)“类型定义”组件 我的模式如下所示: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://www.mycompany.com/myproject/service/v1" xmlns:xsd="http://www.w3.or

我正在定义模式,但在eclipse中验证它时,会出现以下错误

src resolve:无法将名称“common:name”解析为(n)“类型定义”组件

我的模式如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.mycompany.com/myproject/service/v1"              xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:tns="http://www.mycompany.com/myproject/service/v1"            
        xmlns:product="http://www.mycompany.com/otherproject/service/products/v1"
        xmlns:common="http://www.mycompany.com/myproject/service/common/v1" elementFormDefault="qualified">

<xsd:import namespace="http://www.mycompany.com/otherproject/service/products/v1" schemaLocation="products_v1.xsd" />
<xsd:import namespace="http://www.mycompany.com/myproject/service/common/v1" schemaLocation="common_v1.xsd" />          

<xsd:element name="GetProductRequest" type="tns:GetProductRequest">
    <xsd:annotation>
        <xsd:documentation>Get Product Request</xsd:documentation>
    </xsd:annotation>
</xsd:element>  

<xsd:complexType name="GetProuctRequest">
    <xsd:annotation>
        <xsd:documentation>Get Product Request</xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>

        <xsd:element name="ID" type="common:ID" minOccurs="1" maxOccurs="1">
            <xsd:annotation>
                <xsd:documentation>ID</xsd:documentation>
            </xsd:annotation>
        </xsd:element>


        <xsd:element name="Name" type="common:Name" minOccurs="1" maxOccurs="1">
            <xsd:annotation>
                <xsd:documentation>Name</xsd:documentation>
            </xsd:annotation>
        </xsd:element>  

    </xsd:sequence>
</xsd:complexType>

.....

获取产品请求
获取产品请求
身份证件
名称
.....
公共_v1.xsd如下所示

<xsd:schema targetNamespace="http://www.mycompany.com/myproject/service/common/v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:tns="http://www.mycompany.com/myproject/service/common/v1" 
        elementFormDefault="qualified">


<xsd:complexType name="ID">
    <xsd:annotation>
        <xsd:documentation>ID</xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
        <xsd:element name="X" type="xsd:string" minOccurs="1" maxOccurs="1">
            <xsd:annotation>
                <xsd:documentation>X</xsd:documentation>
            </xsd:annotation>
        </xsd:element>
        <xsd:element name="Y" type="xsd:string" minOccurs="1" maxOccurs="1">
            <xsd:annotation>
                <xsd:documentation>Y</xsd:documentation>
            </xsd:annotation>
        </xsd:element>
    </xsd:sequence>
</xsd:complexType>  

<xsd:element name="Name" type="xsd:string">
    <xsd:annotation>
        <xsd:documentation>Name</xsd:documentation>
    </xsd:annotation>
</xsd:element>
......

身份证件
X
Y
名称
......
问题是我的模式能够解析common_v1.xsd中的一些元素,而有些元素则不能。在上面的代码中,common:ID没有给出任何错误,但是common:Name给出了错误


我无法理解为什么某些元素没有解析。

从您显示的内容来看,您在
公共
命名空间中似乎有一个元素
名称
,但没有该类型,并且您正在尝试在此处使用该类型:

    <xsd:element name="Name" type="common:Name" minOccurs="1" maxOccurs="1">
        <xsd:annotation>
            <xsd:documentation>Name</xsd:documentation>
        </xsd:annotation>
    </xsd:element>

名称
因此,要么创建一个类型
common:Name
,要么改用


<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" 
targetNamespace="http://www.bharatsecurity.com/Patients"
 xmlns:tns="http://www.bharatsecurity.com/Patients" 
 elementFormDefault="qualified">
<element name="patient" type="tns:Patients"></element>

you need to write complex type for this tns otherwise it will result in cannot resolve type (n) error  like :- 


<complexType name="Patients">
<sequence>
<element name="id" type="int" />
<element name="name" type="string"></element>
<element name="gender" type="string"></element>
<element name="age" type="int"></element>
</sequence>
</complexType>
</schema>
您需要为此tns写入复杂类型,否则将导致无法解析类型(n)错误,如:-