2014-12-30 11 views
6

पर हल नहीं कर सकता है, मैं स्कीमा को परिभाषित कर रहा हूं लेकिन इसे ग्रहण में मान्य करने पर यह निम्न त्रुटि देता है।एक्सएसडी: नाम 'प्रकार' को एक (एन) 'टाइप परिभाषा' घटक

src-resol: नाम 'सामान्य: नाम' को एक (एन) 'प्रकार परिभाषा' घटक में हल नहीं किया जा सकता है।

मेरे स्कीमा ऐसा दिखाई देता है:

<?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> 

..... 

और common_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> 
...... 

समस्या की तरह दिखता है मेरी स्कीमा common_v1.xsd से तत्वों में से कुछ को हल करने में सक्षम है और कुछ नहीं उपर्युक्त कोड सामान्य में: आईडी कोई त्रुटि नहीं देती है लेकिन आम: नाम त्रुटि देता है।

मुझे समझ में नहीं आता कि कुछ तत्वों का समाधान क्यों नहीं किया जाता है।

उत्तर

4

आप की तरह आप 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 या इसके बजाय <xsd:element ref="common:Name" .../> का उपयोग करें।

1
<?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> 
संबंधित मुद्दे