Topic
  • 11 replies
  • Latest Post - ‏2013-12-06T06:40:21Z by condy
franciscoLF
franciscoLF
3 Posts

Pinned topic empty integer attribute in xml Schema validation

‏2011-11-15T07:15:40Z |
Hi,

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?

Thanks
Updated on 2012-06-18T06:32:19Z at 2012-06-18T06:32:19Z by chrysanthy
  • SystemAdmin
    SystemAdmin
    1391 Posts

    Re: empty integer attribute in xml Schema validation

    ‏2011-11-15T16:24:51Z  
    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>
    
  • franciscoLF
    franciscoLF
    3 Posts

    Re: empty integer attribute in xml Schema validation

    ‏2011-11-15T16:38:32Z  
    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.
    <pre class="jive-pre"> <xs:simpleType> <xs:restriction base= "xs:string"> <xs:pattern value= "((\+|-)?\d+)?" /> </xs:restriction> </xs:simpleType> </pre>
    Thanks tsuji

    I will try to use it
  • SystemAdmin
    SystemAdmin
    1391 Posts

    Re: empty integer attribute in xml Schema validation

    ‏2011-11-15T16:50:22Z  
    Thanks tsuji

    I will try to use it
    I forgot to put a name attribute (such as name="ex_int") to the simpleType. Please add it in so that it can be applied. Thanks!
  • franciscoLF
    franciscoLF
    3 Posts

    Re: empty integer attribute in xml Schema validation

    ‏2011-11-15T17:25:16Z  
    I forgot to put a name attribute (such as name="ex_int") to the simpleType. Please add it in so that it can be applied. Thanks!
    Ok, thanks a lot
  • mukulg
    mukulg
    28 Posts

    Re: empty integer attribute in xml Schema validation

    ‏2011-11-18T11:00:29Z  
    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.

    Thanks
  • SystemAdmin
    SystemAdmin
    1391 Posts

    Re: empty integer attribute in xml Schema validation

    ‏2012-01-02T16:31:50Z  
    • mukulg
    • ‏2011-11-18T11:00:29Z
    I find the following XSD type definition to be another correct option for this requirement,
    <pre class="jive-pre"> <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> </pre>

    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.

    Thanks
    It is very good and with useful information. Thanks, mukulg, for your post.
  • MukhlesurRahman
    MukhlesurRahman
    1 Post

    Re: empty integer attribute in xml Schema validation

    ‏2012-05-15T05:24:17Z  
    • mukulg
    • ‏2011-11-18T11:00:29Z
    I find the following XSD type definition to be another correct option for this requirement,
    <pre class="jive-pre"> <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> </pre>

    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.

    Thanks
    Thank you, it's helpful solution.

    Islam
  • mayday1985
    mayday1985
    2 Posts

    Re: empty integer attribute in xml Schema validation

    ‏2012-06-15T03:14:13Z  
    • mukulg
    • ‏2011-11-18T11:00:29Z
    I find the following XSD type definition to be another correct option for this requirement,
    <pre class="jive-pre"> <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> </pre>

    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.

    Thanks
    Thanks for this helpful imformation

    [url=http://www.ledpanellight.net/]LED Strips[/url]
  • mayday1985
    mayday1985
    2 Posts

    Re: empty integer attribute in xml Schema validation

    ‏2012-06-15T03:14:45Z  
    • mukulg
    • ‏2011-11-18T11:00:29Z
    I find the following XSD type definition to be another correct option for this requirement,
    <pre class="jive-pre"> <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> </pre>

    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.

    Thanks
    Thanks for this helpful imformation

    LED Strips
  • chrysanthy
    chrysanthy
    1 Post

    Re: empty integer attribute in xml Schema validation

    ‏2012-06-18T06:32:19Z  
    Thanks for this helpful imformation

    LED Strips
    this is really helpful. thanks so much.


    LED panel lights
  • condy
    condy
    1 Post

    Re: empty integer attribute in xml Schema validation

    ‏2013-12-06T06:40:21Z  
    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.
    <pre class="jive-pre"> <xs:simpleType> <xs:restriction base= "xs:string"> <xs:pattern value= "((\+|-)?\d+)?" /> </xs:restriction> </xs:simpleType> </pre>

    Great! thx

    http://www.imigyled.com

     

    Updated on 2013-12-06T06:48:30Z at 2013-12-06T06:48:30Z by condy