2011-10-20 14 views
5

में अद्वितीय मान निर्दिष्ट करने के लिए कैसे मैं xs प्राप्त करने में असमर्थ हूं: XML फ़ाइल में काम करने के लिए अद्वितीय विनिर्देशक। मैं बस काम करता है कि एक XPath काम करने में सक्षम नहीं लगता है। इस सवाल में कोड की मात्रा के लिए मेरी क्षमा है, लेकिन मैं किसी के लिए बहुत आभारी हूं जो बता सकता है कि मैं नीचे क्या कर रहा हूं। कोई फर्क नहीं पड़ता कि मैं क्या करता हूं, मुझे तत्व में @ref विशेषता नहीं मिल सकती है ताकि मेरे डुप्लिकेटिंग मूल्य (प्रत्येक रेफरी अद्वितीय हो) के लिए त्रुटि की रिपोर्ट हो।किसी XML स्कीमा

जानकारी के लिए कोई भी मदद या पॉइंटर्स बहुत ही आभारी होंगे।

तरह चाहता है, पैट्रिक

यह मेरा स्कीमा है:

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema id="Artworks" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:aw="http://www.fourthwish.co.uk/data/Artworks.xsd" 
xmlns="http://www.fourthwish.co.uk/data/Artworks.xsd" 
targetNamespace="http://www.fourthwish.co.uk/data/Artworks.xsd" 
elementFormDefault="qualified" 
> 
<xs:element name="artworks"> 
    <xs:complexType> 
    <xs:sequence minOccurs="0" maxOccurs="unbounded"> 
      <xs:element name="artwork" type="ArtworkType"> 
       <xs:unique name="uniqueRef"> 
        <xs:selector xpath="artwork"/> 
        <xs:field xpath="@ref"/> 
       </xs:unique> 
      </xs:element> 
     </xs:sequence> 
    </xs:complexType> 
</xs:element> 
<xs:complexType name="ArtworkType"> 
    <xs:sequence> 
     <xs:element name="title" type="xs:string"/> 
    </xs:sequence> 
    <xs:attribute name="ref" type="xs:nonNegativeInteger"/> 
</xs:complexType> 
</xs:schema> 

और ये मेरे एक्सएमएल फ़ाइल है:

<?xml version="1.0" encoding="utf-8" standalone="yes"?> 
<artworks 
xmlns="http://www.fourthwish.co.uk/data/Artworks.xsd" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.fourthwish.co.uk/data/Artworks.xsd Artworks.xsd" 
> 
<artwork ref="1"> 
    <title>Title String</title> 
</artwork> 
<artwork ref="1"> 
    <title>Title String</title> 
</artwork> 
</artworks> 

मैं डुप्लिकेट रेफरी के लिए एक त्रुटि क्यों नहीं मिल सकता मान? Arrrggghhh! मैंने इंटरनेट पर सब कुछ पढ़ा है। कृपया किसी की मदद करें।

उत्तर

1

क्या आपने यह प्रश्न देखने के लिए देखा है कि क्या यह समान है - पूछने वाले ने अपने प्रश्न पर एक एवर पोस्ट किया।

How make univoque my enumeration by xs:unique

3

उपयोग करें:

चेतावनी::

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema id="Artworks" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:aw="http://www.fourthwish.co.uk/data/Artworks.xsd" 
xmlns="http://www.fourthwish.co.uk/data/Artworks.xsd" 
targetNamespace="http://www.fourthwish.co.uk/data/Artworks.xsd" 
elementFormDefault="qualified" 
> 
    <xs:element name="artworks"> 
    <xs:complexType> 
     <xs:sequence minOccurs="0" maxOccurs="unbounded"> 
     <xs:element name="artwork" type="ArtworkType"/> 
     </xs:sequence> 
    </xs:complexType> 

    <xs:unique name="uniqueRef"> 
     <xs:selector xpath="aw:artwork"/> 
     <xs:field xpath="@ref"/> 
    </xs:unique> 

    </xs:element> 

    <xs:complexType name="ArtworkType"> 
    <xs:sequence> 
     <xs:element name="title" type="xs:string"/> 
    </xs:sequence> 
    <xs:attribute name="ref" type="xs:nonNegativeInteger"/> 
    </xs:complexType> 
</xs:schema> 
1

आप सेक्सन-ई के माध्यम से इस स्कीमा चलाते हैं, तो यह आपको बताता है test.xsd की लाइन 13 पर: जटिल टाइप करें ArtworkType {} आर्टवर्क

नामक एक बच्चे तत्व की अनुमति नहीं देता है जो मूल रूप से आपको बता रहा है कि आप कलाकृति में हैं एक नामस्थान, और इसलिए एक उपसर्ग की जरूरत है।

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