Base Framework
Public Types | Public Member Functions | Protected Member Functions | List of all members
Document Class Reference

DOM document. More...

#include <base/xml/Document.h>

Inherits Node.

Public Types

typedef Array< Pair< String, String > > PrefixNamespace
 
- Public Types inherited from Node
enum  NodeType {
  ELEMENT_NODE, ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE,
  ENTITY_REFERENCE_NODE, ENTITY_NODE, PROCESSING_INSTRUCTION_NODE, COMMENT_NODE,
  DOCUMENT_NODE, DOCUMENT_TYPE_NODE, DOCUMENT_FRAGMENT_NODE, NOTATION_NODE,
  ATTRIBUTE_DECL_NODE, ELEMENT_DECL_NODE, ENTITY_DECL_NODE
}
 

Public Member Functions

 Document ()
 
 Document (ShadowDocument document) noexcept
 
DocumentType getDocumentType () noexcept
 
DOMImplementation getImplementation () noexcept
 
DocumentType createAndSetDocumentType (const String &qualifiedName, const String &publicId, const String &systemId)
 
Element getDocumentElement () noexcept
 
Attribute createAttribute (const String &name)
 
Attribute createAttributeNS (const String &namespaceURI, const String &qualifiedName)
 
Element createElement (const String &name)
 
Element createElementNS (const String &namespaceURI, const String &qualifiedName)
 
DocumentFragment createDocumentFragment ()
 
Text createText (const String &data)
 
Comment createComment (const String &data)
 
CDATASection createCDATASection (const String &data)
 
ProcessingInstruction createProcessingInstruction (const String &target, const String &data)
 
EntityReference createEntityReference (const String &name)
 
Element getElementById (const String &elementId)
 
Node selectSingleNode (const String &xpath, const PrefixNamespace &namespaces=PrefixNamespace())
 
Array< Node * > getXPath (const String &xpath, const PrefixNamespace &namespaces=PrefixNamespace())
 
Attribute createAttribute (const String &name, const String &value)
 
Node importNode (Node importedNode, bool deep)
 
void doXIncludeSubstitution ()
 
void save (const String &filename)
 
bool validate () const
 
bool validate (Node node) const
 
void destroy ()
 
- Public Member Functions inherited from Node
 Node () noexcept
 
 Node (const Node &copy) noexcept
 
Nodeoperator= (const Node &assign) noexcept
 
Node appendChild (Node child)
 
Node insertBefore (Node newChild, Node refChild)
 
Node removeChild (Node child)
 
Node replaceChild (Node newChild, Node oldChild)
 
Node cloneNode (bool deep)
 
String getLocalName () const noexcept
 
String getNamespaceURI () const noexcept
 
String getName () const
 
NodeType getType () const
 
String getValue () const
 
ShadowDocument getOwnerDocument () noexcept
 
String getPrefix () const
 
void setPrefix (const String &prefix)
 
Node getParent () const noexcept
 
Node getPreviousSibling () const noexcept
 
Node getNextSibling () const noexcept
 
Node getFirstChild () const
 
Node getLastChild () const
 
bool hasAttributes () const noexcept
 
bool hasChildNodes () const
 
bool isSupported (const String &feature, const String &version) const noexcept
 
void normalize ()
 
void setValue (const String &value)
 
bool isValid () const noexcept
 
bool isInvalid () const noexcept
 
bool isUnlinked () const noexcept
 
bool isSame (const Node &node) const noexcept
 
bool operator== (const Node &node) const noexcept
 
bool hasSameOwner (const Node &node) const noexcept
 
bool isAncestor (const Node &node) const noexcept
 
 operator bool () const noexcept
 
 ~Node () noexcept
 

Protected Member Functions

 Document (void *context) noexcept
 
- Protected Member Functions inherited from Node
 Node (void *_context) noexcept
 
void * getContext () noexcept
 
const void * getContext () const noexcept
 

Detailed Description

DOM document.

DOM document.

Version
1.0
Examples
testsuite/sax.cpp, testsuite/validate.cpp, and testsuite/xsltprocessor.cpp.

