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?
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:51ZThis is the accepted answer. This is the accepted answer.It 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>
Re: empty integer attribute in xml Schema validation2011-11-15T16:50:22ZThis is the accepted answer. This is the accepted answer.
- franciscoLF 270004TDD7
mukulg 060001WFFW28 Posts
Re: empty integer attribute in xml Schema validation2011-11-18T11:00:29ZThis is the accepted answer. This is the accepted answer.I 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
condy 270006V45W1 Post
Re: empty integer attribute in xml Schema validation2013-12-06T06:40:21ZThis is the accepted answer. This is the accepted answer.Updated on 2013-12-06T06:48:30Z at 2013-12-06T06:48:30Z by condy