4#include <xercesc/dom/DOMDocument.hpp>
5#include <xercesc/dom/DOMElement.hpp>
7#include "xmlBase/Dom.h"
8#include "xmlBase/XmlParser.h"
9#include "xmlBase/docMan/DocClient.h"
10#include "xmlBase/docMan/DocMan.h"
13 XERCES_CPP_NAMESPACE_USE
15 DocMan* DocMan::m_self = 0;
24 if ( m_self == 0 ) { m_self =
new DocMan(); }
28 bool DocMan::parse(
const std::string& filename,
const std::string& docType ) {
32 DOMDocument* doc = m_parser->
parse( filename.c_str(), docType );
33 if ( doc == 0 )
return false;
35 if ( m_meFirst != 0 ) m_meFirst->handleChild( doc );
37 DOMElement*
root = doc->getDocumentElement();
44 if ( m_meFirst != 0 ) m_meFirst->handleChild( child );
47 if ( list ) list->
invoke( child );
53 if ( m_meFirst != 0 ) m_meFirst->handleChild( 0 );
64 m_lists.push_back( curList );
66 return curList->
add( client );
70 if ( m_meFirst != 0 )
return false;
79 for (
ix = 0;
ix < m_lists.size();
ix++ )
82 if ( eltName.compare( cur->
getName() ) == 0 )
return cur;
88 ClientsIt it = m_clients.begin();
89 const std::string& clientName = client->
getName();
90 while ( it != m_clients.end() )
93 if ( clientName.compare( ( *it )->getName() ) == 0 )
return 0;
96 if ( front ) m_clients.insert( m_clients.begin(), client );
97 else m_clients.push_back( client );
110 ClientsIt it = m_clients.begin();
111 while ( it != m_clients.end() )
113 ( *it )->handleChild( elt );
122 ListsIt it = m_lists.begin();
123 while ( it != m_lists.end() )
virtual const std::string & getName()=0
Nested class to keep track of clients for one element type.
void invoke(DomElement *elt)
call back each client in turn
const std::string & getName()
which list are we?
bool add(DocClient *client, bool front=false)
Add a client to list.
bool remove(DocClient *client)
DocMan allows different clients to share a single xml document.
virtual bool regClient(const std::string &eltName, DocClient *client)
static DocMan * getPointer()
Implements singleton.
bool regMeFirst(DocClient *client)
Register privileged client; only available to derived classes.
virtual bool parse(const std::string &filename, const std::string &docType=std::string(""))
ClientList * findList(const std::string &eltName)
static std::string getTagName(const DOMElement *node)
static DOMElement * getSiblingElement(const DOMNode *child)
Return next element sibling, if any.
static DOMElement * getFirstChildElement(const DOMNode *parent)
Get first child which is an element node, if any.