[Expat-discuss] (no subject)
marktt at excite.com
Mon Jun 30 15:42:27 EDT 2003
> No need to do any of that. Expat will pass the prefix if you set the > NSTriplet option.
I am sorry, may be I wasn't clear enough.
Suppose I have an XML file containing:
<A xmlns:foo="uri://example" xmlns:gg="uri://example2">
Expat can handle gg:attr2, but it cannot handle the value of attr.
The type of the attribute 'attr' is QName. expat doesn't (and cannot) know that. I want to be able to determine what namespace corresponds to foo. It would be great if expat had a function to do that (e.g. const XML_Char *XML_GetNamespace(const XML_Char *prefix)), but since it doesn't, I have to do this manually by keeping track of all namespace aliases seen so far (including keeping track of the current and previous default namespaces).
The obvious way to do it is to use a stack (I assume expat uses a stack internally). I want to avoid the overhead of calling 2 strdup()'s before storing a <prefix, namespace> pair on the stack. This seems safe to do (not using strdup()), since expat must have the aliases stored somewhere, otherwise it won't be able to expand elements or attributes of the form alias:local-name. I just want to be sure that it's really safe, is it?
Also, I want to take this one step further and avoid the overhead of having a separate stack, and access expat's stack directly instead. Can you send me info on where can I find the code that deals with storing/retrieiving <prefix, namespace> pairs? (I know my code will not be portable, but efficiency is more important for me).
My problem will be solved if expat had an XML_GetNamespace() function, so please consider having it in future releases.
Join Excite! - http://www.excite.com
The most personalized portal on the Web!
More information about the Expat-discuss