[xml] Re: How to validate?



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"

Attachment: pgpkoLbb9yMrl.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]