Hi to all, I have an XML schema document that looks like this :
<?xml version="1.0" ?><xs:schema id="Employees" targetNamespace="http://tempuri.org/Employee.xsd" xmlns:mstns="http://tempuri.org/Employee.xsd" xmlns="http://tempuri.org/Employee.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified"> <xs:element name="Employees" msdata:IsDataSet="true" msdata:EnforceConstraints="False"> <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element name="Employee"> <xs:complexType> <xs:sequence> <xs:element name="Firstname" type="xs:string" minOccurs="1" msdata:Ordinal="0" maxOccurs="1" /> <xs:element name="Lastname" type="xs:string" minOccurs="1" msdata:Ordinal="1" maxOccurs="1" /> </xs:sequence> <xs:attribute name="empId" form="unqualified" type="xs:byte" use="required" /> </xs:complexType> <xs:key name="EmployeeKey"> <xs:selector xpath="Employee" /> <xs:field xpath="Employee/@empId" /> </xs:key> </xs:element> </xs:choice> </xs:complexType> </xs:element></xs:schema>
I want to test whether the schema that I created validates against an instance document. Below is my sample instance document.
<?xml version="1.0" encoding="utf-8"?><Employees xmlns="http://tempuri.org/Employee.xsd"> <Employee empId="1"> <Firstname>John</Firstname> <Lastname>Doe</Lastname> </Employee> <Employee empId="1"> <Firstname>Jane</Firstname> <Lastname>Doe</Lastname> </Employee></Employees>
As we should expect, the instance document will be invalidated since both <Employee> elements have the same empId attribute (empId="1"). When I validate this instance document against the schema that I created, it is recognized as a valid XML document. What could be the problem? Is there a syntax error in my XPath declaration?
hehe.. sensya na ha.. actually, ngayon lang ulit na-check tong forums, i was out of the office and was not able to continue my XML study and development. hehe.. anyway, thanks po sa mga effort ninyo, I really appreciate it. ..
actually, na-try ko na po yung mga previous na binigay niyo. Unfortunately, hindi yata nag-work eh. Fortunately, however, I also posted that same problem in msdn forums and someone there was able to make it work..
Here's the link : http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=667201&SiteID=1
ps: thanks smash and punzie. huwag na kayo tampo. hehe..