H3D API
2.4.1
|
This class implements the SAX2 ContentHandler and ErrorHandler interface in order to build an H3D scenegraph from a X3D XML file. More...
#include <H3D/X3DSAX2Handlers.h>
Inherits DefaultHandler.
Classes | |
class | NodeElement |
Encapsulate a node with its XML containerField attribute. More... | |
Public Member Functions | |
X3DSAX2Handlers (DEFNodes *dn=NULL, DEFNodes *_exported_nodes=NULL, PrototypeVector *_proto_declarations=NULL, bool _called_from_proto_declaration=false) | |
Constructor. More... | |
~X3DSAX2Handlers () | |
Destructor. | |
const AutoRef< Node > & | getResultingNode () |
Get the node that has been generated by the last parsing. More... | |
virtual void | startDocument () |
Handler for the SAX ContentHandler interface. More... | |
virtual void | endDocument () |
Handler for the SAX ContentHandler interface. More... | |
void | startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs) |
Handler for the SAX ContentHandler interface. More... | |
void | startCDATA () |
Handler for the SAX LexicalHandler interface. More... | |
void | endCDATA () |
Handler for the SAX LexicalHandler interface. More... | |
void | characters (const XMLCh *const chars, const XMLSize_t length) |
Handler for the SAX DocumentHandler interface. More... | |
void | endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname) |
Handler for the SAX ContentHandler interface. More... | |
void | warning (const SAXParseException &exc) |
Handler for the SAX ErrorHandler interface. More... | |
void | error (const SAXParseException &exc) |
Handler for the SAX ErrorHandler interface. More... | |
void | fatalError (const SAXParseException &exc) |
Handler for the SAX ErrorHandler interface. More... | |
Public Attributes | |
X3DPrototypeInstance * | proto_instance |
If this is set to non-NULL then the parser is used to create an X3DPrototypeInstance. More... | |
Protected Types | |
typedef std::stack< NodeElement > | NodeElementStack |
A stack of NodeElements. More... | |
Protected Member Functions | |
void | protoStartElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs) |
This function will be called by startElement if the element is a ProtoDeclare element or a child of it. More... | |
void | protoEndElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname) |
This function will be called by endElement if the element is a ProtoDeclare element or a child of it. More... | |
void | handleProtoInterfaceFieldElement (const Attributes &attrs) |
This function is called when a field element has been found in a ProtoInterface element. More... | |
void | handleConnectElement (const Attributes &attrs, Node *parent) |
This function will be called if a connect element has been found in an IS element. More... | |
void | handleRouteElement (const Attributes &attrs, bool route_no_event=false) |
This function will be called if a ROUTE, ROUTE_NO_EVENT or ROUTE_WITH_EVENT element has been found. | |
void | handleProgramSettingElement (const Attributes &attrs) |
This function will be called if a PROGRAM_SETTING element has been found. | |
Field * | handleFieldElement (const Attributes &attrs, Node *parent) |
This function will be called if a "field" element has been found that is not part of a ProtoInterface element. More... | |
void | handleImportElement (const Attributes &attrs) |
This function will be called if a IMPORT element has been found. | |
void | handleExportElement (const Attributes &attrs) |
This function will be called if a EXPORT element has been found. | |
X3DPrototypeInstance * | handleProtoInstanceElement (const Attributes &attrs) |
This function will be called if a ProtoInstance element has been found. More... | |
void | handleFieldValueElement (const Attributes &attrs, Node *parent) |
This function will be called if a fieldValue element has been found in a ProtoInstance element. | |
void | handleExternProtoDeclareElement (const Attributes &attrs) |
This function will be called if a ExternProtoDeclare element has been found. | |
string | getLocationString () |
Returns a string with the current location as given by the current Locator object. More... | |
Protected Attributes | |
AutoRef< ProtoDeclaration > | proto_declaration |
Will be set when a ProtoDeclare element is found and it is will be used in protoStartElement and protoEndElement to define a prototype. More... | |
bool | called_from_proto_declaration |
If true then this handler is created in proto_declaration so a ProtoDeclare element is allowed at top level. | |
string | proto_body |
The string_body string is used when defining ProtoBody. More... | |
unsigned int | proto_body_count |
Counter used know when a proto body part has finished. More... | |
H3DInt32 | defining_proto_body |
true if we are inside a ProtoBody element. | |
bool | defining_proto_interface |
true if we are inside a ProtoInterface element. | |
bool | defining_proto_connections |
true if we are inside an IS element. | |
bool | defining_extern_proto |
true if we are inside an ExternProtoDeclare element. | |
NodeElementStack | node_stack |
A stack of nodes that have been created while traversing the XML structure. | |
bool | delete_DEF_map |
If true the DEF_map member will be deleted when the X3DSAX2handlers object is destructed. | |
bool | delete_exported_map |
If true the exported_nodes member will be deleted when the X3DSAX2handlers object is destructed. | |
bool | delete_proto_declarations |
If true the proto_declarations member will be deleted when the X3DSAX2handlers object is destructed. | |
DEFNodes * | DEF_map |
A structure containing a map between DEF names and nodes that are found during parsing. | |
DEFNodes * | exported_nodes |
A list of DEFNodes that contain the nodes that have been exported using the EXPORT statement. | |
PrototypeVector * | proto_declarations |
The ProtoDeclarations that have been defined with ProtoDeclare elements. | |
AutoRefVector< H3DScriptNode > | script_nodes |
All instances of H3DScriptNode that has been instanced so far during parsing. | |
AutoRef< Node > | resulting_node |
The Node that is created during parsing. | |
Locator * | locator |
The locator object of the parser. More... | |
bool | profile_set |
Set after a profile is found (either in the X3D tag or in a PROFILE statement) | |
bool | meta_set |
Set after a META is set. | |
bool | inside_cdata |
Set to true while parser is parsing characters inside a CDATA construct. | |
string | cdata |
The characters collected inside a CDATA construct. More... | |
This class implements the SAX2 ContentHandler and ErrorHandler interface in order to build an H3D scenegraph from a X3D XML file.
|
protected |
A stack of NodeElements.
Used during parsing to keep track of the created Nodes.
|
inline |
Constructor.
dn | A structure to store the mapping between DEF names and the nodes the reference |
_exported_nodes | A structure to store the exported nodes. |
_proto_declarations | Storage of all proto declarations. |
_called_from_proto_declaration | True if instance is created by ProtoDeclaration class. |
References DEF_map, exported_nodes, and proto_declarations.
void X3DSAX2Handlers::characters | ( | const XMLCh *const | chars, |
const XMLSize_t | length | ||
) |
Handler for the SAX DocumentHandler interface.
if( length > 0 )
Receive notification of character data inside an element.
References length().
void X3DSAX2Handlers::endCDATA | ( | ) |
Handler for the SAX LexicalHandler interface.
Called on start of CDATA.
References H3D::X3D::X3DSAX2Handlers::NodeElement::setCDATA().
|
virtual |
Handler for the SAX ContentHandler interface.
Is called at end of parsing and updates all script nodes named nodes.
void X3DSAX2Handlers::endElement | ( | const XMLCh *const | uri, |
const XMLCh *const | localname, | ||
const XMLCh *const | qname | ||
) |
Handler for the SAX ContentHandler interface.
Builds the H3D scene graph.
uri | the URI of the associated namespace for this element |
localname | the local part of the element name |
qname | the QName of this element |
X3D::XMLParseError |
void X3DSAX2Handlers::error | ( | const SAXParseException & | exc | ) |
Handler for the SAX ErrorHandler interface.
Throws an X3D::XMLParseError exception with the error information.
X3D::XMLParseError |
void X3DSAX2Handlers::fatalError | ( | const SAXParseException & | exc | ) |
Handler for the SAX ErrorHandler interface.
Throws an XMLParseError exception with the error information.
X3D::XMLParseError |
|
protected |
Returns a string with the current location as given by the current Locator object.
system id and line number is included. Only valid during event callbacks.
Get the node that has been generated by the last parsing.
Only valid after a successful call to the parse() function of a SAX2 Parser with class as a ContentHandler.
References resulting_node.
|
protected |
This function will be called if a connect element has been found in an IS element.
The attrs argument are the attributes of the ProtoInterface element and the parent argument is the node of the element that it lies within.
References H3D::X3D::X3DSAX2Handlers::NodeElement::haveConnectElement(), and H3D::X3D::X3DSAX2Handlers::NodeElement::setConnectElement().
This function will be called if a "field" element has been found that is not part of a ProtoInterface element.
If successful it returns a new Field with the specified attributes, if not NULL is returned.
|
protected |
This function will be called if a ProtoInstance element has been found.
It returns an X3DPrototypeInstance of the specified prototype if it exists, otherwise NULL.
|
protected |
This function is called when a field element has been found in a ProtoInterface element.
The attrs argument are the attributes of the field element.
|
protected |
This function will be called by endElement if the element is a ProtoDeclare element or a child of it.
It replaces the normal functionallity of startElement
References H3DUtil::AutoRef< class >::get().
|
protected |
This function will be called by startElement if the element is a ProtoDeclare element or a child of it.
It replaces the normal functionallity of startElement and creates a ProtoDeclaration instead.
void X3DSAX2Handlers::startCDATA | ( | ) |
Handler for the SAX LexicalHandler interface.
Handler for the SAX LexicalHandler interface. Called on start of CDATA.
|
inlinevirtual |
Handler for the SAX ContentHandler interface.
Resets the node member to NULL
References resulting_node.
void X3DSAX2Handlers::startElement | ( | const XMLCh *const | uri, |
const XMLCh *const | localname, | ||
const XMLCh *const | qname, | ||
const Attributes & | attrs | ||
) |
Handler for the SAX ContentHandler interface.
Builds the H3D scene graph.
uri | the URI of the associated namespace for this element |
localname | the local part of the element name |
qname | the QName of this element |
attrs | the specified or defaulted attributes. |
X3D::XMLParseError |
void X3DSAX2Handlers::warning | ( | const SAXParseException & | exc | ) |
Handler for the SAX ErrorHandler interface.
Prints a warning message to the Console.
|
protected |
The characters collected inside a CDATA construct.
Set in the characters function when inside_cdata is true. Reset in endCDATA fucntion.
|
protected |
The locator object of the parser.
Can be used to retrieve the location of any document handler event in the XML source document.
|
protected |
The string_body string is used when defining ProtoBody.
All elements will then just be translated to a string to be used by the ProtoDeclaration.
|
protected |
Counter used know when a proto body part has finished.
Will be incremented on each start of element end decremented on end. This means each time it reaches 0 a body element is finished.
|
protected |
Will be set when a ProtoDeclare element is found and it is will be used in protoStartElement and protoEndElement to define a prototype.
On end of ProtoDeclare it will be added to proto_declarations and proto_declaration will be set to NULL again;
X3DPrototypeInstance* H3D::X3D::X3DSAX2Handlers::proto_instance |
If this is set to non-NULL then the parser is used to create an X3DPrototypeInstance.
This allows the IS and connect elements to be used.