* * Parse an XML element and its children. This is the main parsing * function. The lexical analyser contains a references to the input * stream being parsed. The function calls itself recursively to * parse its children. * * @param lex The lexical analyser for this parse. * * @return The element that has just been read from the input stream. * *******************************************
| 297 | * |
| 298 | *************************************************************************/ |
| 299 | ElementXMLImpl* ParseXML::ParseElement() |
| 300 | { |
| 301 | // Check if we're starting with a comment |
| 302 | while (Have(kComment)) |
| 303 | { |
| 304 | SetLastComment(GetTokenValue()) ; |
| 305 | GetNextToken() ; |
| 306 | } |
| 307 | |
| 308 | // We must start with an open tag marker |
| 309 | MustBe(kOpenTagChar) ; |
| 310 | |
| 311 | // For now ignore header tags |
| 312 | if (Have(kHeaderChar)) |
| 313 | { |
| 314 | while (!IsError() && !Have(kCloseTagChar)) |
| 315 | { |
| 316 | GetNextToken() ; |
| 317 | } |
| 318 | |
| 319 | // We must start with an open tag marker |
| 320 | MustBe(kOpenTagChar) ; |
| 321 | |
| 322 | //return NULL ; |
| 323 | } |
| 324 | |
| 325 | // Create the object we'll be returning |
| 326 | ElementXMLImpl* pElement = new ElementXMLImpl() ; |
| 327 | |
| 328 | // Get the tag name |
| 329 | ParseString tagName ; |
| 330 | MustBe(kIdentifier, tagName) ; |
| 331 | |
| 332 | pElement->SetTagName(tagName.c_str()) ; |
| 333 | |
| 334 | if (HasLastComment()) |
| 335 | { |
| 336 | pElement->SetComment(GetLastComment()) ; |
| 337 | SetLastComment("") ; |
| 338 | } |
| 339 | |
| 340 | // Used to record whether data is encoded binary |
| 341 | bool dataIsEncoded = false ; |
| 342 | |
| 343 | // Read all of the attributes (if there are any) |
| 344 | while (!IsError() && Have(kIdentifier)) |
| 345 | { |
| 346 | ParseString name = GetTokenValue() ; |
| 347 | |
| 348 | // Consume the name |
| 349 | GetNextToken() ; |
| 350 | |
| 351 | // Must be followed by "=" |
| 352 | MustBe(kEqualsChar) ; |
| 353 | |
| 354 | // Then must be followed by a string containing the value |
| 355 | ParseString value ; |
| 356 | MustBe(kQuotedString, value) ; |
no test coverage detected