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

XMLDocument Class Reference
[XML C++ Wrappers]

#include <xmlDocument.hpp>

Inheritance diagram for XMLDocument:

Inheritance graph
[legend]

Public Member Functions

 XMLDocument (const std::string &schemaURI)
void load (const std::string &fileName) throw (Error)
void save (const std::string &fileName) throw (Error)
void fromString (const std::string &string) throw (Error)
void fromInputSource (InputSource &inputSource) throw (Error)
const XalanDocument * getDocument (void) const
XMLReference
< XalanElement > 
getDocumentElement (void)
XalanSourceTreeDOMSupport * getDOMSupport (void)
XPathEnvSupportDefault * getEnvSupport (void)
XPathFactoryDefault * getXPathFactory (void)
XPathExecutionContextDefault * getExecutionContext (void)

Protected Attributes

XMLErrorHandler xmlErrorHandler
 Error handler for catching parse errors.
const XalanDocument * document
 The XML DOM.
Xalan classes for parsing and maintaining the XML DOM


XalanSourceTreeDOMSupport theDOMSupport
XalanSourceTreeParserLiaison theLiaison
Xalan classes for making XPath queries


XPathEnvSupportDefault theEnvSupport
XObjectFactoryDefault theXObjectFactory
XPathFactoryDefault theXPathFactory
XPathExecutionContextDefault theExecutionContext

Detailed Description

Class for parsing XML documents. Don't forget to add the following initialization code to your main application, before using this class:
    XMLPlatformUtils::Initialize();
    XPathInit oTheXPathInit;
    
After using this class, execute the following code:
    XMLPlatformUtils::Terminate();
    
See Apache Xerces and Xalan documentation for more details.
Date:
Thu Mar 10 2005
Author:
Jan Wedekind (wedesoft@users.sourceforge.net)

Definition at line 68 of file xmlDocument.hpp.


Constructor & Destructor Documentation

XMLDocument::XMLDocument ( const std::string &  schemaURI  ) 

Constructor. Create empty XML-document and configure verification.

Parameters:
schemaURI (Namespace-URI and) XSD-filename of XML schema. Specify "", if you don't want verification.

Definition at line 39 of file xmlDocument.cpp.

References theDOMSupport, theLiaison, and xmlErrorHandler.

00039                                                     :
00040    theLiaison( theDOMSupport )
00041 #ifndef SIMPLEXPATH
00042   , theExecutionContext( theEnvSupport, theDOMSupport, theXObjectFactory )
00043 #endif
00044 {
00045   theDOMSupport.setParserLiaison( &theLiaison );
00046   theLiaison.setErrorHandler( &xmlErrorHandler );
00047   if ( !schemaURI.empty() ) {
00048 #ifndef NDEBUG
00049     cerr << "Specifying schema \"" << schemaURI << "\"." << endl;
00050 #endif
00051     if ( schemaURI.find( ' ' ) < schemaURI.size() )
00052       theLiaison.setExternalSchemaLocation
00053         ( StrX<XMLCh,char>( schemaURI.c_str() ).getBuffer() );
00054     else
00055       theLiaison.setExternalNoNamespaceSchemaLocation
00056         ( StrX<XMLCh,char>( schemaURI.c_str() ).getBuffer() );
00057     theLiaison.setUseValidation( true );
00058   };
00059   theLiaison.setDoNamespaces( true );
00060 };


Member Function Documentation

void XMLDocument::load ( const std::string &  fileName  )  throw (Error)

Definition at line 62 of file xmlDocument.cpp.

References ERRORMACRO, and fromInputSource().

00063 {
00064   // XALAN_USING_XERCES(LocalFileInputSource)
00065   try {
00066     LocalFileInputSource
00067       localFileInputSource( StrX<XMLCh,char>( fileName.c_str() ).getBuffer() );
00068     fromInputSource( localFileInputSource );
00069   } catch ( XMLException &exc ) {
00070     ERRORMACRO( false, Error, ,
00071                 "Could not load XML file \"" << fileName << "\": "
00072                 << ( StrX<char,XMLCh>( exc.getMessage() ).getBuffer() ) );
00073   };
00074 };

