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

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

    Re: empty integer attribute in xml Schema validation

    ‏2011-11-15T16:24:51Z  in response to franciscoLF
    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
      ACCEPTED ANSWER

      Re: empty integer attribute in xml Schema validation

      ‏2011-11-15T16:38:32Z  in response to SystemAdmin
      Thanks tsuji

      I will try to use it
      • SystemAdmin
        SystemAdmin
        1391 Posts
        ACCEPTED ANSWER

        Re: empty integer attribute in xml Schema validation

        ‏2011-11-15T16:50:22Z  in response to franciscoLF
        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!
    • condy
      condy
      1 Post
      ACCEPTED ANSWER

      Re: empty integer attribute in xml Schema validation

      ‏2013-12-06T06:40:21Z  in response to SystemAdmin

      Great! thx

      http://www.imigyled.com

       

      Updated on 2013-12-06T06:48:30Z at 2013-12-06T06:48:30Z by condy
  • mukulg
    mukulg
    28 Posts
    ACCEPTED ANSWER

    Re: empty integer attribute in xml Schema validation

    ‏2011-11-18T11:00:29Z  in response to franciscoLF
    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
      ACCEPTED ANSWER

      Re: empty integer attribute in xml Schema validation

      ‏2012-01-02T16:31:50Z  in response to mukulg
      It is very good and with useful information. Thanks, mukulg, for your post.
    • MukhlesurRahman
      MukhlesurRahman
      1 Post
      ACCEPTED ANSWER

      Re: empty integer attribute in xml Schema validation

      ‏2012-05-15T05:24:17Z  in response to mukulg
      Thank you, it's helpful solution.

      Islam
    • mayday1985
      mayday1985
      2 Posts
      ACCEPTED ANSWER

      Re: empty integer attribute in xml Schema validation

      ‏2012-06-15T03:14:13Z  in response to mukulg
      Thanks for this helpful imformation

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

      Re: empty integer attribute in xml Schema validation

      ‏2012-06-15T03:14:45Z  in response to mukulg
      Thanks for this helpful imformation

      LED Strips