/** * Returns true if the given string has only whitespace characters */ bool XMLUtils::isWhitespace(const nsAFlatString& aText) { nsAFlatString::const_char_iterator start, end; aText.BeginReading(start); aText.EndReading(end); for ( ; start != end; ++start) { if (!isWhitespace(*start)) { return false; } } return true; }
void txStandaloneXSLTProcessor::parseStylesheetPI(const nsAFlatString& aData, nsAString& aType, nsAString& aHref) { nsAFlatString::const_char_iterator start, end; aData.BeginReading(start); aData.EndReading(end); nsAFlatString::const_char_iterator iter; PRInt8 found = 0; while (start != end) { SKIP_WHITESPACE(start, end); iter = start; SKIP_ATTR_NAME(iter, end); // Remember the attr name. const nsAString & attrName = Substring(start, iter); // Now check whether this is a valid name="value" pair. start = iter; SKIP_WHITESPACE(start, end); if (*start != '=') { // No '=', so this is not a name="value" pair. We don't know // what it is, and we have no way to handle it. break; } // Have to skip the value. ++start; SKIP_WHITESPACE(start, end); PRUnichar q = *start; if (q != QUOTE && q != APOSTROPHE) { // Not a valid quoted value, so bail. break; } ++start; // Point to the first char of the value. iter = start; while (iter != end && *iter != q) { ++iter; } if (iter == end) { // Oops, unterminated quoted string. break; } // At this point attrName holds the name of the "attribute" and // the value is between start and iter. if (attrName.EqualsLiteral("type")) { aType = Substring(start, iter); ++found; } else if (attrName.EqualsLiteral("href")) { aHref = Substring(start, iter); ++found; } // Stop if we found both attributes if (found == 2) { break; } // Resume scanning after the end of the attribute value. start = iter; ++start; // To move past the quote char. } }