23 const char XPATH_DELIM (
'/');
36 (( (c==
' ') || (c ==
'\t') || (c ==
'\n')|| (c ==
'\r') || (c<0x20) || (c>=0x7f) ))
48 theParentNode (parent),
64 theCDataFlag(src.theCDataFlag)
131 <<
"ossimXmlNode::read: entered ......\n";
140 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
153 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
165 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
182 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
192 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
199 while(attribute->
read(in))
215 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
225 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
239 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
253 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
266 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
279 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
289 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
305 if(childNode->
read(in))
315 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
328 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
341 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
351 <<
"ossimXmlNode::read: leaving ......\n"<<__LINE__ <<
"\n";
356 }
while( !in.fail() );
361 <<
"ossimXmlNode::read: leaving ......\n";
382 if (xpath[static_cast<std::string::size_type>(0)] == XPATH_DELIM)
387 <<
"WARNING: ossimXmlNode::findChildNodes\n" 388 <<
"Only relative XPaths can be searched from a node. " 389 <<
"Returning null list...\n";
397 const std::string::size_type delim_pos = xpath.
find(XPATH_DELIM);
404 ossimXmlNode::ChildListType::const_iterator child_iter =
theChildNodes.begin();
405 ossimXmlNode::ChildListType::const_iterator child_end =
theChildNodes.end();
409 if (delim_pos==std::string::npos || delim_pos == xpath.
size()-1)
411 for ( ; child_iter != child_end ; ++ child_iter)
413 if ((*child_iter)->getTag() == desired_tag)
417 result.push_back(*child_iter);
423 for ( ; child_iter != child_end ; ++ child_iter)
425 if ((*child_iter)->getTag() == desired_tag)
431 (*child_iter)->findChildNodes(sub_xpath, result);
445 if (xpath[static_cast<std::string::size_type>(0)] == XPATH_DELIM)
450 <<
"WARNING: ossimXmlNode::findFirstNode\n" 451 <<
"Only relative XPaths can be searched from a node. " 452 <<
"Returning null list...\n";
460 const std::string::size_type delim_pos = xpath.
find(XPATH_DELIM);
467 ossimXmlNode::ChildListType::const_iterator child_iter =
theChildNodes.begin();
468 ossimXmlNode::ChildListType::const_iterator child_end =
theChildNodes.end();
471 if (delim_pos==std::string::npos || delim_pos == xpath.
size()-1)
473 for ( ; child_iter != child_end ; ++ child_iter)
475 if ((*child_iter)->getTag() == desired_tag)
482 for ( ; child_iter != child_end ; ++ child_iter)
484 if ((*child_iter)->getTag() == desired_tag)
512 if (xpath[static_cast<std::string::size_type>(0)] == XPATH_DELIM)
517 <<
"WARNING: ossimXmlNode::findFirstNode\n" 518 <<
"Only relative XPaths can be searched from a node. " 519 <<
"Returning null list...\n";
527 const std::string::size_type delim_pos = xpath.
find(XPATH_DELIM);
536 ossimXmlNode::ChildListType::iterator child_iter =
theChildNodes.begin();
537 ossimXmlNode::ChildListType::iterator child_end =
theChildNodes.end();
540 if (delim_pos==std::string::npos || delim_pos == xpath.
size()-1)
542 for ( ; child_iter != child_end ; ++ child_iter)
544 if ((*child_iter)->getTag() == desired_tag)
551 for ( ; child_iter != child_end ; ++ child_iter)
553 if ((*child_iter)->getTag() == desired_tag)
636 if(attribute.
valid())
641 return attribute.
valid();
696 os <<
"\n" << indent <<
"<" << xml_node->
theTag;
703 ossimXmlNode::AttributeListType::const_iterator attr =
723 os <<
"<![CDATA[" <<xml_node->
theText <<
"]]>";
737 ossimXmlNode::ChildListType::const_iterator nodes = xml_node->
theChildNodes.begin();
740 os << (*nodes).get();
743 os <<
"\n" << indent;
749 os <<
"</" << xml_node->
theTag <<
">";
768 bool addIfNotPresentFlag)
772 if(attribute.
valid())
779 if(addIfNotPresentFlag)
798 if (relPath[static_cast<std::string::size_type>(0)] == XPATH_DELIM)
803 <<
"Only relative XPaths can be searched from a node. " 804 <<
"Returning null list...\n";
812 const std::string::size_type delim_pos = relPath.
find(XPATH_DELIM);
820 if (delim_pos==std::string::npos || delim_pos == relPath.
size()-1)
829 if (delim_pos != std::string::npos && delim_pos != relPath.
size()-1)
832 return node->
addNode(subPath, text);
872 ossimXmlNode::ChildListType::iterator iter =
theChildNodes.begin();
876 if(node == iter->get())
892 ossimXmlNode::ChildListType::iterator iter =
theChildNodes.begin();
895 if(tag == iter->get()->theTag)
911 for(idx = 0; idx < children.size(); ++idx)
927 for(idx = 0; idx < children.size(); ++idx)
968 copyPrefix += (name+
".");
979 for(attributeIdx = 0; attributeIdx <
theAttributes.size(); ++attributeIdx)
1000 <<
"ossimXmlNode::readTag: entered ......\n";
1033 <<
"ossimXmlNode::readTag: leaving ......\n";
1036 return (!tag.
empty())&&(!in.fail());
1044 <<
"ossimXmlNode::readCDataContent: entered ...\n";
1049 bool result =
false;
1080 <<
"\nexit status: " << (result?
"true":
"false")
1081 <<
"\nossimXmlNode::readCDataContent: leaving ...\n";
1098 std::streampos initialPos = in.tellg();
1103 if(ostrBuf ==
"<![CDATA[")
1115 else if(ostrBuf.substr(0,4) ==
"<!--")
1117 in.seekg(initialPos);
1137 else if(ostrBuf.substr(0,1) ==
"<")
1139 in.seekg(initialPos);
1143 in.seekg(initialPos);
1145 while(!in.fail() && c !=
'<')
1182 if(in.peek() !=
'-')
1189 if(in.peek() ==
'-')
1192 if(in.peek() ==
'>')
1200 }
while(!done&&!in.fail());
1244 <<
"ossimXmlNode::readTextContent: entered ...\n";
1251 bool result =
false;
1260 std::streampos initialPos = in.tellg();
1270 }
while ( (c !=
'<') && !in.fail() );
1273 result = !in.fail();
1281 in.seekg(initialPos);
1282 result = !in.fail();
1305 result = !in.fail();
1313 else if ( c ==
'[' )
1355 <<
"\nexit status: " << (result?
"true":
"false")
1356 <<
"\nossimXmlNode::readTextContent: leaving ...\n";
1365 bool result =
false;
1373 return (!in.fail());
1381 if(in.fail())
return false;
1399 if(in.fail()) result =
false;
ossimXmlNode * theParentNode
void clear()
Erases the entire container.
void setTag(const ossimString &tag)
bool read(std::istream &in)
void setText(const ossimString &text)
RTTI_DEF2(ossimXmlNode, "ossimXmlNode", ossimObject, ossimErrorStatusInterface)
void findChildNodes(const ossimString &rel_xpath, ossimXmlNode::ChildListType &nodelist) const
Represents serializable keyword/value map.
bool read(std::istream &in)
const ossimXmlNode::ChildListType & getChildNodes() const
ossimString const & getTag() const
void duplicateChildren(ossimXmlNode::ChildListType &result) const
std::vector< ossimRefPtr< ossimXmlAttribute > > AttributeListType
vector< ossimRefPtr< ossimXmlAttribute > > theAttributes
bool readTag(std::istream &in, ossimString &tag)
const ossimString & getValue() const
ossimRefPtr< ossimXmlNode > addNode(const ossimString &relPath, const ossimString &text="")
const ossimRefPtr< ossimXmlNode > & findFirstNode(const ossimString &rel_xpath) const
void toKwl(ossimKeywordlist &kwl, const ossimString &prefix="") const
ossimRefPtr< ossimXmlNode > removeChild(ossimRefPtr< ossimXmlNode > node)
ostream & operator<<(ostream &os, const ossimXmlNode &xml_node)
ossimRefPtr< ossimXmlNode > addOrSetNode(const ossimString &relPath, const ossimString &text="")
std::vector< ossimRefPtr< ossimXmlNode > > ChildListType
bool readTextContent(std::istream &in)
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
void setValue(const ossimString &value)
bool getAttributeValue(ossimString &value, const ossimString &name) const
const ossimString & getText() const
void addChildren(ossimXmlNode::ChildListType &children)
ossimRefPtr< ossimXmlAttribute > findAttribute(const ossimString &name)
void addAttributes(ossimXmlNode::AttributeListType &children)
const ossimXmlNode * getParentNode() const
std::string::size_type size() const
void duplicateAttributes(ossimXmlNode::AttributeListType result) const
unsigned int ossim_uint32
bool readEndTag(std::istream &in, ossimString &endTag)
void skipCommentTag(std::istream &in)
const ossimXmlNode::AttributeListType & getAttributes() const
bool readCDataContent(std::istream &in)
void setParent(ossimXmlNode *parent)
std::basic_istream< char > istream
Base class for char input streams.
void setAttributes(ossimXmlNode::AttributeListType &children)
vector< ossimRefPtr< ossimXmlNode > > theChildNodes
void setChildren(ossimXmlNode::ChildListType &children)
bool setAttribute(const ossimString &name, const ossimString &value, bool addIfNotPresentFlag=false)
virtual void setErrorStatus() const
void setCDataFlag(bool value)
bool getChildTextValue(ossimString &value, const ossimString &relPath) const
std::string substr(std::string::size_type pos=0, std::string::size_type n=std::string::npos) const
Equivalent to basic_string(*this, pos, n).
void addAttribute(ossimRefPtr< ossimXmlAttribute > attribute)
void addChildNode(ossimRefPtr< ossimXmlNode > node)
std::string::size_type find(const std::string &s, std::string::size_type pos=0) const
Searches for s as a substring of *this, beginning at character pos of *this.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
virtual ossimObject * dup() const