List Info

Thread: program interaction with XML config




program interaction with XML config
user name
2006-11-28 01:22:03
Hello -

I'm writing my first libxml2 program and first serious DTD
design of
any kind.  The program is a tablebase generator for
analyzing chess
endgames and the XML is used both as a configuration file to
control
the operation of the program and as a header on the
generated
tablebases.  Things like piece colors and types, any
restrictions on
their movements, how to handle captures and queening, the
exact layout
of the tablebase format, etc, are all specified in XML.

My problem relates to the DTD.  Right now, I'm just using a
SYSTEM
descriptor with the DTD in the cwd.  I've thought of using a
PUBLIC
descriptor; I've thought of using catalogs, but's here my
issue.

I really think that I want the DTD to be tied to the version
of the
program.  This is because I rely heavily on the DTD to
validate my XML
input.  I don't, for example, check for any unknown elements
in the
config file - I just assume that if the thing passed
validation, then
it can't have any unknown elements in it.  Makes the code a
lot
easier.

So I really don't want the program to go out over the
network and get
the latest and greatest version of the DTD, right?  I want
it to
validate against the version that the program is compiled
with...
I think.

So here's what it comes down to (I've provided all this
other stuff as
background so you can understand where I'm coming from):

Can I hardwire the DTD into the program?  I don't see
anything in the
API that lets me load a DTD from a char[] buffer - did I
miss this?

Or can anyone suggest some other way to handle this that I'm
missing?

Thank you.



 					-bwb

 					Brent Baccala
 					cosinefreesoft.org
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
program interaction with XML config
user name
2006-11-28 09:55:00
On Mon, Nov 27, 2006 at 08:22:03PM -0500, Brent Baccala
wrote:
[...]
  Design issues not really specific to libxml2
[...]
> Can I hardwire the DTD into the program?  I don't see
anything in the
> API that lets me load a DTD from a char[] buffer - did
I miss this?


 /**
 * xmlIOParseDTD:
 * sax:  the SAX handler block or NULL
 * input:  an Input Buffer
 * enc:  the charset encoding if known
 *
 * Load and parse a DTD
 * 
 * Returns the resulting xmlDtdPtr or NULL in case of error.
 * input will be freed by the function in any case.
 */

xmlDtdPtr
xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr
input,
              xmlCharEncoding enc) {

  You will have to create an xmlParserInputBufferPtr from a
in-memory string
but that's possible.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/v
irtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine  http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )