diff options
author | Nikolai Pretzell <np@openoffice.org> | 2002-11-11 12:56:57 +0000 |
---|---|---|
committer | Nikolai Pretzell <np@openoffice.org> | 2002-11-11 12:56:57 +0000 |
commit | c6507cfc1b069670bab9b6d64dce40c6a486d658 (patch) | |
tree | 70086f1af504d1402f78adc803ea25c1571065b4 /xml2cmp | |
parent | d58f914db07a4b993d028897c428adbfba728826 (diff) |
#91933# Allow XML tags like <EmptyTag/> in XML module descriptions.
Diffstat (limited to 'xml2cmp')
-rw-r--r-- | xml2cmp/source/xcd/parse.cxx | 42 | ||||
-rw-r--r-- | xml2cmp/source/xcd/parse.hxx | 9 |
2 files changed, 40 insertions, 11 deletions
diff --git a/xml2cmp/source/xcd/parse.cxx b/xml2cmp/source/xcd/parse.cxx index af3c83bcc..9d9a2f871 100644 --- a/xml2cmp/source/xcd/parse.cxx +++ b/xml2cmp/source/xcd/parse.cxx @@ -2,9 +2,9 @@ * * $RCSfile: parse.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: np $Date: 2001/03/23 13:39:37 $ + * last change: $Author: np $Date: 2002/08/08 16:08:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -208,7 +208,9 @@ X2CParser::Parse_Text( Simstr & o_sText, const Simstr & i_sElementName, bool i_bReverseName ) { - CheckAndPassBeginTag(i_sElementName.str()); + + if ( ! CheckAndPassBeginTag(i_sElementName.str()) ) + return; // Add new Element GetTextTill( o_sText, '<', i_bReverseName ); @@ -224,8 +226,10 @@ X2CParser::Parse_MultipleText( List<Simstr> & o_rTexts, { for ( Goto('<'); IsBeginTag(i_sElementName.str()); Goto('<') ) { - o_rTexts.push_back(Simstr()); - Parse_Text(o_rTexts.back(), i_sElementName, i_bReverseName); + Simstr sNew; + Parse_Text(sNew, i_sElementName, i_bReverseName); + if (sNew.l() > 0) + o_rTexts.push_back(sNew); } } @@ -400,15 +404,19 @@ X2CParser::GetTextTill( Simstr & o_rText, o_rText = &sWord[0]; } -void +bool X2CParser::CheckAndPassBeginTag( const char * i_sElementName ) { + bool ret = true; Goto('<'); if ( ! IsBeginTag(i_sElementName) ) SyntaxError( "unexpected element"); + if (IsAbsoluteEmpty()) + ret = false; Goto_And_Pass('>'); - Pass_White(); - + if (ret) + Pass_White(); + return ret; } void @@ -420,6 +428,24 @@ X2CParser::CheckAndPassEndTag( const char * i_sElementName ) Goto_And_Pass('>'); } +bool +X2CParser::IsAbsoluteEmpty() const +{ + const char * pEnd = strchr(text+1, '>'); + if (pEnd != 0) + { + if ( *(pEnd-1) == '/' ) + { + const char * pAttr = strchr(text+1, '"'); + if (pAttr == 0) + return true; + else if ( (pAttr-text) > (pEnd-text) ) + return true; + } + } + return false; +} + void X2CParser::SyntaxError( const char * i_sText ) { diff --git a/xml2cmp/source/xcd/parse.hxx b/xml2cmp/source/xcd/parse.hxx index bde779958..128412e03 100644 --- a/xml2cmp/source/xcd/parse.hxx +++ b/xml2cmp/source/xcd/parse.hxx @@ -2,9 +2,9 @@ * * $RCSfile: parse.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: np $Date: $ + * last change: $Author: np $Date: 2001/03/23 13:39:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -145,10 +145,13 @@ class X2CParser Simstr & o_rText, char i_cEnd, bool i_bReverseName = false ); - void CheckAndPassBeginTag( + /// @return false in case of empty tag with no attributes. + bool CheckAndPassBeginTag( const char * i_sElementName ); void CheckAndPassEndTag( const char * i_sElementName ); + /// @precond IsBeginTag() == true. + bool IsAbsoluteEmpty() const; void SyntaxError( |