Results 1 to 5 of 5

Thread: XML Validation: XMLSPY vs. XMLValidatingReader

  1. #1

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

    XML Validation: XMLSPY vs. XMLValidatingReader

    I'm a newbie when it comes to .XSD, please bear with me.

    I've created a .xml doc that validates fine using XMLSPY. Tried writing a simple validation program in C# using XmlValidatingReader (more or less copied from MSDN) and I get an XmlSchemaException: element has an invalid value according to its data type.

    This is the definition in the schema:
    <xsd:element name="ActivityTime" type="xsd:time"> where xsd is defined as xmlns:xsd="http://www.w3.org/2001/XMLSchema

    Here's an example that validates fine in XMLSPY yet gives an exception with XmlValidatingReader:
    <jxdd:ActivityTime>07:59</jxdd:ActivityTime>

    Here's an example that validates fine using either method:
    <jxdd:ActivityTime>14:20:00-05:00</jxdd:ActivityTime>

    I can see how the values are different, but what I don't get is why it validates with one method and not the other. Is this poor validation in XMLSPY? A problem with XmlValidatingReader? Or am I missing something?

    Thanks,
    Mike

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Skimming through the XSD specs, it seems that time values must be at least of the format hh:mm:ss, but the specs are very vague on this point. Consequently, this section is revised several times in the errata.
    http://www.w3.org/2001/05/xmlschema-errata#Errata2

    It's absurd, really. The errata is nearly as long as the spec.
    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
    I know, I *tried* to find the definition, but could not come up with anything definitive.

    What I'm worried about is someone sends me an xml that validates find with XMLSPY, but I'm using .NET classes for validation and according to that, it's not valid. Where do I go to say "here, look at the spec"?

    Thanks,
    Mike

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Ok, I picked out the exact part of the spec that is important. This is a quote from the errata.
    '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)?
    It describes the EBNF form of the dateTime datatype. The time datatype is defined to be a left-truncated version of dateTime, in other words it's the part right of the 'T':
    hh ':' mm ':' ss ('.' s+)?
    This pattern describes two hour digits, a colon, two minute digits, a colon, two second digits and an optional comma with one or more second fraction digits. It is therefore invalid to omit the first two second digits, XMLSPY is at fault and 14:32 is not valid for the time datatype.
    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.

  5. #5

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Excellent, CornedBee - I appreciate you taking the time.

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