I'm trying to validate an xml with an xml Schema, but the validation has errors...
My xmlSchema has an integer optional attibute , but when i parse the xml with the attribute empty, the validation show this error:
LSX-00231: entero sin signo "" no válido
How can i pass an empty integer attribute?
This topic has been locked.
11 replies Latest Post - 2013-12-06T06:40:21Z by condy
Pinned topic empty integer attribute in xml Schema validation
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-06-18T06:32:19Z at 2012-06-18T06:32:19Z by chrysanthy
Re: empty integer attribute in xml Schema validation2011-11-15T16:24:51Z in response to franciscoLFIt would be difficult to reconcile empty string with xs:int type. Hence, a compromise is to surrender the hope of schema-aware application to recognize it immediately as numeric and in particular being an integer. The application would then have to parse an integer out of it if it is not empty.
If that is acceptable, a construction of such type can appear like this.
<xs:simpleType> <xs:restriction base= "xs:string"> <xs:pattern value= "((\+|-)?\d+)?" /> </xs:restriction> </xs:simpleType>
mukulg 060001WFFW28 PostsACCEPTED ANSWER
Re: empty integer attribute in xml Schema validation2011-11-18T11:00:29Z in response to franciscoLFI find the following XSD type definition to be another correct option for this requirement,
<xs:simpleType name= "ex_int"> <xs:union memberTypes= "xs:int EMPTY_STR"/> </xs:simpleType> <xs:simpleType name= "EMPTY_STR"> <xs:restriction base= "xs:string"> <xs:enumeration value= ""/> </xs:restriction> </xs:simpleType>
If you validate your data with the type 'ex_int' above, you would get the desired behavior. This technique has further advantage, that after validation the PSVI result would have more accurate type information.
mayday1985 270005E7222 Posts