2011-10-13 13 views
6

मैं निम्नलिखित XSD से एक प्रमाणीकरण त्रुटि हो रही है:XSD त्रुटि: चरित्र सामग्री की अनुमति नहीं है क्योंकि सामग्री प्रकार खाली है

<?xml version="1.0" ?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <xsd:element name="People"> 
     <xsd:complexType> 
     <xsd:sequence> 
      <xsd:element name="Person" maxOccurs="unbounded"> 
       <xsd:complexType> 
        <xsd:attribute name="name" type="xsd:string" use="required" /> 
       </xsd:complexType> 
      </xsd:element> 
     </xsd:sequence> 
     </xsd:complexType> 
    </xsd:element> 
</xsd:schema> 

जब निम्न XML का उपयोग मान्य करने के लिए:

<?xml version="1.0" ?> 
<People> 
    <Person name='john'> 
     a nice person 
    </Person> 
    <Person name='sarah'> 
     a very nice person 
    </Person> 
    <Person name='chris'> 
     the nicest person in the world 
    </Person> 
</People> 

रिटर्न निम्न त्रुटि:

lxml.etree.XMLSyntaxError: Element 'Person': Character content is not allowed, because the content type is empty. 

मैं क्या याद आ रही है?

उत्तर

13

यह कह रहा है कि "व्यक्ति" में एक स्ट्रिंग शामिल नहीं हो सकती है। एक्सएमएल कि XSD उपयोग के साथ मान्य करने के लिए के लिए यह:

<?xml version="1.0" ?> 
<People> 
    <Person name='john'> 
    </Person> 
    <Person name='sarah'> 
    </Person> 
    <Person name='chris'> 
    </Person> 
</People> 

सत्यापन के लिए XSD के लिए इस प्रयास करें:

<?xml version="1.0" ?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <xsd:element name="People"> 
     <xsd:complexType> 
     <xsd:sequence> 
     <xsd:element name="Person" type="Person" maxOccurs="unbounded"/> 
     </xsd:sequence> 
     </xsd:complexType> 
    </xsd:element> 

    <xsd:complexType name="Person"> 
    <xsd:simpleContent> 
     <xsd:extension base="xsd:string"> 
      <xsd:attribute name="name" type="xsd:string" use="required" /> 
     </xsd:extension> 
    </xsd:simpleContent> 
    </xsd:complexType> 
</xsd:schema> 
+0

क्या मैं (एक्सएमएल में तार जोड़ने के लिए XSD को जोड़ने की जरूरत है के तहत कर व्यक्ति तत्व)? – Russell

+0

मेरी पोस्ट संपादित की गई। कृपया जांचें। –

संबंधित मुद्दे