From 5c3263289b3e10c49badd416e12075af0f2f294e Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 6 Jun 2006 07:52:12 +0000 Subject: 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. --- src/xmlreader.cpp | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'src/xmlreader.cpp') 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() } setContent( fbContent.getData() ); } - usedChar(); - usedChar(); + usedChar( 2 ); gcall( ws() ); FlexBuf fbName; while( true ) @@ -368,6 +367,46 @@ bool XmlReader::content() throw XmlException("Malformed close tag."); } } + else if( getChar(1) == '!' ) + { + // We know it's a comment, let's see if it's proper + if( getChar(2) != '-' || + getChar(3) != '-' ) + { + // Not a valid XML comment + throw XmlException("Malformed comment start tag found."); + } + + usedChar( 4 ); + + // Now burn text until we find the close tag + for(;;) + { + if( getChar() == '-' ) + { + if( getChar( 1 ) == '-' ) + { + // The next one has to be a '>' now + if( getChar( 2 ) != '>' ) + { + throw XmlException("Malformed comment close tag found. You cannot have a '--' that isn't followed by a '>' in a comment."); + } + usedChar( 3 ); + break; + } + else + { + // Found a dash followed by a non dash, that's ok... + usedChar( 2 ); + } + } + else + { + // Burn comment chars + usedChar(); + } + } + } else { if( fbContent.getLength() > 0 ) -- cgit v1.2.3