summaryrefslogtreecommitdiff
path: root/xml2cmp
diff options
context:
space:
mode:
authorNikolai Pretzell <np@openoffice.org>2002-11-11 12:56:57 +0000
committerNikolai Pretzell <np@openoffice.org>2002-11-11 12:56:57 +0000
commit4486321f54bb78bd1a7d22023c035ddf2b789adf (patch)
tree4d21a32532187ea9fc1dbef12c9b60ce80e230a7 /xml2cmp
parent9116e15052add7465bd6dc44f34114f32287a8d7 (diff)
#91933# Allow XML tags like <EmptyTag/> in XML module descriptions.
Diffstat (limited to 'xml2cmp')
-rw-r--r--xml2cmp/source/xcd/parse.cxx42
-rw-r--r--xml2cmp/source/xcd/parse.hxx9
2 files changed, 40 insertions, 11 deletions
diff --git a/xml2cmp/source/xcd/parse.cxx b/xml2cmp/source/xcd/parse.cxx
index 894366c33151..a79cd91688d8 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 285f74ee7e4c..1c06ec8b436c 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(