After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 312216 - Please wrap support for XML Schemas and Relax NG
Please wrap support for XML Schemas and Relax NG
Status: RESOLVED FIXED
Product: libxml++
Classification: Bindings
Component: General
2.10.x
Other All
: Normal enhancement
: ---
Assigned To: Christophe de Vienne
Christophe de Vienne
Depends on:
Blocks:
 
 
Reported: 2005-08-01 10:06 UTC by Daniel Holbach
Modified: 2008-12-12 12:09 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
Patch to add schema (71.46 KB, patch)
2007-06-05 10:03 UTC, Emilien KIA
none Details | Review
libxmlpp_schema.patch (15.25 KB, patch)
2007-06-10 17:20 UTC, Murray Cumming
none Details | Review
libxml++_schemafree.patch (854 bytes, patch)
2008-12-05 21:21 UTC, Murray Cumming
none Details | Review
schema.cc patch (317 bytes, patch)
2008-12-12 10:45 UTC, Przemysław Grzegorczyk
none Details | Review

Description Daniel Holbach 2005-08-01 10:06:50 UTC
the API is exposed in 
 - include/libxml/relaxng.h and
 - include/libxml/xmlschemas.h
 - (Daniel Veillard just replied to the mailing list thread
(http://sourceforge.net/mailarchive/forum.php?thread_id=7863484&forum_id=12784)
and announced his work on xml schematron - no idea how that works, but the API
seems to be similar, so here goes: include/libxml/schematron.h)

judging the code, where I used relax ng, i think it's most important to wrap
 - the structures *ParserCtxtPtr, *ValidCtxtPtr, *Ptr
 - *NewParserCtxt(), *Parse(), *FreeParserCtxt(), *NewParserCtxt(),
*NewValidCtxt(), *ValidateDoc(), *FreeValidCtxt()
 - xmlReadFile should be there already, right?
Comment 1 Murray Cumming 2005-08-01 10:23:57 UTC
Thanks. Committed. However, Gtk::Combo is deprecated, and it's far more
important that we update that section to mention Gtk::ComboBox.
Comment 2 Murray Cumming 2005-08-01 10:32:10 UTC
Ignore the last comment: wrong bug.

I'm pretty sure that we already use most of those functions. We hide the context
(Ctxt) inside the *Parser instance. Maybe the *ValidCtxt is something new.
Comment 3 Murray Cumming 2005-08-01 10:32:40 UTC
Reopening. Didn't meant to close it.
Comment 4 Daniel Holbach 2005-08-01 10:38:02 UTC
concerning comment 2, I don't think that's correct:

daniel@bert:~/1/libxml++2.6-2.10.0$ grep -ir relax * | cut -d: -f1
daniel@bert:~/1/libxml++2.6-2.10.0$ grep -ir schema * | cut -d: -f1
docs/reference/2.10/html/classxmlpp_1_1TextReader.html
docs/reference/2.10/html/classxmlpp_1_1TextReader.html
docs/reference/Doxyfile.in
docs/reference/Doxyfile
libxml++/parsers/textreader.h
daniel@bert:~/1/libxml++2.6-2.10.0$

lixml++/parsers/textreader.h just has this comment:
/** Whether an Attribute node was generated from the default value defined in
the DTD or schema.
Comment 5 Luis Villa 2005-08-24 21:47:01 UTC
Please use the gnome milestone field only to indicate gnome-wide showstoppers.
Thanks.
Comment 6 Brent Smith (smitten) 2005-10-23 19:10:55 UTC
marking as new
Comment 7 Murray Cumming 2005-12-15 14:02:13 UTC
> concerning comment 2, I don't think that's correct:
>
> daniel@bert:~/1/libxml++2.6-2.10.0$ grep -ir relax * | cut -d: -f1
> daniel@bert:~/1/libxml++2.6-2.10.0$ grep -ir schema * | cut -d: -f1

But you mentioned this API:

> *ParserCtxtPtr, *ValidCtxtPtr, *Ptr
> *NewParserCtxt(), *Parse(), *FreeParserCtxt(), *NewParserCtxt(),
> *NewValidCtxt(), *ValidateDoc(), *FreeValidCtxt()

Mabe we need to know what * is. Sorry for being pedantic, but I think precision
is useful when dealing with the obscure libxml API.

Comment 8 Murray Cumming 2006-11-17 07:39:54 UTC
This is still unclear to me. I'd like an actual list of libxml functions that we don't wrap, please, ideally not containing functions that we do wrap. Examples of their use would be even better.
Comment 9 Emilien KIA 2007-06-05 10:03:50 UTC
Created attachment 89401 [details] [review]
Patch to add schema

This is a patch to add XML schema validation capability to libxml++.

This patch is only tested on linux. As I have not any other platform, I cant add files to projects other than autotools.

Regards
Emilien
Comment 10 Murray Cumming 2007-06-10 17:20:20 UTC
Created attachment 89706 [details] [review]
libxmlpp_schema.patch

This is a svn diff version of the patch, so that it doesn't include changes to generated files. It still needs a ChangeLog entry.

I have not yet looked at the patch properly.
Comment 11 Murray Cumming 2007-06-15 09:05:59 UTC
Note that my revised patch is missing the schema.h and schema.cc files from the original patch.
Comment 12 Emilien KIA 2007-06-15 09:59:08 UTC
Ok cool.
Thanks to generate it, I dont work on svn tree.
Comment 13 Tirpak Balazs 2008-01-25 16:01:29 UTC
So, will this patch be added to libxml++?

(In reply to comment #10)
> Created an attachment (id=89706) [edit]
> libxmlpp_schema.patch
> 
> This is a svn diff version of the patch, so that it doesn't include changes to
> generated files. It still needs a ChangeLog entry.
> 
> I have not yet looked at the patch properly.
> 

Comment 14 Murray Cumming 2008-03-18 16:20:07 UTC
I didn't like that this seems to be a separate class rather than just support for schemas in the regular parsers, but I see that the API is the same as our existing DtdValidator class. I guess that is used to validate a document with a DTD other than the one mentioned in the document. 

But is this new class the only way to validate with a Schema instead of a DTD, or does it also work if you just mention the Schema in the document?
Comment 15 Murray Cumming 2008-03-26 17:36:06 UTC
I have applied this in svn trunk and I will soon do a libxml++ 2.23.1 tarball release.

Sorry for the delay, Emilien. Without the ChangeLog entry it wasn't clear to me until recently.
Comment 16 Tirpak Balazs 2008-08-28 13:35:52 UTC
Hi,

I'd reop this bug, if I know how to do that. There are some problems with the schema wrapper.

1st: xmlSchemaFree is used nowhere, though xmlSchemaParser is used ->mem leak
2nd: in schema.cc, release_underlying method: impl_ = 0 -> really bad!
3rd: embedded_doc_ variable will never be true, so in release_underlying nothing will be freed, deleted, etc.
4th: in schema.cc, set_document: the embbed parameter is never used.
Comment 17 Murray Cumming 2008-08-28 13:39:58 UTC
That sounds rather bad. Could you try to make a patch, please?
Comment 18 Tirpak Balazs 2008-08-28 14:13:49 UTC
Sorry, but I do not have the time to investigate this further, though the patch should be straightforward as soon as someone finds out what embbeded_doc_ is really used for.

This patch resolves the mem leak problem in the case where set_document is not used (which is exactly the case what I am using it for) (though if set_document is used, it still won't be freed because of the embbeded_doc_ is always false problem)

--- a/libxml++/schema.cc
+++ b/libxml++/schema.cc
 void Schema::release_underlying()
 {
+  if (impl_)
+    xmlSchemaFree(impl_);
+
Comment 19 Murray Cumming 2008-12-05 21:21:46 UTC
Created attachment 124025 [details] [review]
libxml++_schemafree.patch

I have committed this patch, which is what I think you are suggesting. I would appreciate it if someone could test that this fixes the problem.
Comment 20 Przemysław Grzegorczyk 2008-12-12 10:45:01 UTC
Created attachment 124504 [details] [review]
schema.cc patch

There is a little bug in schema.cc and libxml++ won't build.
This patch fixes that.
Comment 21 Murray Cumming 2008-12-12 12:09:30 UTC
Thanks. Committed.