xml

2011-12-13 20 views
6

में एक xsd फ़ाइल संदर्भित करें मैं xml भाषा में नया हूं, मेरे पास एक xml फ़ाइल है और मैंने उस फ़ाइल के लिए xsd स्कीमा बनाया है, लेकिन मेरी समस्या यह है कि इस स्कीमा को xml फ़ाइल में कैसे संदर्भित किया जाए। मेरा एक्सएमएल स्कीमा इस तरह दिखता हैxml

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:wmh="http://www.wmhelp.com/2003/eGenerator" 
    elementFormDefault="qualified" 
    targetNamespace="http://axis.com/service" 
    xmlns="http://axis.com/service" 
    version="1.0"> 

    <xs:element name="SWService" type="SWServiceType"/> 
    <xs:element name="HWService" type="HWServiceType"/> 


<xs:complexType name="SWServiceType"> 
<xs:sequence> 
    <xs:element name="Service" type="ServiceType" minOccurs="0" maxOccurs="unbounded"/> 
    </xs:sequence> 
    </xs:complexType> 

<xs:complexType name="ServiceType"> 
<xs:complexContent> 
<xs:extension base="IdType"> 
    <xs:sequence> 
    <xs:element name="Description" type="xs:string" maxOccurs="1" minOccurs="0"/> 
    <xs:element name="ServiceCustomers" type="ServiceCustomersType" maxOccurs="1" 
minOccurs="0"/> 
    <xs:element name="ServiceSuppliers" type="ServiceSuppliersType" maxOccurs="1" 
minOccurs="0"/> 
    </xs:sequence> 
    <xs:attribute name="Name" type="xs:string" use="required"/> 
    </xs:extension> 
    </xs:complexContent> 
    </xs:complexType> 

    <xs:complexType name="HWServiceType"> 
    <xs:sequence> 
    <xs:element name="element" type="elementGroupType" maxOccurs="1" minOccurs="0"/> 
    </xs:sequence> 
    </xs:complexType> 

    <xs:complexType name="ServiceCustomersType"> 
    <xs:sequence> 
    <xs:element name="SoftWare" type="SoftWareType" maxOccurs="unbounded" 
    minOccurs="0"/> 
    </xs:sequence> 
    </xs:complexType> 

    <xs:complexType name="ServiceSuppliersType"> 
    <xs:sequence> 
    <xs:element name="SoftWare" type="SoftWareType" maxOccurs="unbounded" 
minOccurs="0"/> 
    <xs:element name="HardWare" type="HardWareType" maxOccurs="unbounded" 
    minOccurs="0"/> 
    </xs:sequence> 
</xs:complexType> 

<xs:complexType name="SoftWareType"> 
<xs:complexContent> 
<xs:extension base="PathType"> 
    <xs:attribute name="Service" type="xs:string" use="required"/> 
    </xs:extension> 
    </xs:complexContent> 
</xs:complexType> 

<xs:complexType name="HardWareType"> 
<xs:complexContent> 
<xs:extension base="PathType"> 
    <xs:attribute name="Type" type="xs:string" use="required"/> 
    <xs:attribute name="Nr" type="xs:string" use="required"/> 
    <xs:attribute name="Service" type="xs:string" use="required"/> 
    </xs:extension> 
    </xs:complexContent> 
</xs:complexType> 

<xs:complexType name="PathType"> 
    <xs:attribute name="Path" type="xs:string" use="required"/> 
</xs:complexType> 


    <xs:complexType name="elementGroupType"> 
<xs:sequence> 
     <xs:element name="element" type="elementType" maxOccurs="unbounded" 
minOccurs="1"/> 
    </xs:sequence> 
</xs:complexType> 


<xs:complexType name="elementType"> 
    <xs:sequence> 
    <xs:element name="LM" type="LMType2" maxOccurs="1" minOccurs="1"/> 
    <xs:element name="Service" type="ServiceType" maxOccurs="unbounded" minOccurs="0"/> 
    </xs:sequence> 
    <xs:attribute name="Type" type="xs:string" use="required"/> 
    <xs:attribute name="Nr" type="xs:string" use="required"/> 
    <xs:attribute name="Name" type="xs:string" use="required"/> 
</xs:complexType> 


    <xs:complexType name="LMType2"> 
    <xs:sequence> 
    <xs:element name="LowerMode" type="LowerModeType2" maxOccurs="unbounded" 
minOccurs="0"/> 
    </xs:sequence> 
</xs:complexType> 

<xs:complexType name="LowerModeType2"> 
<xs:complexContent> 
    <xs:extension base="IdType"> 
    <xs:attribute name="Probability" type="xs:double" use="required"/> 
    </xs:extension> 
    </xs:complexContent> 
    </xs:complexType> 


