29 #ifndef __X3DSAX2HANDLERS_H__
30 #define __X3DSAX2HANDLERS_H__
47 #include <xercesc/sax2/Attributes.hpp>
48 #include <xercesc/sax2/DefaultHandler.hpp>
49 #include <xercesc/sax/Locator.hpp>
50 #include <xercesc/sax2/XMLReaderFactory.hpp>
51 #include <xercesc/sax2/SAX2XMLReader.hpp>
53 XERCES_CPP_NAMESPACE_USE
82 PrototypeVector *_proto_declarations = NULL,
83 bool _called_from_proto_declaration =
false ):
107 if( !_exported_nodes ) {
110 if( !_proto_declarations ) {
126 void setDocumentLocator(
const Locator *
const _locator ) {
157 const XMLCh*
const localname,
158 const XMLCh*
const qname,
159 const Attributes& attrs);
186 const XMLCh *
const localname,
187 const XMLCh *
const qname);
192 void warning(
const SAXParseException& exc);
197 void error(
const SAXParseException& exc);
202 void fatalError(
const SAXParseException& exc);
214 const XMLCh*
const localname,
215 const XMLCh*
const qname,
216 const Attributes& attrs );
222 const XMLCh*
const localname,
223 const XMLCh*
const qname );
239 bool route_no_event =
false );
274 const string &_container_field =
"" ):
275 container_field( _container_field ),
277 have_connect_element( false ) {
278 if( node ) node->
ref();
284 container_field = ne.container_field;
286 if( node ) node->
ref();
287 have_connect_element = ne.have_connect_element;
292 if( node ) node->
unref();
321 return !cdata.empty();
331 return container_field;
336 return have_connect_element;
341 have_connect_element = b;
344 string container_field;
347 bool have_connect_element;
448 H3DAPI_API SAX2XMLReader* getNewXMLParser();
Contains the DEFNodes class.
Contains the Field class.
Base class for all scripting node interfaces.
Header file for ProtoDeclaration.
This file contains functions for creating H3D nodes from X3D input.
The Field class.
Definition: Field.h:46
Node is the base class for all classes that can be part of the H3D scene-graph.
Definition: Node.h:46
This abstract node type is the base type for all prototype instances in the X3D system.
Definition: X3DPrototypeInstance.h:65
Provides a mapping between defined DEF names in X3D and the nodes they refer to.
Definition: DEFNodes.h:92
Encapsulate a node with its XML containerField attribute.
Definition: X3DSAX2Handlers.h:270
bool haveConnectElement()
Returns true if the node have a connect element.
Definition: X3DSAX2Handlers.h:335
const string & getContainerField()
Get the container field value.
Definition: X3DSAX2Handlers.h:330
void setCDATA(const string &s)
Set CDATA associated with the node.
Definition: X3DSAX2Handlers.h:315
bool haveCDATA()
Returns true if there is any CDATA associated with the node.
Definition: X3DSAX2Handlers.h:320
Node * getNode()
Get the Node value.
Definition: X3DSAX2Handlers.h:305
NodeElement(Node *_node, const string &_container_field="")
Constructor.
Definition: X3DSAX2Handlers.h:273
void setConnectElement(const bool &b)
Set the have_connect_element variable.
Definition: X3DSAX2Handlers.h:340
~NodeElement()
Destructor.
Definition: X3DSAX2Handlers.h:291
NodeElement(const NodeElement &ne)
Copy constructor.
Definition: X3DSAX2Handlers.h:282
const string & getCDATA()
Get the CDATA associated with the node.
Definition: X3DSAX2Handlers.h:325
void setContainerField(const string &s)
Set the container field value.
Definition: X3DSAX2Handlers.h:310
void setNode(Node *n)
Set the Node value.
Definition: X3DSAX2Handlers.h:296
This class implements the SAX2 ContentHandler and ErrorHandler interface in order to build an H3D sce...
Definition: X3DSAX2Handlers.h:71
bool defining_extern_proto
true if we are inside an ExternProtoDeclare element.
Definition: X3DSAX2Handlers.h:389
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.
Definition: X3DSAX2Handlers.cpp:904
void handleFieldValueElement(const Attributes &attrs, Node *parent)
This function will be called if a fieldValue element has been found in a ProtoInstance element.
Definition: X3DSAX2Handlers.cpp:1085
Locator * locator
The locator object of the parser.
Definition: X3DSAX2Handlers.h:428
H3DInt32 defining_proto_body
true if we are inside a ProtoBody element.
Definition: X3DSAX2Handlers.h:380
AutoRefVector< H3DScriptNode > script_nodes
All instances of H3DScriptNode that has been instanced so far during parsing.
Definition: X3DSAX2Handlers.h:420
void startElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
Handler for the SAX ContentHandler interface.
Definition: X3DSAX2Handlers.cpp:1208
PrototypeVector * proto_declarations
The ProtoDeclarations that have been defined with ProtoDeclare elements.
Definition: X3DSAX2Handlers.h:416
void warning(const SAXParseException &exc)
Handler for the SAX ErrorHandler interface.
Definition: X3DSAX2Handlers.cpp:1724
bool delete_exported_map
If true the exported_nodes member will be deleted when the X3DSAX2handlers object is destructed.
Definition: X3DSAX2Handlers.h:401
DEFNodes * DEF_map
A structure containing a map between DEF names and nodes that are found during parsing.
Definition: X3DSAX2Handlers.h:409
void handleImportElement(const Attributes &attrs)
This function will be called if a IMPORT element has been found.
Definition: X3DSAX2Handlers.cpp:544
unsigned int proto_body_count
Counter used know when a proto body part has finished.
Definition: X3DSAX2Handlers.h:377
void characters(const XMLCh *const chars, const XMLSize_t length)
Handler for the SAX DocumentHandler interface.
Definition: X3DSAX2Handlers.cpp:1200
string cdata
The characters collected inside a CDATA construct.
Definition: X3DSAX2Handlers.h:445
void endCDATA()
Handler for the SAX LexicalHandler interface.
Definition: X3DSAX2Handlers.cpp:1181
bool defining_proto_interface
true if we are inside a ProtoInterface element.
Definition: X3DSAX2Handlers.h:383
bool delete_DEF_map
If true the DEF_map member will be deleted when the X3DSAX2handlers object is destructed.
Definition: X3DSAX2Handlers.h:397
void handleExternProtoDeclareElement(const Attributes &attrs)
This function will be called if a ExternProtoDeclare element has been found.
Definition: X3DSAX2Handlers.cpp:993
void handleProtoInterfaceFieldElement(const Attributes &attrs)
This function is called when a field element has been found in a ProtoInterface element.
Definition: X3DSAX2Handlers.cpp:157
X3DSAX2Handlers(DEFNodes *dn=NULL, DEFNodes *_exported_nodes=NULL, PrototypeVector *_proto_declarations=NULL, bool _called_from_proto_declaration=false)
Constructor.
Definition: X3DSAX2Handlers.h:80
void handleConnectElement(const Attributes &attrs, Node *parent)
This function will be called if a connect element has been found in an IS element.
Definition: X3DSAX2Handlers.cpp:673
bool inside_cdata
Set to true while parser is parsing characters inside a CDATA construct.
Definition: X3DSAX2Handlers.h:440
virtual void endDocument()
Handler for the SAX ContentHandler interface.
Definition: X3DSAX2Handlers.cpp:1730
const AutoRef< Node > & getResultingNode()
Get the node that has been generated by the last parsing.
Definition: X3DSAX2Handlers.h:133
void handleProgramSettingElement(const Attributes &attrs)
This function will be called if a PROGRAM_SETTING element has been found.
Definition: X3DSAX2Handlers.cpp:477
bool called_from_proto_declaration
If true then this handler is created in proto_declaration so a ProtoDeclare element is allowed at top...
Definition: X3DSAX2Handlers.h:367
NodeElementStack node_stack
A stack of nodes that have been created while traversing the XML structure.
Definition: X3DSAX2Handlers.h:393
string proto_body
The string_body string is used when defining ProtoBody.
Definition: X3DSAX2Handlers.h:371
void endElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
Handler for the SAX ContentHandler interface.
Definition: X3DSAX2Handlers.cpp:1586
void fatalError(const SAXParseException &exc)
Handler for the SAX ErrorHandler interface.
Definition: X3DSAX2Handlers.cpp:1713
X3DPrototypeInstance * handleProtoInstanceElement(const Attributes &attrs)
This function will be called if a ProtoInstance element has been found.
Definition: X3DSAX2Handlers.cpp:969
bool delete_proto_declarations
If true the proto_declarations member will be deleted when the X3DSAX2handlers object is destructed.
Definition: X3DSAX2Handlers.h:405
void handleExportElement(const Attributes &attrs)
This function will be called if a EXPORT element has been found.
Definition: X3DSAX2Handlers.cpp:629
bool defining_proto_connections
true if we are inside an IS element.
Definition: X3DSAX2Handlers.h:386
bool meta_set
Set after a META is set.
Definition: X3DSAX2Handlers.h:435
~X3DSAX2Handlers()
Destructor.
Definition: X3DSAX2Handlers.h:116
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...
Definition: X3DSAX2Handlers.cpp:247
AutoRef< Node > resulting_node
The Node that is created during parsing.
Definition: X3DSAX2Handlers.h:423
DEFNodes * exported_nodes
A list of DEFNodes that contain the nodes that have been exported using the EXPORT statement.
Definition: X3DSAX2Handlers.h:413
string getLocationString()
Returns a string with the current location as given by the current Locator object.
Definition: X3DSAX2Handlers.cpp:150
bool profile_set
Set after a profile is found (either in the X3D tag or in a PROFILE statement)
Definition: X3DSAX2Handlers.h:432
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 i...
Definition: X3DSAX2Handlers.cpp:786
void error(const SAXParseException &exc)
Handler for the SAX ErrorHandler interface.
Definition: X3DSAX2Handlers.cpp:1704
AutoRef< ProtoDeclaration > proto_declaration
Will be set when a ProtoDeclare element is found and it is will be used in protoStartElement and prot...
Definition: X3DSAX2Handlers.h:363
virtual void startDocument()
Handler for the SAX ContentHandler interface.
Definition: X3DSAX2Handlers.h:139
void startCDATA()
Handler for the SAX LexicalHandler interface.
Definition: X3DSAX2Handlers.cpp:1171
std::stack< NodeElement > NodeElementStack
A stack of NodeElements.
Definition: X3DSAX2Handlers.h:357
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.
Definition: X3DSAX2Handlers.cpp:384
X3DPrototypeInstance * proto_instance
If this is set to non-NULL then the parser is used to create an X3DPrototypeInstance.
Definition: X3DSAX2Handlers.h:206
An exception for errors occuring while parsing an X3D XML file.
Definition: X3DSAX2Handlers.h:64
H3D_API_EXCEPTION(Vec2dNormalizeError)
H3D API namespace.
Definition: Anchor.h:38