Main | License | Installation | FAQ | Screenshots | Contact | Links | Sf.net | Freshmeat.net | KDE-Apps.org
Requirements | Design | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

XMLReference< T > Class Template Reference
[XML C++ Wrappers]

#include <xmlReference.hpp>

Inheritance diagram for XMLReference< T >:
Inheritance graph
[legend]

Public Member Functions

 XMLReference (T *_node, XMLDocument *_document)
 XMLReference (const XMLReference< T > &r)
XMLReference< T > & operator= (const XMLReference< T > &r)
T & operator* (void) const
T * operator-> (void) const
T * get (void) const
 operator bool (void) const
bool operator! () const
std::string getNodeText (void) throw (Error,XMLException)
XMLReference< XalanNode > selectNode (const std::string &xPath) throw (Error,XMLException)
 Only implemented for XalanElement.
XMLNodeReferenceList selectNodes (const std::string &xPath) throw (Error,XMLException)
 Only implemented for XalanElement.
bool existNode (const std::string &xPath) throw (XMLException)
 Only implemented for XalanElement.
XMLDocumentgetDocument (void) const
template<>
XMLReference< XalanNode > selectNode (const std::string &xPath) throw(Error, XMLException)
template<>
XMLNodeReferenceList selectNodes (const std::string &xPath) throw(Error, XMLException)
template<>
bool existNode (const std::string &xPath) throw(XMLException)

Protected Attributes

T * node
XMLDocumentdocument

Detailed Description

template<class T>
class XMLReference< T >

Wrapper for XML-nodes and -elements of the Apache-library.

Date:
Mon Jan 10 2005
Author:
Jan Wedekind (wedesoft@users.sourceforge.net)

Definition at line 41 of file xmlReference.hpp.


Constructor & Destructor Documentation

template<class T>
XMLReference< T >::XMLReference ( T *  _node,
XMLDocument _document 
)
template<class T>
XMLReference< T >::XMLReference ( const XMLReference< T > &  r  ) 

Member Function Documentation

template<>
bool XMLReference< XalanElement >::existNode ( const std::string &  xPath  )  throw(XMLException) [inline]

Definition at line 81 of file xmlReference.cpp.

00083 {
00084   return selectNodes( xPath ).getLength() >= 1;
00085 }

template<class T>
bool XMLReference< T >::existNode ( const std::string &  xPath  )  throw (XMLException)

Only implemented for XalanElement.

template<class T>
T* XMLReference< T >::get ( void   )  const [inline]

Definition at line 55 of file xmlReference.hpp.

References XMLReference< T >::node.

Referenced by dynamic_pointer_cast().

00055 { return node; }

template<class T>
XMLDocument* XMLReference< T >::getDocument ( void   )  const [inline]

Definition at line 71 of file xmlReference.hpp.

References XMLReference< T >::document.

Referenced by dynamic_pointer_cast().

00071 { return document; }

template<class T>
std::string XMLReference< T >::getNodeText ( void   )  throw (Error,XMLException)
template<class T>
XMLReference< T >::operator bool ( void   )  const [inline]

Definition at line 57 of file xmlReference.hpp.

References XMLReference< T >::node.

00057 { return node != NULL; }

template<class T>
bool XMLReference< T >::operator! (  )  const [inline]

Definition at line 59 of file xmlReference.hpp.

References XMLReference< T >::node.

00059 { return node == NULL; }

template<class T>
T& XMLReference< T >::operator* ( void   )  const [inline]

Definition at line 51 of file xmlReference.hpp.

References XMLReference< T >::node.

00051 { assert( node != NULL ); return *node; }

template<class T>
T* XMLReference< T >::operator-> ( void   )  const [inline]

Definition at line 53 of file xmlReference.hpp.

References XMLReference< T >::node.

00053 { assert( node != NULL ); return node; }

template<class T>
XMLReference< T >& XMLReference< T >::operator= ( const XMLReference< T > &  r  ) 
template<>
XMLReference< XalanNode > XMLReference< XalanElement >::selectNode ( const std::string &  xPath  )  throw(Error, XMLException) [inline]

Definition at line 33 of file xmlReference.cpp.

References ERRORMACRO, XMLNodeReferenceList::getLength(), and XMLNodeReferenceList::item().

00034 {
00035   XMLNodeReferenceList nodeList( selectNodes( xPath ) );
00036   ERRORMACRO( nodeList.getLength() >= 1, Error, ,
00037               "Could not find XML node with x-path \"" << xPath  << "\"." );
00038   ERRORMACRO( nodeList.getLength() <= 1, Error, ,
00039               "There are multiple nodes with x-path \"" << xPath << "\"." );
00040   assert( nodeList.getLength() == 1 );
00041   return nodeList.item( 0 );
00042 }

template<class T>
XMLReference< XalanNode > XMLReference< T >::selectNode ( const std::string &  xPath  )  throw (Error,XMLException)

Only implemented for XalanElement.

template<>
XMLNodeReferenceList XMLReference< XalanElement >::selectNodes ( const std::string &  xPath  )  throw(Error, XMLException) [inline]

Definition at line 46 of file xmlReference.cpp.

References ERRORMACRO.

00047 {
00048   ERRORMACRO( document != NULL, Error, ,
00049               "Can not select nodes from empty XML document." );
00050 #ifdef SIMPLEXPATH
00051   XalanDocumentPrefixResolver thePrefixResolver( document );
00052   XPathEvaluator theEvaluator;
00053   // Using XalanDOMString-constructor, which is present in Xalan-C version
00054   // 1.9 and in earlier versions as well!
00055   NodeRefList obj =
00056     theEvaluator.selectNodeList( *document->getDOMSupport(), node,
00057                                  XalanDOMString( xPath.c_str() ).c_str(),
00058                                  thePrefixResolver );
00059 #else
00060   XPathProcessorImpl theXPathProcessor;
00061   XPath * const contextXPath = document->getXPathFactory()->create();
00062   const ElementPrefixResolverProxy prefixResolver
00063       ( node, *document->getEnvSupport(), *document->getDOMSupport() );
00064   theXPathProcessor.initXPath( *contextXPath,
00065   // With which version was this introduced exactly?
00066 #if _XALAN_VERSION >= 10500
00067                                *document->getXPathConstructionContext(),
00068 #endif
00069                                XalanDOMString( xPath.c_str() ),
00070                    prefixResolver );
00071 
00072   shared_ptr< XObjectPtr > obj( new XObjectPtr );
00073   *obj =
00074     contextXPath->execute( node, prefixResolver,
00075                            *document->getExecutionContext() );
00076 #endif
00077   return XMLNodeReferenceList( obj, document );
00078 }

template<class T>
XMLNodeReferenceList XMLReference< T >::selectNodes ( const std::string &  xPath  )  throw (Error,XMLException)

Only implemented for XalanElement.


Field Documentation

template<class T>
XMLDocument* XMLReference< T >::document [protected]

Definition at line 76 of file xmlReference.hpp.

Referenced by XMLReference< T >::getDocument().

template<class T>
T* XMLReference< T >::node [protected]

The documentation for this class was generated from the following file:


anymeal 0.31 - recipe management software - Make the most of your food! - © Jan Wedekind Sun Dec 19 19:36:06 2010 - GNU Free Documentation License