wxXml2Document Class Reference

#include <xml2.h>

Inheritance diagram for wxXml2Document:

wxXml2Wrapper List of all members.

Detailed Description

This class holds XML data/document as parsed by the libxml2 parser.

Use Load and Save to perform IO on wxStream or on wxFile objects. Use the GetRoot() function to edit the contents of the XML document through wxXml2Node functions.


Public Member Functions

 wxXml2Document ()
 Creates an empty document.
 wxXml2Document (wxXml2Node &root)
 Constructs a document and sets its root to the given node.
 wxXml2Document (const wxString &filename)
 Loads the given filename and parse it.
 wxXml2Document (xmlDoc *doc)
 Wraps the given libxml2 structure.
 wxXml2Document (const wxXml2Document &doc)
 Copies the given wrapper (does not imply the XML structure copy).
virtual ~wxXml2Document ()
 Destructor.
bool operator== (const wxXml2Document &doc) const
bool operator!= (const wxXml2Document &doc) const
wxXml2Documentoperator= (const wxXml2Document &doc)
bool Create (const wxString &version=wxT("1.0"))
 Creates a new empty XML document with the given version.
bool Load (wxInputStream &stream, wxString *pErr=NULL)
 Parses the data from the given wxInputStream. See Load().
bool Load (const wxString &filename, wxString *pErr=NULL)
 Parses XML & XHTML file and loads data.
int Save (wxOutputStream &stream, const wxString &encoding=wxT("UTF-8"), long flags=wxXML2DOC_USE_NATIVE_NEWLINES, int indentstep=4) const
 Saves the XML data in the given stream with the given encoding.
bool Save (const wxString &filename, const wxString &encoding=wxT("UTF-8"), long flags=wxXML2DOC_USE_NATIVE_NEWLINES, int indentstep=4) const
 Saves the document as XML or XHTML file in the given encoding format.
bool IsNonEmpty () const
 Returns TRUE if this object is wrapping a non-NULL object.
bool IsOk () const
 Returns TRUE if everything is okay in the XML tree structure.