Member Typedef Documentation

◆ PrefixNamespace

Prefix and namespace pair.

Constructor & Destructor Documentation

◆ Document() [1/3]

Document::Document ( void *  context)
inlineprotectednoexcept

Internal constructor.

◆ Document() [2/3]

Document::Document ( )

Initializes the document as invalid.

◆ Document() [3/3]

Document::Document ( ShadowDocument  document)
inlinenoexcept

Initializes the document as invalid.

Member Function Documentation

◆ createAndSetDocumentType()

DocumentType Document::createAndSetDocumentType ( const String qualifiedName,
const String publicId,
const String systemId 
)

Creates and sets a document type object for this document.

Examples
testsuite/sax.cpp.

◆ createAttribute() [1/2]

Attribute Document::createAttribute ( const String name)

Creates an Attribute of the given name.

◆ createAttribute() [2/2]

Attribute Document::createAttribute ( const String name,
const String value 
)

Creates a new attribute.

◆ createAttributeNS()

Attribute Document::createAttributeNS ( const String namespaceURI,
const String qualifiedName 
)

Creates an Attribute of the given qualified name and namespace URI.

◆ createCDATASection()

CDATASection Document::createCDATASection ( const String data)

Creates a CDATASection node whose value is the specified string.

Examples
testsuite/sax.cpp.

◆ createComment()

Comment Document::createComment ( const String data)

Creates a Comment node given the specified string.

Examples
testsuite/sax.cpp.

◆ createDocumentFragment()

DocumentFragment Document::createDocumentFragment ( )

Creates an empty DocumentFragment node.

◆ createElement()

Element Document::createElement ( const String name)

Creates an element of the type specified.

Examples
testsuite/sax.cpp.

◆ createElementNS()

Element Document::createElementNS ( const String namespaceURI,
const String qualifiedName 
)

Creates an element of the given qualified name and namespace URI.

Examples
testsuite/sax.cpp.

◆ createEntityReference()

EntityReference Document::createEntityReference ( const String name)

Creates an EntityReference node.

◆ createProcessingInstruction()

ProcessingInstruction Document::createProcessingInstruction ( const String target,
const String data 
)

Creates a ProcessingInstruction node given the specified target and data strings.

Examples
testsuite/sax.cpp.

◆ createText()

Text Document::createText ( const String data)

Creates a Text node given the specified string.

◆ destroy()

void Document::destroy ( )

Destroys the document.

◆ doXIncludeSubstitution()

void Document::doXIncludeSubstitution ( )

Do XInclude substitution.

◆ getDocumentElement()

Element Document::getDocumentElement ( )
noexcept

This is a convenience attribute that allows direct access to the child node that is the root element of the document.

◆ getDocumentType()

DocumentType Document::getDocumentType ( )
noexcept

The Document Type Declaration associated with this document.

◆ getElementById()

Element Document::getElementById ( const String elementId)

Returns the Element whose ID is given by elementId.

◆ getImplementation()

DOMImplementation Document::getImplementation ( )
noexcept

The DOMImplementation object that handles this document.

◆ getXPath()

Array<Node*> Document::getXPath ( const String xpath,
const PrefixNamespace namespaces = PrefixNamespace() 
)

Returns the result for the given XPath expression.

◆ importNode()

Node Document::importNode ( Node  importedNode,
bool  deep 
)

Imports a node from another document to this document. The returned node has no parent. The source node is not altered or removed from the original document; this method creates a new copy of the source node.

◆ save()

void Document::save ( const String filename)

Save to document to the specified file.

Parameters
filenameThe name of the file.
Examples
testsuite/xsltprocessor.cpp.

◆ selectSingleNode()

Node Document::selectSingleNode ( const String xpath,
const PrefixNamespace namespaces = PrefixNamespace() 
)

Returns the first node for the given XPath expression.

◆ validate() [1/2]

bool Document::validate ( ) const

Returns true if the document is valid.

◆ validate() [2/2]

bool Document::validate ( Node  node) const

Returns true if the tree is valid.