Re: [xml] Migration from MS XML and minimal build questions...



On 24/06/06, Daniel Veillard <veillard redhat com> wrote:


Okay. To me your approach sounds exactly like this:
   "I don't want to invest learning libxml2 API, it's just a quick hack
    until I get what I want, but please give me the code which will do this"
 
Daniel,
 
Sorry you feel that - I don't think it is quite true.  I am relatively new to coding XML and I started with MS's implementation.  I think I understand it (probably not as well as I should).  However, once started with one implementation, you use it as a reference point and expect other packages to do things is a similar way or, if not similar, to have equivalent features - some better, some not as good.  I have looked at the libxml2 API (honest) but it is rather like reading a telephone directory - it has all the information you will ever need but doesn't tell you how to make a call!  [As an aside - it would be nice to have the whole documentation in a PDF file!  Easier to print, especially on A4.]
 
I have been in the IT business more years than I care to admit (at least 30) and I learn much more from seeing working examples.  Even skeleton examples (giving the idea but not actually all the coding) help me.  The API documentation comes in when you already "know" what you want/need and just need the details to code it.  Well this is my way of working - sorry I am probably too old to change and if it isn't your way.
 

 
That code exists, in C form, basically when running
  xmllint --sax --schemas foo.xsd foo.xml
it will do exactly what I guess you are asking below. Of course xmllint has
far more code than what you ask for but it's there
 
Thank you for this.

As to the features that you mention as "default behaviour", I couldn't find this (the documentation of the API is very large and I could have missed this).  Can you tell me where is it documented please?


> If anyone has an example of using SAX2 to parse an XML file with the above
> features/properties - I would be very very grateful to look at it, i.e.
> a. validate the XML file with an external XSD file (that I specify at run
> time)

it exists in xmllint.c as part of the distribution but you will have
to pick the right code
around line 3318 there is code to generate a parsed schemas
around line 1614 there is a testSAX function that you should look at too
 
Thank you - I will look.


> I am sure that my current "startDocument"/"endDocument",
> "startElement"/"endElement"  and "characters" routines can be quickly
> converted from MSXML to libxml2.

not sure SAX/SAX2 is not defined for C everybody implemented it his own way
 
The logic will be the same (I hope) just the calling parameters/structure and return information.

> Hopefully, the error and warning routings
> will also convert OK.

unlikely either
 
Again, hopefully the logic will be same.

> Most of the documentation I have seen for most XML parsers don't include
> many examples that newcomers like me can use, although the API documentation
> is very good and detailed - it is just putting it together that is unclear.
> Some examples haven't been updated since SAX1.

On purpose. I think SAX is a very bad API for beginners, so I carefully
avoid sending them in that direction.
 
I actually disagree with you in the case where one (me) needs to process a record  at a time (my xml file is an export of a type of database, each record is written as an element with each field as a separate embedded element) rather than load the whole thing into a DOM memory just to import to a new database stucture (if I understand the difference between SAX & DOM).
 
Thank you for your time in responding and on pointers/details.  I will follow up and I will read/learn the libxml API (well not all of it!).
 
David
 
PS. Yes - if I get it working I will try and reduce the library.  As you know (certainly by now!), I do only need a minimal set of the large functionality of libxml2.  From what I have seen of the changes to libxml2, they are mostly in new functionality rather than the support of parsing and validation.  It would not be necessary to keep fully up to date.  Anyway, as long as there are no changes to the default behaviour for parsing/validation or their API, a new full version of libxml2 could be used "as is", as/when it is released even if I haven't produced a minimal version.
 


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