xml validation with XSD 1.1

I don´t have experience with validation with XSD file, I have to validate the xml file with XSD 1.1 but I getting the next error:

lineNumber: 10; columnNumber: 71; c-cta-xpath: The XPath expression '@tipoelemento = CABECERA' couldn't compile successfully in 'cta-subset' mode, during CTA evaluation. 

file.xml

<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> 

file.xsd

<?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" minOccurs="1" maxOccurs="1">                 <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" minOccurs="1" maxOccurs="1" type="VERSION" />         <xs:element name="atributo" minOccurs="1" maxOccurs="1" type="BRIGADA" />         <xs:element name="atributo" minOccurs="1" maxOccurs="1" type="BUZON" />     </xs:sequence> </xs:complexType> <xs:complexType name="VERSION"> <xs:sequence>     <xs:element name="nombre" type="xs:string" minOccurs="1" fixed="VERSION" />     <xs:element name="valor" type="xs:string" minOccurs="1" /> </xs:sequence> </xs:complexType> <xs:complexType name="BRIGADA">     <xs:sequence>         <xs:element name="nombre" type="xs:string" minOccurs="1" fixed="BRIGADA" />         <xs:element name="valor" type="xs:string" minOccurs="1" />     </xs:sequence> </xs:complexType> <xs:complexType name="BUZON">     <xs:sequence>         <xs:element name="nombre" type="xs:string" minOccurs="1" fixed="BUZON" />         <xs:element name="valor" type="xs:string" minOccurs="1" />     </xs:sequence> </xs:complexType> </xs:schema> 

I haven´t experience in this materia, sorry!

I followed this link click here

I have seen in this link click here that I need use full XPath 2.0 but I don´t know how to do it.

How do I solve this issue?

Regards

Add Comment
1 Answer(s)

XPath expressions used in conditional type assignment are restricted to accessing attributes, they can’t access child elements.

Your mistake is that in your expression, @tipoelemento = CABECERA, CABACERA is interpreted as child::CABECERA, that is, a reference to a child element. I think you wanted a string literal here, which would be @tipoelemento = 'CABECERA' where the string is in quotes.

Answered on July 17, 2020.
Add Comment

Your Answer

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