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
diff --git a/types.lisp b/types.lisp
index 26f89fa..1d481c6 100644
--- a/types.lisp
+++ b/types.lisp
@@ -1049,11 +1049,11 @@
(num (str)
(and str (parse-number:parse-number str))))
(setf (values y m d h min s tz-h tz-m)
- (values (* (int y) (if minusp -1 1))
+ (values (and y (* (int y) (if minusp -1 1)))
(int m) (int d) (int h) (int min)
(num s)
(int tz-h) (int tz-m))))
- (let ((day-limit (day-limit m y)))
+ (let ((day-limit (and m y (day-limit m y))))
;; check ranges
(cond
((and y m d h min s