From: Stefan S. <se...@sy...> - 2003-01-22 14:51:52
|
hi there, I'm currently looking into existing C++ wrappers for libxml2. I'v written one myself, as a Quick Hack (tm), but would like to get rid of that and rather contribute to an existing one and focus on the stuff I'd actually do with that library... One thing I do a lot right now with xml documents is reading them in (DOM), then searching for specific data. I do this with xpath expressions, so I need a way to retrieve a 'NodeSet' from a document, given an xpath. What is needed for this is 1) a document to search in, 2) a context node, 3) the actual xpath expression. Would you be interested into a patch that adds such functionality ? You currently don't have a 'Document' class (though the 'DomParser' comes close), and the 'Node' class doesn't know the document it is part of. The simplest change would be an added 'lookup' method in the DomParser: typedef std::vector<Node *> NodeSet; // pointers or deep copies ? NodeSet DomParser::lookup(const Node *context, const std::string &xpath) const; Though there are a couple of 'issues': 1) I really think I'm not searching in a parser, but in a document (a DOM tree, actually), though it's the DomParser that creates it (factory). 2) For various reasons I think nodes should hold a reference to the document they are part of. This is important as soon as you want to interpret them, for example namespaces can only looked up in the document, the same is true for default attributes (defined in the dtd). Assuming the node knows its document, the above 'lookup' method could be written more naturally as 'NodeSet Node::lookup(const std::string &) const;' Another question I have is about the supported character domain. You currently use std::string, but it is obvious that this isn't enough, at least not if you want to provide a generic XML API. I read in a message about using glibmm. What's the background for this ? What functionality do you need from there ? Why wouldn't a simple replacement of std::string by std::wstring suffice ? The actual unicode processing isn't the scope of libxml++, or is it ? Looking forward to using libxml++ in my future work, kind regards, Stefan |