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



On Sat, Jun 24, 2006 at 09:23:45PM +0100, David Kelvin wrote:
Thank you

Re: Q2 and the minimal build - I will take your advice and try and get what
I want to do working with the full library.
 once you get it working then think about trimming it down.

Re: Q1, I accept that you may not be conversant with MS's implementation but
I had hoped that the comments would have indicated my intention.  The
examples and documentation on the site nearly all reference SAX1 not SAX2.

  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"

So tell me, with such an attitude, should I really write the code for you,
should I invest in you as a user ?

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

Also, most other implementations I have seen have a "putFeature" or
"putProperty" to set requirements:

e.g. MSXML:

// Want all errors
putFeature(L"exhaustive-errors", VARIANT_TRUE);
// Want to validate XML file
putFeature(L"schema-validation", VARIANT_TRUE);
// Ignore any schema specified in the XML file
putFeature(L"use-schema-location", VARIANT_FALSE);
// Don't allow user to override validation by using DTDs
putFeature(L"prohibit-dtd", VARIANT_TRUE);
// Ignore any schema embedded in the XML file
putFeature(L"use-inline-schema", VARIANT_FALSE);
// Only use the XSD place in the schema cache
putProperty(L"schemas", _variant_t(pSchemaCache.GetInterfacePtr()));

Xerces has similar features (via setFeature) and properties (via
setProperty) but I can't seem to do a one-to-one mapping!

  No in libxml2 it's very different.

I'm not sure exactly what expat has.

  no DTD nor XSd validation which makes things a bit easier.

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

b. report back all errors during validation

  default behaviour but you will have to swicth XSD 

c. ignore any schema specified in the XML file

  default behaviour

d. prevent the user overriding the validation using DTDs

  by default DTD loading and validation is not activated

e. ignore all schema embedded in the XML file

  default behaviour.

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

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

  unlikely either

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.
  In general w.r.t. to doc and code example, there are some:
    http://xmlsoft.org/examples/index.html
they don't cover everything, I take patches or new examples. We don't have
the manpower of the Microsoft or IBM teams to do this, heck nobody is paid
full time to work on libxml2, if that scares you well too bad, but you can
help too.


Daniel

-- 
Daniel Veillard      | Red Hat http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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