[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [xml] Re: How to validate?
- From: Petr Novak <novak merlot ics muni cz>
- To: xml gnome org
- Subject: Re: [xml] Re: How to validate?
- Date: Mon, 1 Dec 2003 19:13:56 +0100
Hi all,
thanks for advise, it works. But I have any more the following question:
How can I return data from handler function?
I have something like this:
void validateHandler(void *pUserData, xmlErrorPtr pError){
...
// Here I find non-valid element and I need to log it and distribute
// some information about it to the funciton "validate"
}
bool validate(){
...
xmlSetStructuredErrorFunc(Context, (*validateHandler));
xmlValidateDocument(Context, Document);
...
// Here I need know something like the type of the node which is
// non-valid.
}
I can assign anything to pUserData, but I cannot obtain it back in the
"validate" function. I though that it will be written to validation context,
but that were not changed.
If I try to assign it to the pError->ctxt->userData, it crashes with
"Unprivileged Memory Access" message.
Can you advise me again?
Thank you very much
Petr Novak, Liberouter Project
On Tue, Nov 18, 2003 at 04:00:28PM +0100, Enno Rehling wrote:
> Petr Novak wrote:
>
> >Hallo,
> >I have some questions about validation document against DTD (or
> >Relax NG in the future):
> >
> >1. Is any way how to detect where is non-valid element or
> >attribute in document? I have parsed XML document (using
> >xmlParseFile) and DTD in file and I need obtain something
> >like xmlNodePtr.
>
> I've just gone through the same question, and I found
> xmlSetStructuredErrorFunc() - it lets you define a callback that gets a
> structured error message during the xmlValidate() process, which among
> other things, contains the node that causes the error. Documentation and
> examples are sparse, but with a little bit of poking around, you might find
> what you need.
>
> Don't define the other two warning/error functions, or the structured Error
> won't be called.
>
> >2. So I tried validate elements itself. But if I try to validate
> >some element using xmlValidateElement, it returns always errors
> >to standart error output that every element in document is not
> >defined. Why?
>
> Can't help you there, need help myself. I'm also looking for better
> documentation around schemas/dtds/etc, or some good examples to learn from.
>
> Enno
> --
> <Gibs> When you kill 6 people in Unreal Tournament it is "MonsterKill", In
> Quake3 it is "Excellent", in Counter-Strike it is "Kicked by console"
--
Petr Novak, Liberouter Project (www.liberouter.org)
E-mail: novak merlot ics muni cz
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]