Menu

Bug in fromXml()?

Help
2003-02-07
2003-02-13
  • David Monahan

    David Monahan - 2003-02-07

    Using fromXml() to store an xml string. If the string is empty and the string tags are not used i.e.
    <value></value>
    The call to XmlRpcUtil::getNextTag gets the value end tag and the fromXml() method returns "false".

    David

     
    • Chris Morley

      Chris Morley - 2003-02-07

      Yup. I'll fix that. For now, use the <string> tags if you can.

       
    • David Monahan

      David Monahan - 2003-02-10

      I forgot to mention before - thank you for a nicely implemented library.

      This bug was quite nasty in my example as the empty string was in a struct in an array in a struct. The whole lot gets marked invalid type. I did a quick hack on the fromXml() as follows:

      In the check for typeTag:

      else if (typeTag.empty() || typeTag == VALUE_ETAG || typeTag == STRING_TAG)
            result = stringFromXml(valueXml, offset);

      And at the bottom of the fn:
          if (result && typeTag != VALUE_ETAG)  // Skip over the </value> tag
          {
            XmlRpcUtil::findTag(VALUE_ETAG, valueXml, offset);
          }
          else if(!result)
          {
            *offset = savedOffset;
          }

       
      • Chris Morley

        Chris Morley - 2003-02-13

        I think that might still fail for cases where the string is not empty, but is blank (all whitespace). How about this:

            if ( ! XmlRpcUtil::nextTagIs(VALUE_TAG, valueXml, offset))
              return false;       // Not a value, offset not updated

            int afterValueOffset = *offset;
            std::string typeTag = XmlRpcUtil::getNextTag(valueXml, offset);
            bool result = false;
            if (typeTag == BOOLEAN_TAG)
              ...
            // Watch for empty/blank strings with no <string>tag
            else if (typeTag == VALUE_ETAG)
            {
              *offset = afterValueOffset;   // back up & try again
              result = stringFromXml(valueXml, offset);
            }

        I have made this change and a couple others locally and will get them into cvs tonight.

        Chris

         

Log in to post a comment.