bool IsUnlinked () const
 Returns always TRUE since documents are entities which contain links to other structures (wxXml2DTD, wxXml2Node.
bool IsDTDValid (wxString *err=NULL, int bUseInternal=0) const
 Checks if this document is conform to the DTD which it holds.
wxXml2Node GetRoot () const
 Returns the root node of the document.
wxXml2DTD GetDTD () const
 Returns the internal DTD associated with this document.
wxString GetVersion () const
 Returns version of document (may be empty).
wxString GetFileEncoding () const
 Returns encoding of document (may be empty).
xmlDoc * GetObj () const
 Returns the libxml2 underlying object.
void SetRoot (wxXml2Node &node)
 Changes the root of the document (deleting old one).
void SetDTD (wxXml2DTD &dtd)
 Sets the DTD for this document.
void SetStyleSheet (const wxString &xslfile)
 Creates a PI node of the type: <?xml-stylesheet type="text/xsl" href="xslfile"?> where "xslfile" is the given URI to an XSL file.
void SetMathMLDTD ()
 Sets the MathML DTD for this document.
void SetXHTMLStrictDTD ()
 Sets the XHTML DTD for this document.
void SetXHTMLTransitionalDTD ()
void SetXHTMLFrameSetDTD ()

Protected Member Functions

void Destroy ()
 Destroys the data wrapped by this class freeing its memory.
void SetAsEmpty ()
 Sets this element as empty: that is wrapping a NULL pointer.
void Copy (const wxXml2Document &doc)
int & GetPrivate () const
 Returns the private member of the wrapped structure.


Constructor & Destructor Documentation

wxXml2Document::wxXml2Document (  )  [inline]

Creates an empty document.

Use the Create function before using it.

wxXml2Document::wxXml2Document ( wxXml2Node root  ) 

Constructs a document and sets its root to the given node.

wxXml2Document::wxXml2Document ( const wxString &  filename  )  [inline]

Loads the given filename and parse it.

wxXml2Document::wxXml2Document ( xmlDoc *  doc  )  [inline]

Wraps the given libxml2 structure.

wxXml2Document::wxXml2Document ( const wxXml2Document doc  )  [inline]

Copies the given wrapper (does not imply the XML structure copy).

virtual wxXml2Document::~wxXml2Document (  )  [inline, virtual]

Destructor.


Member Function Documentation

void wxXml2Document::Copy ( const wxXml2Document doc  )  [inline, protected]

bool wxXml2Document::Create ( const wxString &  version = wxT("1.0")  ) 

Creates a new empty XML document with the given version.

void wxXml2Document::Destroy (  )  [inline, protected, virtual]

Destroys the data wrapped by this class freeing its memory.

This function should not try to update the reference count since it should have been already updated by the caller.

Implements wxXml2Wrapper.

wxXml2DTD wxXml2Document::GetDTD (  )  const

Returns the internal DTD associated with this document.

If no internal DTDs are associated then wxXml2EmptyDTD is returned.

Note:
The DTD associated with this document could be only a simple line like: <!DOCTYPE mydtd SYSTEM "mydtd.dtd"> to intercept this case, you should use the wxXml2DTD::IsExternalReference() function.

wxString wxXml2Document::GetFileEncoding (  )  const [inline]

Returns encoding of document (may be empty).

Note: this is the encoding original file was saved in, *not* the encoding of in-memory representation!

xmlDoc* wxXml2Document::GetObj (  )  const [inline]

Returns the libxml2 underlying object.

int& wxXml2Document::GetPrivate (  )  const [inline, protected, virtual]

Returns the private member of the wrapped structure.

This function should be used to implement copy constructor and assignment operators.

Implements wxXml2Wrapper.

wxXml2Node wxXml2Document::GetRoot (  )  const

Returns the root node of the document.

wxString wxXml2Document::GetVersion (  )  const [inline]

Returns version of document (may be empty).

bool wxXml2Document::IsDTDValid ( wxString *  err = NULL,
int  bUseInternal = 0 
) const

Checks if this document is conform to the DTD which it holds.

Parameters:
bUseInternal If this parameter is set to 1, then the internal subset (m_doc->intSubset) will be used. If this parameter is set to 0, then the external subset (m_doc->extSubset) will be used. If this parameter is set to -1, then the subset will be chosen automatically (the first valid one).
Note:
Libxml2 does not specify if a document can hold both an internal and an external subset. Anyway, the internal one should be the preferred choice; besides, it is the DTD returned by GetDTD() function.

bool wxXml2Document::IsNonEmpty (  )  const [inline, virtual]

Returns TRUE if this object is wrapping a non-NULL object.

Implements wxXml2Wrapper.

bool wxXml2Document::IsOk (  )  const [inline]

Returns TRUE if everything is okay in the XML tree structure.

bool wxXml2Document::IsUnlinked (  )  const [inline, virtual]

Returns always TRUE since documents are entities which contain links to other structures (wxXml2DTD, wxXml2Node.

..) but a doc is never linked with structures that are not own by itself.

Implements wxXml2Wrapper.

bool wxXml2Document::Load ( const wxString &  filename,
wxString *  pErr = NULL 
)

Parses XML & XHTML file and loads data.

Returns TRUE on success. Returns FALSE otherwise & provide an error description if the given pointer is not NULL.

bool wxXml2Document::Load ( wxInputStream &  stream,
wxString *  pErr = NULL 
)

Parses the data from the given wxInputStream. See Load().

bool wxXml2Document::operator!= ( const wxXml2Document doc  )  const [inline]

wxXml2Document& wxXml2Document::operator= ( const wxXml2Document doc  )  [inline]

bool wxXml2Document::operator== ( const wxXml2Document doc  )  const

bool wxXml2Document::Save ( const wxString &  filename,
const wxString &  encoding = wxT("UTF-8"),
long  flags = wxXML2DOC_USE_NATIVE_NEWLINES,
int  indentstep = 4 
) const

Saves the document as XML or XHTML file in the given encoding format.

Returns TRUE on success.

int wxXml2Document::Save ( wxOutputStream &  stream,
const wxString &  encoding = wxT("UTF-8"),
long  flags = wxXML2DOC_USE_NATIVE_NEWLINES,
int  indentstep = 4 
) const

Saves the XML data in the given stream with the given encoding.

Returns the number of bytes written: -1 if there were errors.

void wxXml2Document::SetAsEmpty (  )  [inline, protected, virtual]

Sets this element as empty: that is wrapping a NULL pointer.

This function *must not* free the memory of the currently wrapped pointer: it must just reset that pointer to NULL. This function is used by DestroyIfUnlinked().

Implements wxXml2Wrapper.

void wxXml2Document::SetDTD ( wxXml2DTD dtd  ) 

Sets the DTD for this document.

void wxXml2Document::SetMathMLDTD (  ) 

Sets the MathML DTD for this document.

void wxXml2Document::SetRoot ( wxXml2Node node  ) 

Changes the root of the document (deleting old one).

void wxXml2Document::SetStyleSheet ( const wxString &  xslfile  ) 

Creates a PI node of the type: <?xml-stylesheet type="text/xsl" href="xslfile"?> where "xslfile" is the given URI to an XSL file.

void wxXml2Document::SetXHTMLFrameSetDTD (  ) 

void wxXml2Document::SetXHTMLStrictDTD (  ) 

Sets the XHTML DTD for this document.

void wxXml2Document::SetXHTMLTransitionalDTD (  ) 


The documentation for this class was generated from the following files:
Generated on Thu Sep 28 14:58:01 2006 for wxXml2 by  doxygen 1.4.7