[xml] Error callbacks when validating using RelaxNG
- From: "Victor Ng" <crankycoder gmail com>
- To: xml gnome org
- Subject: [xml] Error callbacks when validating using RelaxNG
- Date: Wed, 22 Feb 2006 18:18:38 -0500
I'm having some problems trying to figure out how to get the line
number that a document fails at when validating with a RelaxNG schema
definition.
Here is my schema and test data:
Schema :
1 <?xml version="1.0" encoding="utf-8"?>
2 <element name="trip" xmlns="
http://relaxng.org/ns/structure/1.0">
3 <element name="description">
4 <text/>
5 </element>
6 </element>
Test document
1 <?xml version="1.0" encoding="utf-8"?>
2 <foo/>
Using xmllint - I get a proper line number:
$ xmllint --relaxng rng_schema.xml rng_invalid.xml
<?xml version="1.0" encoding="utf-8"?>
<foo/>
rng_invalid.xml:2: element foo: Relax-NG validity error : Expecting element trip, got foo
rng_invalid.xml fails to validate
$
But when I try to use my own callback function I only seem to get the
message body "Expecting element trip, got foo" without any line numbers.
I'm using a callback function defined as:
27 void errorFunc (void *ctx, const char *msg, ...)
28 {
29 char *tmpChar;
30 va_list ap;
31 va_start(ap, tmpChar);
32 while (tmpChar != 0) {
33 printf ("[%s]\n", tmpChar);
34 tmpChar = va_arg(ap, const char *);
35 }
36 va_end(ap);
37 }
38
The output I get is :
[,I]
[Expecting element trip, got foo
]
[\uffff\uffffs\uffff]
I'm not sure what the garbled data is, but the text seems correct.,
I don't think I'm doing anything weirdly, but my C is extremely rusty. Anyone have any idea what I'm doing wrong?
Thanks,
--
"Never attribute to malice that which can be adequately explained by stupidity." - Hanlon's Razor
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]