Ejemplo n.º 1
0
void ossimXmlNode::addChildren(ossimXmlNode::ChildListType& children)
{
    ossim_uint32 idx;
    for(idx = 0; idx < children.size(); ++idx)
    {
        addChildNode(children[idx].get());
    }
}
Ejemplo n.º 2
0
void ossimXmlNode::duplicateChildren(ossimXmlNode::ChildListType& result)const
{
    ossim_uint32 idx = 0;
    for(idx = 0; idx<theChildNodes.size(); ++idx)
    {
        result.push_back((ossimXmlNode*)theChildNodes[idx]->dup());
    }
}
Ejemplo n.º 3
0
void ossimXmlNode::findChildNodes(const ossimString& xpath,
                                  ossimXmlNode::ChildListType& result)const
{
    //***
    // Scan for trivial result (no children owned):
    //***
    if (theChildNodes.size() == 0)
        return;

    //***
    // Make a copy to manipulate:
    //***
    ossimString rel_xpath (xpath);
    if (rel_xpath.empty())
        return;

    //---
    // First verify that this is not an absolute path:
    //---
    if (rel_xpath[static_cast<std::string::size_type>(0)] ==
            XPATH_DELIM[static_cast<std::string::size_type>(0)])
    {
        ossimNotify(ossimNotifyLevel_WARN)
                << "WARNING: ossimXmlNode::findChildNodes\n"
                << "Only relative XPaths can be searched from a node. "
                << "Returning null list...\n";
        return;
    }

    //***
    // Read the desired tag from the relative xpath
    //***
    ossimString desired_tag (rel_xpath);
    if (rel_xpath.contains(XPATH_DELIM))
        desired_tag = rel_xpath.before(XPATH_DELIM);
    ossimString sub_xpath (rel_xpath.after(XPATH_DELIM));

    //***
    // Loop over all child nodes for match:
    //***
    ossimXmlNode::ChildListType::const_iterator child_iter = theChildNodes.begin();
    while(child_iter != theChildNodes.end())
    {
        if ((*child_iter)->getTag() == desired_tag)
        {
            if (sub_xpath.empty())
            {
                //***
                // This was the final target node, simply append to the result:
                //***
                result.push_back(*child_iter);
            }
            else
            {
                //***
                // This match identifies a possible tree to search given the
                // remaining xpath (sub_xpath). Query this child node to search
                // its tree for the remaining xpath:
                //***
                (*child_iter)->findChildNodes(sub_xpath, result);
            }
        }

        //***
        // Proceed to next child:
        //***
        child_iter++;
    }
}
Ejemplo n.º 4
0
void ossimXmlNode::findChildNodes(const ossimString& xpath,
                                  ossimXmlNode::ChildListType& result)const
{
   //***
   // Scan for trivial result (no children owned):
   //***
   if (theChildNodes.empty())
      return;
   
   if (xpath.empty())
      return;
   
   //---
   // First verify that this is not an absolute path:
   //---
   if (xpath[static_cast<std::string::size_type>(0)] == XPATH_DELIM)
   {
      if(traceDebug())
      {
         ossimNotify(ossimNotifyLevel_WARN)
            << "WARNING: ossimXmlNode::findChildNodes\n"
            << "Only relative XPaths can be searched from a node. "
            << "Returning null list...\n";
         }
      return;
   }
   
   //***
   // Read the desired tag from the relative xpath
   //***
   const std::string::size_type delim_pos = xpath.find(XPATH_DELIM);
   // TODO: need string_view
   const ossimString desired_tag = xpath.substr(0,delim_pos);
   
   //***
   // Loop over all child nodes for match:
   //***
   ossimXmlNode::ChildListType::const_iterator child_iter = theChildNodes.begin();
   ossimXmlNode::ChildListType::const_iterator child_end  = theChildNodes.end();
   
   if (delim_pos==std::string::npos) // No XPATH_DELIM character found
   {
      for ( ; child_iter != child_end ; ++ child_iter)
      {
         if ((*child_iter)->getTag() == desired_tag)
            //***
            // This was the final target node, simply append to the result:
            //***
            result.push_back(*child_iter);
      }
   }
   else
   {
      const ossimString sub_xpath   = xpath.substr(delim_pos+1, std::string::npos);
      for ( ; child_iter != child_end ; ++ child_iter)
      {
         if ((*child_iter)->getTag() == desired_tag)
            //***
            // This match identifies a possible tree to search given the
            // remaining xpath (sub_xpath). Query this child node to search
            // its tree for the remaining xpath:
            //***
            (*child_iter)->findChildNodes(sub_xpath, result);
      }
   }
}