Commit 75bd351e authored by Dave Demarle's avatar Dave Demarle

BUG: Make the character data handling in XML files optional. It is off for vtk...

BUG: Make the character data handling in XML files optional. It is off for vtk xml file formats, but it can be turned on, as is the case for the LANL Cosmo SVG reader, when it is needed.
parent ec9c6321
......@@ -22,7 +22,7 @@
#include "vtkObjectFactory.h"
#include "vtkXMLDataElement.h"
vtkCxxRevisionMacro(vtkXMLDataParser, "1.33");
vtkCxxRevisionMacro(vtkXMLDataParser, "1.34");
vtkStandardNewMacro(vtkXMLDataParser);
vtkCxxSetObjectMacro(vtkXMLDataParser, Compressor, vtkDataCompressor);
......@@ -58,6 +58,9 @@ vtkXMLDataParser::vtkXMLDataParser()
#endif
this->AttributesEncoding = VTK_ENCODING_NONE;
//change default because vtk file formats store this information elsewhere
this->IgnoreCharacterData = 1;
}
//----------------------------------------------------------------------------
......@@ -1062,7 +1065,7 @@ void vtkXMLDataParser::UpdateProgress(float progress)
//----------------------------------------------------------------------------
void vtkXMLDataParser::CharacterDataHandler(
const char* data, int length )
{
{
unsigned int numOpen = this->NumberOfOpenElements;
if(numOpen > 0)
{
......
......@@ -129,7 +129,11 @@ public:
vtkSetClampMacro(AttributesEncoding,int,VTK_ENCODING_NONE,VTK_ENCODING_UNKNOWN);
vtkGetMacro(AttributesEncoding, int);
// Called when there is character data to handle.
// Description:
// If you need the text inside XMLElements, turn IgnoreCharacterData off.
// This method will then be called when the file is parsed, and the text
// will be stored in each XMLDataElement. VTK XML Readers store the
// information elsewhere, so the default is to ignore it.
virtual void CharacterDataHandler(const char* data, int length);
protected:
......
......@@ -33,7 +33,7 @@
#include <ctype.h>
#include <sys/stat.h>
vtkCxxRevisionMacro(vtkXMLParser, "1.26");
vtkCxxRevisionMacro(vtkXMLParser, "1.27");
vtkStandardNewMacro(vtkXMLParser);
//----------------------------------------------------------------------------
......@@ -45,6 +45,7 @@ vtkXMLParser::vtkXMLParser()
this->InputString = 0;
this->InputStringLength = 0;
this->ParseError = 0;
this->IgnoreCharacterData = 0;
}
//----------------------------------------------------------------------------
......@@ -68,6 +69,9 @@ void vtkXMLParser::PrintSelf(ostream& os, vtkIndent indent)
}
os << indent << "FileName: " << (this->FileName? this->FileName : "(none)")
<< "\n";
os << indent << "IgnoreCharacterData: "
<< (this->IgnoreCharacterData?"On":"Off")
<< endl;
}
//----------------------------------------------------------------------------
......@@ -229,8 +233,15 @@ int vtkXMLParser::Parse()
XML_SetElementHandler(static_cast<XML_Parser>(this->Parser),
&vtkXMLParserStartElement,
&vtkXMLParserEndElement);
XML_SetCharacterDataHandler(static_cast<XML_Parser>(this->Parser),
&vtkXMLParserCharacterDataHandler);
if (!this->IgnoreCharacterData)
{
XML_SetCharacterDataHandler(static_cast<XML_Parser>(this->Parser),
&vtkXMLParserCharacterDataHandler);
}
else
{
XML_SetCharacterDataHandler(static_cast<XML_Parser>(this->Parser), NULL);
}
XML_SetUserData(static_cast<XML_Parser>(this->Parser), this);
// Parse the input.
......@@ -273,8 +284,15 @@ int vtkXMLParser::InitializeParser()
XML_SetElementHandler(static_cast<XML_Parser>(this->Parser),
&vtkXMLParserStartElement,
&vtkXMLParserEndElement);
XML_SetCharacterDataHandler(static_cast<XML_Parser>(this->Parser),
&vtkXMLParserCharacterDataHandler);
if (!this->IgnoreCharacterData)
{
XML_SetCharacterDataHandler(static_cast<XML_Parser>(this->Parser),
&vtkXMLParserCharacterDataHandler);
}
else
{
XML_SetCharacterDataHandler(static_cast<XML_Parser>(this->Parser), NULL);
}
XML_SetUserData(static_cast<XML_Parser>(this->Parser), this);
this->ParseError = 0;
return 1;
......
......@@ -81,6 +81,13 @@ public:
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
// Description:
// If this is off (the default), CharacterDataHandler will be called to
// process text within XML Elements. If this is on, the text will be
// ignored.
vtkSetMacro(IgnoreCharacterData, int);
vtkGetMacro(IgnoreCharacterData, int);
protected:
vtkXMLParser();
~vtkXMLParser();
......@@ -162,6 +169,8 @@ protected:
friend void vtkXMLParserCharacterDataHandler(void*, const char*, int);
//ETX
int IgnoreCharacterData;
private:
vtkXMLParser(const vtkXMLParser&); // Not implemented.
void operator=(const vtkXMLParser&); // Not implemented.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment