2009-09-09 10 views
6

मैं एक साधारण एक्सएमएल के लिए एक एक्सएमएल स्कीमा डाल रहा हूं (दोनों एक्सएमएल और स्कीमा के लिए बेलो देखें)। लेकिन मुझे सेक्शन नोड के संबंध में निम्न त्रुटि मिलती है: "तत्व में सफेद स्थान नहीं हो सकता है। सामग्री मॉडल खाली है।" । नेट ब्राउजिंग करने के लिए मुझे कोई संक्षिप्त स्पष्टीकरण नहीं मिला क्योंकि इसका अर्थ यह है कि मैं इसे ठीक कर सकता हूं। क्या कोई मदद कर सकता है?त्रुटि क्या है "तत्व में सफेद स्थान नहीं हो सकता है। सामग्री मॉडल खाली है।" क्या मतलब है?

संपादित करें: स्कीमा के साथ सहायता प्रदान करने के लिए सभी के लिए धन्यवाद। मुझे लगता है कि यह एक संक्षिप्त वर्णन करने में मदद करेगा कि सामग्री मॉडल क्या है और यह यहां खाली क्यों है।

एक्सएमएल:

<config> 
    <section name="facets"> 
     <facet type="format" label="Format" max="4"/> 
     <facet type="language" max="4"/> 
     <facet type="pubdate" max="6" submax="8"/> 
     <facet type="ice_topic" label="Fiction: Topic"/> 
    </section> 
</config> 

स्कीमा:

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="config"> 
     <xs:complexType> 
     <xs:sequence> 
      <xs:element name="section" type="sectionBase"/> 
     </xs:sequence> 
     </xs:complexType> 
    </xs:element> 
    <xs:complexType name="sectionBase"> 
     <xs:attribute name="name" type="xs:ID"/> 
    </xs:complexType> 


    <xs:complexType name="sectionFacets" > 
     <xs:complexContent> 
     <xs:extension base="sectionBase"> 
      <xs:sequence> 
       <xs:element name="facet" type="sectionFacetsBaseFacet"/> 
      </xs:sequence> 
     </xs:extension> 
     </xs:complexContent> 
    </xs:complexType> 
    <xs:complexType name="sectionFacetsBaseFacet"> 
     <xs:attribute name="label" type="xs:ID"/> 
     <xs:attribute name="max" type="xs:positiveInteger"/> 
    </xs:complexType> 
    <xs:complexType name="sectionFacetsFormat"> 
     <xs:complexContent> 
     <xs:extension base="sectionFacetsBaseFacet"/> 
     </xs:complexContent> 
    </xs:complexType> 
    <xs:complexType name="sectionFacetsPubdate"> 
     <xs:complexContent> 
     <xs:extension base="sectionFacetsBaseFacet"> 
      <xs:attribute name="submax" type="xs:positiveInteger"/> 
     </xs:extension> 
     </xs:complexContent> 

    </xs:complexType> 
</xs:schema> 

उत्तर

2

के पहलू की लेबल विशेषता section तत्व के प्रकार बदलने का प्रयास करें XS के लिए सेट है: आईडी और इस रिक्त स्थान की अनुमति नहीं है। आप इसके बजाय xs: स्ट्रिंग का उपयोग करना चाह सकते हैं।

+0

एलेक्स की आवश्यकता है, मैं आपका जवाब स्वीकार करता हूं क्योंकि यह सही है। मैं अभी भी समझना चाहता हूं कि सामग्री मॉडल भाग का क्या अर्थ है। कोई उपाय? – Boaz

+2

सामग्री मॉडल के बारे में सामग्री पढ़ना: http://www.stylusstudio.com/w3c/schema0/groups.htm –

0

आपका section तत्व प्रकार sectionBase के रूप में परिभाषित किया गया है, और sectionBase प्रकार परिभाषा केवल एक ही विशेषता परिभाषित करता है। sectionFacets प्रकार पर स्कीमा में कहीं भी कोई संदर्भ नहीं है, जो शायद आपको चाहिए।

sectionFacets

+0

ठीक - कि काम करेगा, लेकिन मैं करने के लिए आधार प्रकार sectionBase तैयार एकाधिक सेक्शन प्रकार की अनुमति दें, जिनमें से केवल एक ही अनुभागफैकेट है। क्या सुझाव यह अनुमति नहीं देगा। – Boaz

+0

लगता है जैसे आपको एक प्रतिस्थापन समूह – skaffman

1

हमारी स्कीमा में कई समस्याएं हैं क्योंकि अन्य पहले ही उल्लेख कर चुके हैं। कुछ इस तरह का प्रयास करें:

एक्स्टेंसिबल स्कीमा:

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <!-- never used; just to be extended --> 
    <xs:complexType name="sectionBaseType" abstract="true"> 
     <xs:attribute name="name" type="xs:ID"/> 
    </xs:complexType> 

    <!-- extension of the sectionBaseType --> 
    <xs:complexType name="sectionSpecialized"> 
     <xs:complexContent> 
      <xs:extension base="sectionBaseType"> 
       <xs:sequence> 
        <xs:element name="facet" type="leftToTheReaderType" 
         maxOccurs="unbounded"/> 
       </xs:sequence> 
      </xs:extension> 
     </xs:complexContent> 
    </xs:complexType> 

    <!-- config may contain a single section or one of its extensions --> 
    <xs:complexType name="configType"> 
     <xs:sequence> 
      <xs:element name="section" type="sectionBaseType"/> 
     </xs:sequence> 
    </xs:complexType> 

    <!-- a single root node called "config" --> 
    <xs:element name="config" type="configType"/> 
</xs:schema> 

स्कीमा उपयोग कैसे करें:

<?xml version="1.0" encoding="UTF-8"?> 
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <!-- note the xsi:type to specify the actual type of the section!! --> 
    <section name="facets" 
     xsi:type="sectionSpecialized"> 
     <facet .../> 
     <facet .../> 
     <facet .../> 
     <facet .../> 
    </section> 
</config> 
+0

धन्यवाद जंको। आदर्श रूप में मैं xml में प्रकार को सेट करने से बचूंगा, क्योंकि स्कीमा का बिंदु किसी XML/को संरचना को सत्यापित करना है। मैं दोनों के बीच दो-तरफा निर्भरता नहीं लेना चाहता हूं। – Boaz