validate xml with same element multiple times
I want to validate this xml file with a xsd file. How can I validate the next steps?
- Number of times the item "atributo" appears.
- "nombre" node has the same value in each element.
- "valor" node has not empty value.
xml file
<datos> <elemento tipoelemento="CABECERA"> <atributo> <nombre>VERSION</nombre> <valor>1.0</valor> </atributo> <atributo> <nombre>BRIGADA</nombre> <valor>JADSJL</valor> </atributo> <atributo> <nombre>BUZON</nombre> <valor>ASDKLFJKA</valor> </atributo> </elemento> </datos>
I try this but I don´t konw if that is possible.
xsd file
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified" vc:minVersion="1.1"> <xs:element name="datos"> <xs:complexType> <xs:sequence> <xs:element name="elemento"> <xs:alternative test="@tipoelemento = 'CABECERA'" type="cabecera"/> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="cabecera"> <xs:sequence> <xs:element name="atributo" /> </xs:sequence> </xs:complexType> </xs:schema>
someone help me?