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



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.

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.  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!

I'm not sure exactly what expat has.


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)
b. report back all errors during validation
c. ignore any schema specified in the XML file
d. prevent the user overriding the validation using DTDs
e. ignore all schema embedded in the XML file

I am sure that my current "startDocument"/"endDocument", "startElement"/"endElement"  and "characters" routines can be quickly converted from MSXML to libxml2.  Hopefully, the error and warning routings will also convert OK.

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.

Thank you in advance.

David



On 23/06/06, Daniel Veillard <veillard redhat com> wrote:
On Fri, Jun 23, 2006 at 08:28:15PM +0100, David Kelvin wrote:
> Q. What would be the equivalent of the above in "libxml2"?

no idea, I don't know MS XML api nor the semantic of the code you pasted.
mayeb someone else does.

> I would like to build a 'minimal' version of libxml2.dll (under VS2005 -
> VC8) that just has enough in it to do what I require - SAX2, validation
> using a fixed specified external XSD schema (elements are only one of types:
> string, integer, date or time), some elements have attributes required or
> optional, most (but not all) character data is in CDATA blocks and, of
> course, parsing (startDocument, startElement, characters, endElement and
> endDocument).  However, the file "configure.js" has so many options that I
> don't know which ones I need and which ones I can remove for my minimal
> libray.
>
> So my last question is:
>
> Q. Which options must I have to do what I want to do and which ones don't I
> need and can set to false?

You will need all the schemas/regexp start plus parser at least.
Unless you're really doing embedded systems I don't suggest to change the
default because you're just :
  1/ entering MS compilation mess, for which only a few people
     really answer on that list
  2/ generate your own version of the package which can lead to
     different behaviour, and unless you're on embedded systems
     it's very hard to control and fix once deployed.

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]