is my xsd correct to be validated for my xml? another problem is that even though i linked my schema with my xml, my declared element "ElectionResultsByPercentage" is still cannot be identified, i don't know why.
this is my code for xml:
<?xml version="1.0" encoding="utf-8"?>
<ElectionResultsByPercentage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation ="schema.xsd">
<Candidate name="John">61</Candidate>
<Candidate name="Sara">24</Candidate>
<Candidate name="Bill">15</Candidate>
</ElectionResultsByPercentage>
and my code in xsd is:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns="https://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
vc:minVersion="1.1">
<xs:element name="ElectionResultsByPercentage">
<xs:complexType>
<xs:sequence>
<xs:element name="Candidate" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:byte">
<xs:attribute type="xs:string" name="name" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:assert test="sum(Candidate)=100"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
i'd also like to know if my usage of assert is correct.
if my xsd is wrong, how can i correct this because it appears to be valid when being validated in oXygen ide