<xs:complexType name="IdType"> 
    <xs:attribute name="Id" type="xs:string" use="required"/> 
</xs:complexType> 

    </xs:schema> 

मैंने इस फ़ाइल को service.xsd के रूप में सहेजा। मुझे इस स्कीमा को मेरी एक्सएमएल फ़ाइल में संदर्भित करने की आवश्यकता है, मैंने ऐसा करने की कोशिश की लेकिन यह मान्य नहीं है।

<?xml version="1.0" encoding="UTF-8"?> 
<Service xsi:schemaLocation="file:///C:/main/newfolder/service.xsd"  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://axis.com/service"   
Version="1.0"> 
--------Xml data------- 
</Service> 

मैं समस्या के तहत क्या कर सकता हूं। यह इस

No DTD of the document found 

मैं इस

<?xml version="1.0" encoding="UTF-8"?> 
<Service xsi:schemaLocation=""http://axis.com/service"  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://axis.com/service"   
Version="1.0"> 
--------Xml data------- 
</Service> 

लेकिन अभी भी एक ही समस्या की तरह की कोशिश की तरह त्रुटि देता है। जब मैं xmlpad का उपयोग कर xml फ़ाइल को मान्य करता हूं। क्या कोई मेरी समस्या को ठीक कर सकता है। बहुत मदद

अग्रिम धन्यवाद।

+1

+1: थोड़ी देर के लिए मैंने देखा है सबसे अच्छी पहली पोस्ट में से एक! –

+0

क्या आप वर्णन कर सकते हैं कि आप XML को कैसे मान्य कर रहे हैं? क्या आप कुछ बाहरी कार्यक्रम या शायद कुछ पुस्तकालय के साथ उपयोग करते हैं? – bbaja42

+0

@ bbaja42 मैं XMLPAD का उपयोग कर सत्यापन कर रहा हूं। – user234

उत्तर

1

schemaLocation के उपयोग के लिए पूरी तरह से वैकल्पिक है और संस्करण विशेषता अपने उदाहरण में गलत है

निम्नलिखित उदाहरण (जब तक आप एक विशेषता अपने स्कीमा में संस्करण कहा जाता है परिभाषित किया है)

<Service xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://axis.com/service"> 
any string 
</Service> 

के खिलाफ ठीक मान्यता देता है स्कीमा:

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:wmh="http://www.wmhelp.com/2003/eGenerator" 
    elementFormDefault="qualified" 
    targetNamespace="http://axis.com/service" 
    xmlns="http://axis.com/service" 
    version="1.0"> 
    <xs:element name="Service" type="xs:string"/> 
</xs:schema> 

मैंने आपके स्ट्रिंग के साथ आपके प्रकार एक्सिस सेवा प्रकार को प्रतिस्थापित किया था।

आपके विफल होने का सटीक कारण निर्धारित करने के लिए मुझे आपकी संपूर्ण स्कीमा और इंस्टेंस दस्तावेज़ देखना होगा।

+0

आपके उत्तर के लिए धन्यवाद, मैं अलग-अलग एक्सएमएल फ़ाइल प्रारूपों, एसडब्ल्यूएसईसी, एचडब्ल्यू सेवा, मॉड्यूल स्पेसिफिकेशन के लिए एक एक्सएसडी लिख रहा हूं, विभिन्न एक्सएमएल फाइलों से संबंधित है और एसडब्ल्यूएसईसीटी एक्सएमएल फाइल xsd को SWServiceType के तहत संदर्भित किया गया है। तीन अलग-अलग एक्सएमएल फाइलों के लिए बुद्धिमान। मैंने संपादित किया है कि मेरी पोस्ट मेरी संपादित पोस्ट पर एक नज़र डाल सकती है। मुझे इस एक्सएसडी को तीन अलग-अलग एक्सएमएल फ़ाइल प्रारूपों में संदर्भित करने की आवश्यकता है। क्या आप मेरी मदद कर सकते हैं। अगर मैं इस xsd को नामस्थान के बिना मान्य करता हूं, लेकिन नाम स्थान के साथ यह त्रुटि दे रहा है। – user234

+0

मुझे खेद है, लेकिन आपको मुझे संपूर्ण एक्सएसडी स्कीमा प्रदान करना होगा ताकि मैं आपको एक उदाहरण XML दस्तावेज़ बनाने में मदद कर सकूं। –

+0

क्या आप मेरी एक्सएसडी पर एक नज़र डाल सकते हैं, मैंने पूरे एक्सएसडी स्कीमा प्रदान किया है। – user234

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