XML validation fails on attributes

needit999

New Member
I've some problem validating an xml against a schema that i defined. The weird thing is that the validation fails only if I use the default namespace \[code\]xmlns="http://retis.sssup.it/duck-lab"\[/code\] while it works like a charm if I define it like \[code\]xmlns:dl="http://retis.sssup.it/duck-lab"\[/code\]. When I use the empty namespace the validation fails only on the attributes with the following messages:\[code\]cvc-complex-type.3.2.2: Attribute 'data_len' is not allowed to appear in element 'data'. cvc-complex-type.4: Attribute 'data_len' must appear on element 'data'.\[/code\]VALID XML:\[code\]<dl:duck xmlns:dl="http://retis.sssup.it/duck-lab" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://retis.sssup.it/duck-lab ../duck.xsd ">... <dl:data dl:data_len="1" dl:data_name="name uint" dl:data_type="uint16" dl:endianess="big-endian"/>\[/code\]INVALID XML:\[code\]<duck xmlns="http://retis.sssup.it/duck-lab" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://retis.sssup.it/duck-lab ../duck.xsd ">... <data data_len="1" data_name="name uint" data_type="uint16" endianess="big-endian"/>\[/code\]--EDIT--DUCK.XSD\[code\]<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://retis.sssup.it/duck-lab" xmlns:dl="http://retis.sssup.it/duck-lab" elementFormDefault="qualified"> <include schemaLocation="datatypes.xsd"/> <include schemaLocation="duck_message.xsd"/> <complexType name="DuckDefinitionType" block="#all" final="#all"> <sequence> <element type="dl:MessageType" name="message_description" form="qualified"/> </sequence> </complexType> <element name="duck" type="dl:DuckDefinitionType" /></schema>\[/code\]DATATYPES.XSD\[code\]<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://retis.sssup.it/duck-lab" xmlns:dl="http://retis.sssup.it/duck-lab" elementFormDefault="qualified"> <attribute name="data_name" type="string"/> <attribute name="data_len" type="nonNegativeInteger"/> <attribute name="data_type" type="string"/> <attribute name="endianess" type="string"/> <element name="data"> <complexType> <attribute ref="dl:data_name" use="required"/> <attribute ref="dl:data_len" use="required"/> <attribute ref="dl:data_type" use="required"/> <attribute ref="dl:endianess" use="required"/> </complexType> </element></schema>\[/code\]DUCK_MESSAGE.XSD\[code\]<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://retis.sssup.it/duck-lab" xmlns:dl="http://retis.sssup.it/duck-lab" elementFormDefault="qualified"> <include schemaLocation="datatypes.xsd"></include> <complexType name="MessageType"> <sequence maxOccurs="unbounded"> <element ref="dl:data"></element> </sequence> </complexType></schema>\[/code\]Obviously I can bypass the problem defining a non empty namespace, but I would like to understand what's wrong.Thanks a lot.
 
Back
Top