[xml] What is the _private field actually for?



I've just realised that the XInclude mechanism does not support this, as it creates its own XML parser context internally and doesn't provide any mechanism to pass in user data via the _private field.

I've tried creating a new function: xmlXIncludeProcessFlagsData(), which takes an additional void* argument that it passes in to the _private field of the created XML parser context. This works fine.

However, I've discovered when parsing an XML document that uses external entities, the context used for parsing the external entities does not preserve the _private field of the original parser context.

eg. If I try to parse the following document using xmlCtxtReadFile:

<!DOCTYPE foo [
<!ENTITY bar SYSTEM "bar.xml">
]>
<foo>Hello &bar; world!</foo>

the context that I pass in (with _private field set) will *not* be used to parse the external entity "bar.xml". Strangely enough, the context that I pass in *will* be used to parse external DTDs, which seems a bit inconsistent.

It seems that further patches to libxml2 will be necessary if I want to be able to use the _private field of the XML parser context in this way. Which leads me to ask what the _private field exists for in the first place, if it cannot be relied upon to be there. What is the use case for this application data field, and in what situations can it actually be used reliably?

(On a slightly unrelated note, it seems that requirements for a future libxml3 have been circulating since 2002 or before. Has there been any progress since then? :)

Cheers,

Michael

--
Print XML with Prince!
http://www.princexml.com



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