#include <dtd.h>
Inheritance diagram for wxXml2DTD:
The purpose of a Document Type Definition is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements. A DTD can be declared inline in your XML document, or as an external reference. Inlined DTDs look like:
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
External DTDs are linked this way:
<!DOCTYPE root-element SYSTEM "systemID = URI for the DTD"> or <!DOCTYPE root-element PUBLIC "externalID" "externalURI">
wxXml2DTD can represent both a full DTD (see IsFullDTD()) or just an external reference (see IsExternalReference()); in this last case, you can use the wxXml2DTD::LoadFullDTD() function to transform this DTD into a full DTD.
Last, you can also use wxXml2DTD as a special type of wxXml2Document: you can Load() or Save() a DTD in the same way you can do for wxXml2Document. wxXml2DTD::GetRoot() lets you navigate through the DTD, even if DTD manipulation using wxXml2Node is not completely supported yet.
Public Member Functions | |
wxXml2DTD () | |
Constructs an empty DTD. It cannot be used until you Create() it. | |
wxXml2DTD (const wxString &file) | |
Loads a DTD standalone file which then can be used to validate a wxXml2Document. | |
wxXml2DTD (const wxXml2Document &doc, const wxString &name, const wxString &externalid, const wxString &systemid) | |
Constructs a DTD with the given name, ExternalID and SystemID. | |
wxXml2DTD (xmlDtd *dtd) | |
Wraps a libxml2 DTD structure. | |
wxXml2DTD (const wxXml2DTD &dtd) | |
Copies the given wrapper (does not imply the XML structure copy). | |
virtual | ~wxXml2DTD () |
Destroys this DTD if it is completely unlinked from a greater XML tree. | |
bool | operator== (const wxXml2DTD &ns) const |
bool | operator!= (const wxXml2DTD &p) const |
wxXml2DTD & | operator= (const wxXml2DTD &dtd) |
void | Create (const wxXml2Document &doc, const wxString &name, const wxString &externalid, const wxString &systemid) |
Creates a new DTD and eventually attach it to the given document. | |
bool | Load (wxInputStream &, wxString *pErr=NULL) |
Loads an external DTD from the given wxInputStream. | |
bool | Load (const wxString &filename, wxString *pErr=NULL) |
A specialized version of the generic Load function for files. | |
int | Save (wxOutputStream &, long flags=wxXML2DOC_USE_NATIVE_NEWLINES) const |
Saves the DTD into the given wxOutputStream. | |
bool | Save (const wxString &filename, long flags=wxXML2DOC_USE_NATIVE_NEWLINES) const |
A specialized version of the generic Save function for files. | |
bool | LoadFullDTD (wxString *pErr=NULL) |
Loads the DTD specified by current SystemID or ExternalID+ExternalURI. | |
bool | IsOk () const |
Returns TRUE if this DTD is valid. | |
bool | IsNonEmpty () const |
Returns TRUE if this object is wrapping a non-NULL object. | |
bool | IsUnlinked () const |
Returns TRUE if this DTD is not linked as internal/external subset of any wxXml2Document. | |
bool | IsExternalReference () const |
Returns TRUE if this DTD is not an entire DTD but only a reference to another resource containing the full DTD. | |
bool | IsSystemSubset () const |
Returns TRUE if this is an external reference (see IsExternalReference) and it is a SYSTEM entity. | |
bool | IsPublicSubset () const |
Returns TRUE if this is an external reference (see IsExternalReference) and it is a PUBLIC entity. | |
bool | IsFullDTD () const |
Returns TRUE if this DTD is a "full" DTD: that is, it's not a *reference* to an external DTD but it contains at least one declaration of a node type. | |
wxString | GetExternalID () const |
Returns the externalID if this is a PUBLIC entity otherwise returns wxEmptyString. | |
wxString | GetExternalURI () const |
Returns the external URI (Uniform Resource Indicator) if this is a PUBLIC entity otherwise returns wxEmptyString. | |
wxString | GetSystemID () const |
Returns the systemID if this is a SYSTEM entity otherwise returns wxEmptyString. | |
wxString | GetName () const |
Returns the name of this DTD. | |
xmlDtd * | GetObj () const |
Returns the associated XML structure. | |
wxXml2BaseNode | GetRoot () const |
Returns the root node for this DTD. | |
void | SetName (const wxString &p) |
void | SetSystemID (const wxString &u) |
void | SetExternalID (const wxString &u) |
void | SetExternalURI (const wxString &u) |
Sets the external URI for this DTD. | |
void | SetRoot (wxXml2ElemDecl &node) |
Sets the root node for this DTD. | |
void | SetRoot (wxXml2AttrDecl &node) |
void | SetRoot (wxXml2EntityDecl &node) |
void | AddElemDecl (const wxString &name, wxXml2ElementTypeVal val=wxXML2_ELEMENT_TYPE_ELEMENT, wxXml2ElemContent &content=wxXml2EmptyElemContent) |
Creates a new wxXml2ElemDecl object and adds it to this DTD. | |
void | AddAttrDecl (const wxString &element, const wxString &name, const wxXml2Namespace &ns=wxXml2EmptyNamespace, wxXml2AttributeType type=wxXML2_ATTRIBUTE_CDATA, wxXml2AttributeDefault def=wxXML2_ATTRIBUTE_NONE, const wxString &defaultval=wxEmptyString, wxXml2Enumeration &e=wxXml2EmptyEnumeration) |
Creates a new wxXml2AttrDecl object and adds it to this DTD. | |
void | AddEntityDecl (const wxString &name, wxXml2EntityType type=wxXML2_INTERNAL_GENERAL_ENTITY, const wxString &externalID=wxEmptyString, const wxString &systemID=wxEmptyString, const wxString &content=wxEmptyString) |
Creates a new wxXml2EntityDecl object and adds it to this DTD. | |
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 wxXml2DTD &dtd) |
int & | GetPrivate () const |
Returns the private member of the wrapped structure. | |
void | SetRoot (wxXml2BaseNode &node) |
This function is not public because it is too generic: with this function the user could set as root of a DTD also a wxXml2Node, wxXml2Property or a wxXml2Namespace since they are classes derived from wxXml2BaseNode. |
wxXml2DTD::wxXml2DTD | ( | ) | [inline] |
Constructs an empty DTD. It cannot be used until you Create() it.
wxXml2DTD::wxXml2DTD | ( | const wxString & | file | ) | [inline] |
Loads a DTD standalone file which then can be used to validate a wxXml2Document.
wxXml2DTD::wxXml2DTD | ( | const wxXml2Document & | doc, | |
const wxString & | name, | |||
const wxString & | externalid, | |||
const wxString & | systemid | |||
) | [inline] |
Constructs a DTD with the given name, ExternalID and SystemID.
wxXml2DTD::wxXml2DTD | ( | xmlDtd * | dtd | ) | [inline] |
Wraps a libxml2 DTD structure.
wxXml2DTD::wxXml2DTD | ( | const wxXml2DTD & | dtd | ) | [inline] |
Copies the given wrapper (does not imply the XML structure copy).
virtual wxXml2DTD::~wxXml2DTD | ( | ) | [inline, virtual] |
Destroys this DTD if it is completely unlinked from a greater XML tree.
void wxXml2DTD::AddAttrDecl | ( | const wxString & | element, | |
const wxString & | name, | |||
const wxXml2Namespace & | ns = wxXml2EmptyNamespace , |
|||
wxXml2AttributeType | type = wxXML2_ATTRIBUTE_CDATA , |
|||
wxXml2AttributeDefault | def = wxXML2_ATTRIBUTE_NONE , |
|||
const wxString & | defaultval = wxEmptyString , |
|||
wxXml2Enumeration & | e = wxXml2EmptyEnumeration | |||
) |
Creates a new wxXml2AttrDecl object and adds it to this DTD.
void wxXml2DTD::AddElemDecl | ( | const wxString & | name, | |
wxXml2ElementTypeVal | val = wxXML2_ELEMENT_TYPE_ELEMENT , |
|||
wxXml2ElemContent & | content = wxXml2EmptyElemContent | |||
) |
Creates a new wxXml2ElemDecl object and adds it to this DTD.
void wxXml2DTD::AddEntityDecl | ( | const wxString & | name, | |
wxXml2EntityType | type = wxXML2_INTERNAL_GENERAL_ENTITY , |
|||
const wxString & | externalID = wxEmptyString , |
|||
const wxString & | systemID = wxEmptyString , |
|||
const wxString & | content = wxEmptyString | |||
) |
Creates a new wxXml2EntityDecl object and adds it to this DTD.
void wxXml2DTD::Copy | ( | const wxXml2DTD & | dtd | ) | [inline, protected] |
void wxXml2DTD::Create | ( | const wxXml2Document & | doc, | |
const wxString & | name, | |||
const wxString & | externalid, | |||
const wxString & | systemid | |||
) |
Creates a new DTD and eventually attach it to the given document.
void wxXml2DTD::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.
wxString wxXml2DTD::GetExternalID | ( | ) | const [inline] |
Returns the externalID if this is a PUBLIC entity otherwise returns wxEmptyString.
See IsPublicSubset().
wxString wxXml2DTD::GetExternalURI | ( | ) | const [inline] |
Returns the external URI (Uniform Resource Indicator) if this is a PUBLIC entity otherwise returns wxEmptyString.
See IsPublicSubset().
wxString wxXml2DTD::GetName | ( | ) | const [inline] |
Returns the name of this DTD.
This is always non-empty: both when this is a reference to a full external DTD and when this is an inlined DTD.
xmlDtd* wxXml2DTD::GetObj | ( | ) | const [inline] |
Returns the associated XML structure.
int& wxXml2DTD::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.
wxXml2BaseNode wxXml2DTD::GetRoot | ( | ) | const |
Returns the root node for this DTD.
If this is just a reference to an external DTD, then the result is wxXml2EmptyNode.
wxString wxXml2DTD::GetSystemID | ( | ) | const [inline] |
Returns the systemID if this is a SYSTEM entity otherwise returns wxEmptyString.
See IsSystemSubset().
bool wxXml2DTD::IsExternalReference | ( | ) | const |
Returns TRUE if this DTD is not an entire DTD but only a reference to another resource containing the full DTD.
See wxXml2DTD's class description for more info about the difference between inlined/external DTD.
bool wxXml2DTD::IsFullDTD | ( | ) | const [inline] |
Returns TRUE if this DTD is a "full" DTD: that is, it's not a *reference* to an external DTD but it contains at least one declaration of a node type.
A "full" DTD can be an inlined DTD obtained using the wxXml2Document::GetDTD() function or it could be a standalone DTD loaded using wxXml2DTD::Load() function. See wxXml2DTD's class description for more info about the difference between inlined/external DTD.
bool wxXml2DTD::IsNonEmpty | ( | ) | const [inline, virtual] |
bool wxXml2DTD::IsOk | ( | ) | const |
Returns TRUE if this DTD is valid.
bool wxXml2DTD::IsPublicSubset | ( | ) | const |
Returns TRUE if this is an external reference (see IsExternalReference) and it is a PUBLIC entity.
PUBLIC subsets are declared as follows: <!DOCTYPE Name PUBLIC "externalID" "externalURI"> PUBLIC subsets can be loaded using LoadFullDTD. PUBLIC subsets always have an empty SystemID (see GetSystemID) and a non-empty ExternalID (see GetExternalID) and a non-empty ExternalURI (see GetExternalURI).
bool wxXml2DTD::IsSystemSubset | ( | ) | const |
Returns TRUE if this is an external reference (see IsExternalReference) and it is a SYSTEM entity.
SYSTEM subsets are declared as follows: <!DOCTYPE Name SYSTEM "systemID"> SYSTEM subsets can be loaded using LoadFullDTD. SYSTEM subsets always have a non-empty SystemID (see GetSystemID) and an empty ExternalID (see GetExternalID) and an empty ExternalURI.
bool wxXml2DTD::IsUnlinked | ( | ) | const [inline, virtual] |
Returns TRUE if this DTD is not linked as internal/external subset of any wxXml2Document.
Implements wxXml2Wrapper.
bool wxXml2DTD::Load | ( | const wxString & | filename, | |
wxString * | pErr = NULL | |||
) |
A specialized version of the generic Load function for files.
bool wxXml2DTD::Load | ( | wxInputStream & | , | |
wxString * | pErr = NULL | |||
) |
Loads an external DTD from the given wxInputStream.
If a document is attached to this DTD and the DTD is loaded correctly, then the document is attached to the new DTD.
bool wxXml2DTD::LoadFullDTD | ( | wxString * | pErr = NULL |
) |
Loads the DTD specified by current SystemID or ExternalID+ExternalURI.
Returns FALSE if this is not a reference to an external DTD or if the DTD specified by the current SystemID/ExternalURI could not be loaded.
bool wxXml2DTD::operator!= | ( | const wxXml2DTD & | p | ) | const [inline] |
bool wxXml2DTD::operator== | ( | const wxXml2DTD & | ns | ) | const |
bool wxXml2DTD::Save | ( | const wxString & | filename, | |
long | flags = wxXML2DOC_USE_NATIVE_NEWLINES | |||
) | const |
A specialized version of the generic Save function for files.
int wxXml2DTD::Save | ( | wxOutputStream & | , | |
long | flags = wxXML2DOC_USE_NATIVE_NEWLINES | |||
) | const |
Saves the DTD into the given wxOutputStream.
Only the wxXML2DOC_USE_NATIVE_NEWLINES flag is currently supported.
void wxXml2DTD::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 wxXml2DTD::SetExternalID | ( | const wxString & | u | ) |
void wxXml2DTD::SetExternalURI | ( | const wxString & | u | ) | [inline] |
Sets the external URI for this DTD.
void wxXml2DTD::SetName | ( | const wxString & | p | ) |
void wxXml2DTD::SetRoot | ( | wxXml2EntityDecl & | node | ) | [inline] |
void wxXml2DTD::SetRoot | ( | wxXml2AttrDecl & | node | ) | [inline] |
void wxXml2DTD::SetRoot | ( | wxXml2ElemDecl & | node | ) | [inline] |
Sets the root node for this DTD.
void wxXml2DTD::SetRoot | ( | wxXml2BaseNode & | node | ) | [protected] |
This function is not public because it is too generic: with this function the user could set as root of a DTD also a wxXml2Node, wxXml2Property or a wxXml2Namespace since they are classes derived from wxXml2BaseNode.
The overloaded versions of SetRoot will ensure this won't happen.
void wxXml2DTD::SetSystemID | ( | const wxString & | u | ) |