[cxml-devel] Bug in validating XSD:DATE

Chaitanya Gupta mail at chaitanyagupta.com
Mon Aug 18 10:19:36 UTC 2008


If I have an RNC file which looks like this:

start =
   element foo {
      element bar { text },
      element baz { xsd:date }
   }

and try to validate against this schema an XML which looks like this:

<foo>
  <bar>haha!</bar>
  <baz>2008-09-09T22:00:00</baz>
</foo>

(Note that the value of 'baz' should have been a date, not a date-time)

I get the following error/backtrace:

`NIL' is not of the expected type `NUMBER'
   [Condition of type TYPE-ERROR]

Restarts:
  0: [ABORT-REQUEST] Abort handling SLIME request.
  1: [ABORT] Abort entirely from this (lisp) process.

Backtrace:
  0: (SWANK::DEBUG-IN-EMACS #<TYPE-ERROR @ #x117dba9a>)
  1: (SWANK:SWANK-DEBUGGER-HOOK #<TYPE-ERROR @ #x117dba9a> #<Function 
SWANK-DEBUGGER-HOOK>)
  2: (ERROR TYPE-ERROR :DATUM NIL :EXPECTED-TYPE NUMBER :FORMAT-CONTROL 
"~@<`~s' is not of the expected type `~s'~:@>" :FORMAT-ARGUMENTS (NIL 
NUMBER))
  3: (CXML-TYPES::PARSE-TIME NIL NIL NIL NIL #1="0" #1# #1# NIL NIL ...)
  4: ((METHOD CXML-TYPES::PARSE/XSD (CXML-TYPES:DATE-TYPE T T)) 
#<CXML-TYPES:DATE-TYPE > "2008-09-09T22:00:00" #<CXML-RNG::VALIDATOR @ 
#x117cb302>)
  5: ((METHOD CXML-TYPES::PARSE/XSD :AROUND (CXML-TYPES:XSD-TYPE T T)) 
#<CXML-TYPES:DATE-TYPE > "2008-09-09T22:00:00" #<CXML-RNG::VALIDATOR @ 
#x117cb302>)
  6: ((:INTERNAL (:EFFECTIVE-METHOD 3 NIL NIL T T) 0) 
#<CXML-TYPES:DATE-TYPE > "2008-09-09T22:00:00" #<CXML-RNG::VALIDATOR @ 
#x117cb302>)
  7: ((METHOD CXML-TYPES:VALIDP (CXML-TYPES:XSD-TYPE T)) 
#<CXML-TYPES:DATE-TYPE > "2008-09-09T22:00:00" #<CXML-RNG::VALIDATOR @ 
#x117cb302>)
  8: ((METHOD CXML-RNG::|DATA'| (T CXML-RNG:DATA T)) 
#<CXML-RNG::VALIDATOR @ #x117cb302> #<CXML-RNG:DATA @ #x117c65a2> 
"2008-09-09T22:00:00")


Attached is a patch which fixes this. Now I get the expected error:

text node not valid,
was expecting a text node of type #<DATE-TYPE >
  [ Error at line 3, column 33 in #<PURI:URI
                                    file://+/Users/chaitanya/tmp/test.xml> ]
   [Condition of type CXML-RNG:RNG-ERROR]


On a side note, I think that the error reporting can be improved a bit. 
e.g. the element inside which the validation error was encountered, can 
that also be reported?


Chaitanya

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: types.lisp.diff
URL: <https://mailman.common-lisp.net/pipermail/cxml-devel/attachments/20080818/69bb90f8/attachment.ksh>


More information about the cxml-devel mailing list