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?

  1. Number of times the item "atributo" appears.
  2. "nombre" node has the same value in each element.
  3. "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?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.