void XMLDocument::save ( const std::string &  fileName  )  throw (Error)

Definition at line 76 of file xmlDocument.cpp.

References ERRORMACRO.

00077 {
00078   ERRORMACRO( false, Error, ,
00079               "Saving of xml-documents not implemented yet." );
00080 }

void XMLDocument::fromString ( const std::string &  string  )  throw (Error)

Referenced by CookBook::getVersion().

void XMLDocument::fromInputSource ( InputSource &  inputSource  )  throw (Error)

Definition at line 91 of file xmlDocument.cpp.

References document, ERRORMACRO, XMLErrorHandler::getErrorMessage(), XMLErrorHandler::getErrorOccurred(), theLiaison, and xmlErrorHandler.

Referenced by load().

00092 {
00093   document = theLiaison.parseXMLStream( inputSource );
00094   if ( xmlErrorHandler.getErrorOccurred() ) {
00095     ERRORMACRO( false, Error, ,
00096                 "Parse error in XML file: "
00097                 << xmlErrorHandler.getErrorMessage() );
00098   };
00099   assert( document != NULL );
00100 }

const XalanDocument* XMLDocument::getDocument ( void   )  const [inline]

Definition at line 85 of file xmlDocument.hpp.

References document.

00086   { return document; }

XMLReference< XalanElement > XMLDocument::getDocumentElement ( void   )  [inline]

Definition at line 88 of file xmlDocument.hpp.

References document.

Referenced by CookBook::getVersion().

00089   { return XMLReference< XalanElement >
00090       ( document->getDocumentElement(), this ); }

XalanSourceTreeDOMSupport* XMLDocument::getDOMSupport ( void   )  [inline]

Definition at line 93 of file xmlDocument.hpp.

References theDOMSupport.

00094   { return &theDOMSupport; }

XPathEnvSupportDefault* XMLDocument::getEnvSupport ( void   )  [inline]

Definition at line 96 of file xmlDocument.hpp.

References theEnvSupport.

00096 { return &theEnvSupport; }

XPathFactoryDefault* XMLDocument::getXPathFactory ( void   )  [inline]

Definition at line 103 of file xmlDocument.hpp.

00103 { return &theXPathFactory; }

XPathExecutionContextDefault* XMLDocument::getExecutionContext ( void   )  [inline]

Definition at line 105 of file xmlDocument.hpp.

References theExecutionContext.

00106   { return &theExecutionContext; }


Field Documentation

XalanSourceTreeDOMSupport XMLDocument::theDOMSupport [protected]

Definition at line 112 of file xmlDocument.hpp.

Referenced by getDOMSupport(), and XMLDocument().

XalanSourceTreeParserLiaison XMLDocument::theLiaison [protected]

Definition at line 114 of file xmlDocument.hpp.

Referenced by fromInputSource(), and XMLDocument().

XMLErrorHandler XMLDocument::xmlErrorHandler [protected]

Error handler for catching parse errors.

Definition at line 117 of file xmlDocument.hpp.

Referenced by fromInputSource(), and XMLDocument().

const XalanDocument* XMLDocument::document [protected]

The XML DOM.

Definition at line 119 of file xmlDocument.hpp.

Referenced by fromInputSource(), getDocument(), and getDocumentElement().

XPathEnvSupportDefault XMLDocument::theEnvSupport [protected]

Definition at line 125 of file xmlDocument.hpp.

Referenced by getEnvSupport().

XObjectFactoryDefault XMLDocument::theXObjectFactory [protected]

Definition at line 127 of file xmlDocument.hpp.

XPathFactoryDefault XMLDocument::theXPathFactory [protected]

Definition at line 134 of file xmlDocument.hpp.

XPathExecutionContextDefault XMLDocument::theExecutionContext [protected]

Definition at line 136 of file xmlDocument.hpp.

Referenced by getExecutionContext().


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

anymeal 0.30 - recipe management software - Make the most of your food! - © Jan Wedekind Sun Sep 14 16:01:29 2008 - GNU Free Documentation License