diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-06-06 07:52:12 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-06-06 07:52:12 +0000 |
commit | 5c3263289b3e10c49badd416e12075af0f2f294e (patch) | |
tree | 9d0b1f3bb167f794ec18466f94f7e8ce6b1d02fa /src/xmlreader.cpp | |
parent | 579a58106e541ef4a005eceaf4577048c69fa539 (diff) | |
download | libbu++-5c3263289b3e10c49badd416e12075af0f2f294e.tar.gz libbu++-5c3263289b3e10c49badd416e12075af0f2f294e.tar.bz2 libbu++-5c3263289b3e10c49badd416e12075af0f2f294e.tar.xz libbu++-5c3263289b3e10c49badd416e12075af0f2f294e.zip |
Added comment handling to the XML system. It just discards them completely, but
later it will retain them so that even after modifying the nodes the comments
could be kept in place so they aren't destroyed if something changes.
Also added necesarry functions to the XmlDocument that lets the tests run again
and fixes some issues with multiple ownernership when transfering the contents
to a new document.
Diffstat (limited to '')
-rw-r--r-- | src/xmlreader.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/xmlreader.cpp b/src/xmlreader.cpp index 76c6258..70fd1d7 100644 --- a/src/xmlreader.cpp +++ b/src/xmlreader.cpp | |||
@@ -332,8 +332,7 @@ bool XmlReader::content() | |||
332 | } | 332 | } |
333 | setContent( fbContent.getData() ); | 333 | setContent( fbContent.getData() ); |
334 | } | 334 | } |
335 | usedChar(); | 335 | usedChar( 2 ); |
336 | usedChar(); | ||
337 | gcall( ws() ); | 336 | gcall( ws() ); |
338 | FlexBuf fbName; | 337 | FlexBuf fbName; |
339 | while( true ) | 338 | while( true ) |
@@ -368,6 +367,46 @@ bool XmlReader::content() | |||
368 | throw XmlException("Malformed close tag."); | 367 | throw XmlException("Malformed close tag."); |
369 | } | 368 | } |
370 | } | 369 | } |
370 | else if( getChar(1) == '!' ) | ||
371 | { | ||
372 | // We know it's a comment, let's see if it's proper | ||
373 | if( getChar(2) != '-' || | ||
374 | getChar(3) != '-' ) | ||
375 | { | ||
376 | // Not a valid XML comment | ||
377 | throw XmlException("Malformed comment start tag found."); | ||
378 | } | ||
379 | |||
380 | usedChar( 4 ); | ||
381 | |||
382 | // Now burn text until we find the close tag | ||
383 | for(;;) | ||
384 | { | ||
385 | if( getChar() == '-' ) | ||
386 | { | ||
387 | if( getChar( 1 ) == '-' ) | ||
388 | { | ||
389 | // The next one has to be a '>' now | ||
390 | if( getChar( 2 ) != '>' ) | ||
391 | { | ||
392 | throw XmlException("Malformed comment close tag found. You cannot have a '--' that isn't followed by a '>' in a comment."); | ||
393 | } | ||
394 | usedChar( 3 ); | ||
395 | break; | ||
396 | } | ||
397 | else | ||
398 | { | ||
399 | // Found a dash followed by a non dash, that's ok... | ||
400 | usedChar( 2 ); | ||
401 | } | ||
402 | } | ||
403 | else | ||
404 | { | ||
405 | // Burn comment chars | ||
406 | usedChar(); | ||
407 | } | ||
408 | } | ||
409 | } | ||
371 | else | 410 | else |
372 | { | 411 | { |
373 | if( fbContent.getLength() > 0 ) | 412 | if( fbContent.getLength() > 0 ) |