30 static ossimTrace traceDebug(
"ossimXmlDocument:debug");
36 (( (c ==
' ') || (c ==
'\t') || (c ==
'\n')|| (c ==
'\r') || (c<0x20) || (c>=0x7f) )))
45 static const int BUFFER_MAX_LEN = 1000;
52 theXmlHeader("<?xml version='1.0'?>"),
53 theStrictCheckFlag(false)
57 openFile(xmlFileName);
64 theXmlHeader(src.theXmlHeader),
65 theFilename(src.theFilename),
66 theStrictCheckFlag(src.theStrictCheckFlag)
81 out << *
this << std::endl;
111 <<
"DEBUG: ossimXmlDocument::ossimXmlDocument\n" 112 <<
"encountered opening file <" << filename <<
"> for " 113 <<
"reading. Aborting..." << endl;
118 return read(xml_stream);
126 bool startTagCharacterFound =
false;
130 while(!in.bad() && (c !=
'<') && (c >= 0x20) && (c <= 0x7e))
136 if (in.bad() || (c!=
'<'))
141 startTagCharacterFound =
true;
147 if(startTagCharacterFound)
158 <<
"FATAL: ossimXmlDocument::ossimXmlDocument" 160 <<
">. The file does not appear to be XML v1.0. \n" 183 <<
"WARNING: ossimXmlDocument::findNodes,\n" 184 <<
"No root node has been instantiated. Returning null " 185 <<
"node list..." << endl;
200 if (xpath[static_cast<std::string::size_type>(0)] !=
201 XPATH_DELIM[
static_cast<std::string::size_type
>(0)])
206 <<
"WARNING: ossimXmlDocument::findNodes\n" 207 <<
"Only absolute XPaths are supported. Returning null " 208 <<
"node list..." << endl;
218 if (root_tag.contains(XPATH_DELIM))
219 root_tag = rel_xpath.before(XPATH_DELIM);
226 <<
"WARNING: ossimXmlDocument::findNodes\n" 227 <<
"XPath's root node <"<<root_tag<<
"> does not match the " 229 <<
"Returning null node list..." << endl;
237 rel_xpath = rel_xpath.
after(XPATH_DELIM);
238 if (rel_xpath.empty())
298 ossimKeywordlist::KeywordMap::iterator mapIter = map.begin();
300 while(mapIter != map.end())
310 std::stack<ossimRefPtr<ossimXmlNode> > tempStack;
312 while(!tempStack.empty())
317 vector<ossimRefPtr<ossimXmlNode> >& childNodes = node->
getChildNodes();
319 for(idx = 0; idx < childNodes.size(); ++idx)
321 tempStack.push(childNodes[idx]);
332 if(node->
getTag() ==
"type")
387 while(in.peek() ==
'<')
389 std::stack<char> theLessThanStack;
390 theLessThanStack.push(
'<');
400 while(!theLessThanStack.empty()&&
405 theLessThanStack.push(
'<');
407 else if(in.peek() ==
'>')
409 theLessThanStack.pop();
void clear()
Erases the entire container.
void setTag(const ossimString &tag)
ossimString substitute(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false) const
Substitutes searchKey string with replacementValue and returns a string.
ostream & operator<<(ostream &os, const ossimXmlDocument &xml_doc)
void setText(const ossimString &text)
void findChildNodes(const ossimString &rel_xpath, ossimXmlNode::ChildListType &nodelist) const
Represents serializable keyword/value map.
bool write(const ossimFilename &file)
static const ossimErrorCode OSSIM_OK
std::basic_ifstream< char > ifstream
Class for char input file streams.
const ossimXmlNode::ChildListType & getChildNodes() const
ossimString const & getTag() const
bool contains(char aChar) const
ossimRefPtr< ossimXmlNode > addNode(const ossimString &relPath, const ossimString &text="")
void toKwl(ossimKeywordlist &kwl, const ossimString &prefix="") const
ossimRefPtr< ossimXmlNode > removeChild(ossimRefPtr< ossimXmlNode > node)
void push_back(char c)
Equivalent to insert(end(), c).
const ossimString & getText() const
bool openFile(const ossimFilename &filename)
void fromKwl(const ossimKeywordlist &kwl)
std::map< std::string, std::string > KeywordMap
const ossimXmlNode * getParentNode() const
virtual ~ossimXmlDocument()
ossimRefPtr< ossimXmlNode > removeRoot()
ossimFilename theFilename
unsigned int ossim_uint32
ossimRefPtr< ossimXmlNode > theRootNode
std::basic_istream< char > istream
Base class for char input streams.
const ossimKeywordlist::KeywordMap & getMap() const
bool readHeader(std::istream &in)
virtual ossimErrorCode getErrorStatus() const
ossimXmlDocument(const ossimFilename &xmlFileName="")
virtual void setErrorStatus() const
void toKwl(ossimKeywordlist &kwl, const ossimString &prefix="") const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
bool read(std::istream &in)
void addAttribute(ossimRefPtr< ossimXmlAttribute > attribute)
std::basic_ofstream< char > ofstream
Class for char output file streams.
void findNodes(const ossimString &xpath, std::vector< ossimRefPtr< ossimXmlNode > > &nodelist) const
Appends any matching nodes to the list supplied (should be empty):
#define RTTI_DEF1(cls, name, b1)
ossimRefPtr< ossimXmlNode > getRoot()
ossimString after(const ossimString &str, std::string::size_type pos=0) const
METHOD: after(str, pos) Returns string immediately after the token str.
void initRoot(ossimRefPtr< ossimXmlNode > node)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.