Results 1 to 3 of 3

Thread: XML/XSD: xs:date and nillable

  1. #1

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    XML/XSD: xs:date and nillable

    If I allow a nillable date element like this
    Code:
    <xs:element name="DOB" type="xs:date" nillable="true"/>
    how can I write my element so it validates when there is no date - e.g. You don't know the DOB (date of birth)

    Using XmlSpy to test, will need to validate with .NET.

    I've tried an empty element, "0000-00-00", and just not including the element, nothing works so far.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: XML/XSD: xs:date and nillable

    From the standard:
    If {nillable} is true, then an element may also be ·valid· if it carries the namespace qualified attribute with [local name] nil from namespace http://www.w3.org/2001/XMLSchema-instance and value true (see xsi:nil (§2.6.2)) even if it has no text or element content despite a {content type} which would otherwise require content. Formal details of element ·validation· are described in Element Locally Valid (Element) (§3.3.4).
    Therefore, given that xsi is the namespace prefix of XMLSchema-instance, the element would look like
    <DOB xsi:nil="true"/>
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Re: XML/XSD: xs:date and nillable

    Perfect, thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width