बस वी.एस. 2013 में की कोशिश की और वी.एस. 2015 उन्होंने ऐसा किया अब कुंजी/रीफकी मान्य करें। हालांकि यह अभिभावक स्तर पर चेतावनियां दिखाता है।
लेकिन जैसा कि @antiduh ने कहा, वे अभी भी xsd फ़ाइल की जांच नहीं करते हैं। तो आपको वास्तव में की आवश्यकता है सुनिश्चित करें कि xsd में कुंजी/रीकी सही है।
यह एक साधारण नमूना जानने के लिए मेरे घंटों का समय लगा। यहां तक कि sample on MSDN काम नहीं करता है। मुझे इसे थोड़ा संशोधित करना पड़ा।
सबसे पहले, सुनिश्चित करें कि आप how to let Visual Studio validate an xml against an xsd of your choice जानते हैं।
फिर कुंजी/रीकी सत्यापन के लिए निम्न नमूना xsd और xml का उपयोग करें। ध्यान दें कि चेतावनी रूट तत्व के समापन पर है, उस तत्व के बजाय जो कुंजी/रेफ नियम का उल्लंघन करती है।
XSD फ़ाइल इस तरह दिखता है:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="namespace1"
xmlns:r="namespace1"
elementFormDefault="qualified">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="A" type="r:A" maxOccurs="unbounded"/>
<xs:element name="B" type="r:B"/>
</xs:sequence>
</xs:complexType>
<xs:keyref name="dummy" refer="r:pNumKey">
<xs:selector xpath="r:A/r:part"/>
<xs:field xpath="@ref-number"/>
</xs:keyref>
<xs:key name="pNumKey">
<xs:selector xpath="r:B/r:part"/>
<xs:field xpath="@key-number"/>
</xs:key>
</xs:element>
<xs:complexType name="A">
<xs:sequence>
<xs:element name="part" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="ref-number" type="xs:integer"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="B">
<xs:sequence>
<xs:element name="part" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="key-number" type="xs:integer"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
और xml फ़ाइल इस तरह दिखता है:
<?xml version="1.0" encoding="utf-8" ?>
<root xmlns="namespace1">
<A>
<!-- if the ref-number is equal to one of the key-number, the validation will pass -->
<part ref-number="1"/>
</A>
<A>
<!-- if the ref-number is not equal to one of the key-number, the validation will give error -->
<part ref-number="5"/>
</A>
<B>
<part key-number="1"/>
<part key-number="2"/>
<part key-number="3"/>
</B>
</root><!--you will see warnings here-->
की (http
स्रोत
2016-09-08 21:20:51
संभव डुप्लिकेट [आप बनाम 2010 में एक्सएमएल के खिलाफ XSD मान्य कर सकते हैं?]: //stackoverflow.com/questions/8988593/can-you-validate-xsd-against-xml-in-vs-2010) – DaveShaw
क्या आपको कभी इसका उत्तर मिला? ऐसा लगता है कि एक्सएसडी एक्सएसडी के साथ इसका समर्थन है ... –
अभी तक कोई जवाब नहीं है, मैं सोच रहा हूं कि जितना अधिक से अधिक लोग इसे ऊपर उठाते हैं, वहां कोई जवाब नहीं है। दुर्भाग्य से। –