Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
NodeFactory Class Reference

#include <elm/xom/NodeFactory.h>

Public Member Functions

virtual ~NodeFactory (void)
 
virtual DocumentstartMakingDocument (void)
 
virtual ElementstartMakingElement (void)
 
virtual Nodes makeAttribute (void)
 
virtual Nodes makeComment (void)
 
virtual Nodes makeDocType (String rootElementName, String publicID, String systemID)
 
virtual Nodes makeProcessingInstruction (void)
 
virtual ElementmakeRootElement (void)
 
virtual Nodes makeText (void)
 
virtual Nodes finishMakingElement (Element *element)
 
virtual void finishMakingDocument (Document *document)
 
virtual AttributemakeAttribute (void *node)
 
virtual CommentmakeComment (void *node)
 
virtual DocumentmakeDocument (void *node)
 
virtual ProcessingInstruction * makeProcessingInstruction (void *node)
 
virtual ElementmakeElement (void *node)
 
virtual TextmakeText (void *node)
 

Static Public Attributes

static NodeFactory default_factory
 

Detailed Description

Used for building nodes during a load. Builders use a NodeFactory object to construct each Node object (Element, Text, Attribute, etc.) they add to the tree. The default implementation simply calls the relevant constructor, stuffs the resulting Node object in a length one Nodes object, and returns it.

Subclassing this class allows builders to produce instance of subclasses (for example, HTMLElement) instead of the base classes.

Subclasses can also filter content while building. For example, namespaces could be added to or changed on all elements. Comments could be deleted. Processing instructions can be changed into elements. An xinclude:include element could be replaced with the content it references. All such changes must be consistent with the usual rules of well-formedness. For example, the makeDocType() method should not return a list containing two DocType objects because an XML document can have at most one document type declaration. Nor should it return a list containing an element, because an element cannot appear in a document prolog. However, it could return a list containing any number of comments and processing instructions, and not more than one DocType object.

Constructor & Destructor Documentation

◆ ~NodeFactory()

~NodeFactory ( void  )
virtual

Member Function Documentation

◆ finishMakingDocument()

void finishMakingDocument ( Document document)
virtual

Signals the end of a document. The default implementation of this method does nothing. The builder does not call this method if an exception is thrown while building a document.

Parameters
documentthe completed Document

Referenced by XSLTransform::toDocument().

◆ finishMakingElement()

Nodes finishMakingElement ( Element element)
virtual

◆ makeAttribute() [1/2]

Attribute * makeAttribute ( void node)
virtual

Build an attribute from an XML node.

Parameters
nodeXML node.
Returns
Built attribute.

◆ makeAttribute() [2/2]

Nodes makeAttribute ( void  )
virtual

◆ makeComment() [1/2]

Comment * makeComment ( void node)
virtual

Build a comment from an XML node.

Parameters
nodeXML node.
Returns
Built comment.

◆ makeComment() [2/2]

Nodes makeComment ( void  )
virtual

Referenced by Node::make().

◆ makeDocType()

Nodes makeDocType ( xom::String  rootElementName,
xom::String  publicID,
xom::String  systemID 
)
virtual

◆ makeDocument()

Document * makeDocument ( void node)
virtual

Build a document from an input stream.

Parameters
nodeNode used by the parser.

Referenced by Builder::build(), and XSLTransform::transformDocument().

◆ makeElement()

Element * makeElement ( void node)
virtual

Build an element from its low-level reference.

Parameters
nodeLow-level node reference.

Referenced by Node::make().

◆ makeProcessingInstruction() [1/2]

ProcessingInstruction * makeProcessingInstruction ( void node)
virtual

Build a comment from an XML node.

Parameters
nodeXML node.
Returns
Built comment.

◆ makeProcessingInstruction() [2/2]

Nodes makeProcessingInstruction ( void  )
virtual

◆ makeRootElement()

Element * makeRootElement ( void  )
virtual

◆ makeText() [1/2]

Text * makeText ( void node)
virtual

Build a text from its low-level node reference.

Parameters
nodeLow-level node reference.

◆ makeText() [2/2]

Nodes makeText ( void  )
virtual

Referenced by Node::make().

◆ startMakingDocument()

Document * startMakingDocument ( void  )
virtual

Creates a new Document object. The root element of this document is initially set to <root xmlns="http://www.xom.nu/fakeRoot">. This is only temporary. As soon as the real root element's start-tag is read, this element is replaced by the real root. This fake root should never be exposed.

The builder calls this method at the beginning of each document, before it calls any other method in this class. Thus this is a useful place to perform per-document initialization tasks.

Subclasses may change the root element, content, or other characteristics of the document returned. However, this method must not return null or the builder will throw a ParsingException.

Returns
the newly created Document

Referenced by XSLTransform::toDocument().

◆ startMakingElement()

Element * startMakingElement ( void  )
virtual

Member Data Documentation

◆ default_factory

NodeFactory default_factory
static

Default node factory.


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