| 1344 | |
| 1345 | |
| 1346 | char* XMLElement::ParseAttributes( char* p ) |
| 1347 | { |
| 1348 | const char* start = p; |
| 1349 | XMLAttribute* prevAttribute = 0; |
| 1350 | |
| 1351 | // Read the attributes. |
| 1352 | while( p ) { |
| 1353 | p = XMLUtil::SkipWhiteSpace( p ); |
| 1354 | if ( !p || !(*p) ) { |
| 1355 | _document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() ); |
| 1356 | return 0; |
| 1357 | } |
| 1358 | |
| 1359 | // attribute. |
| 1360 | if ( XMLUtil::IsAlpha( *p ) ) { |
| 1361 | XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); |
| 1362 | attrib->_memPool = &_document->_attributePool; |
| 1363 | attrib->_memPool->SetTracked(); |
| 1364 | |
| 1365 | p = attrib->ParseDeep( p, _document->ProcessEntities() ); |
| 1366 | if ( !p || Attribute( attrib->Name() ) ) { |
| 1367 | DELETE_ATTRIBUTE( attrib ); |
| 1368 | _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p ); |
| 1369 | return 0; |
| 1370 | } |
| 1371 | // There is a minor bug here: if the attribute in the source xml |
| 1372 | // document is duplicated, it will not be detected and the |
| 1373 | // attribute will be doubly added. However, tracking the 'prevAttribute' |
| 1374 | // avoids re-scanning the attribute list. Preferring performance for |
| 1375 | // now, may reconsider in the future. |
| 1376 | if ( prevAttribute ) { |
| 1377 | prevAttribute->_next = attrib; |
| 1378 | } |
| 1379 | else { |
| 1380 | _rootAttribute = attrib; |
| 1381 | } |
| 1382 | prevAttribute = attrib; |
| 1383 | } |
| 1384 | // end of the tag |
| 1385 | else if ( *p == '/' && *(p+1) == '>' ) { |
| 1386 | _closingType = CLOSED; |
| 1387 | return p+2; // done; sealed element. |
| 1388 | } |
| 1389 | // end of the tag |
| 1390 | else if ( *p == '>' ) { |
| 1391 | ++p; |
| 1392 | break; |
| 1393 | } |
| 1394 | else { |
| 1395 | _document->SetError( XML_ERROR_PARSING_ELEMENT, start, p ); |
| 1396 | return 0; |
| 1397 | } |
| 1398 | } |
| 1399 | return p; |
| 1400 | } |
| 1401 | |
| 1402 | |
| 1403 | // |
nothing calls this directly
no test coverage detected