xref: /aoo41x/main/xml2cmp/source/xcd/parse.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir #include <parse.hxx>
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <string.h>
32*cdf0e10cSrcweir #include <iostream>
33*cdf0e10cSrcweir #include <xmlelem.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #if (_MSC_VER >=1400)
36*cdf0e10cSrcweir #pragma warning(disable:4365)
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #ifdef UNX
40*cdf0e10cSrcweir #define strnicmp strncasecmp
41*cdf0e10cSrcweir #endif
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir #define AssertionOf(x)	\
50*cdf0e10cSrcweir 	{if (!(x)) {std::cerr << "Assertion failed: " << #x << __FILE__ << __LINE__ << std::endl; exit(3); }}
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir X2CParser::X2CParser( XmlElement & o_rDocumentData )
55*cdf0e10cSrcweir 	:	// sFileName,
56*cdf0e10cSrcweir 		nFileLine(0),
57*cdf0e10cSrcweir 		pDocumentData(&o_rDocumentData),
58*cdf0e10cSrcweir         // sWord,
59*cdf0e10cSrcweir 		text(0)
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir }
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir X2CParser::~X2CParser()
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir }
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir bool
69*cdf0e10cSrcweir X2CParser::LoadFile( const char * i_sFilename )
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir 	sFileName = i_sFilename;
72*cdf0e10cSrcweir 	nFileLine = 1;
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir 	// Load file:
75*cdf0e10cSrcweir 	if ( ! LoadXmlFile( aFile, i_sFilename ) )
76*cdf0e10cSrcweir 		return false;
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 	// Test correct end:
79*cdf0e10cSrcweir 	const char * pLastTag = strrchr(aFile.operator const char *(),'<');
80*cdf0e10cSrcweir 	if (pLastTag == 0)
81*cdf0e10cSrcweir 		return false;
82*cdf0e10cSrcweir 	if ( strnicmp(pLastTag+2, pDocumentData->Name().str(), pDocumentData->Name().l()) != 0
83*cdf0e10cSrcweir 		 || strnicmp(pLastTag, "</", 2) != 0 )
84*cdf0e10cSrcweir 		return false;
85*cdf0e10cSrcweir 	if (strchr(pLastTag,'>') == 0)
86*cdf0e10cSrcweir 		return false;
87*cdf0e10cSrcweir 	return true;
88*cdf0e10cSrcweir }
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir void
91*cdf0e10cSrcweir X2CParser::Parse()
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir 	// Parse:
94*cdf0e10cSrcweir 	text = aFile.operator const char *();
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 	Parse_XmlDeclaration();
97*cdf0e10cSrcweir 	Parse_Doctype();
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 	pDocumentData->Parse(*this);
100*cdf0e10cSrcweir }
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir bool
103*cdf0e10cSrcweir X2CParser::Parse( const char * i_sFilename )
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir 	bool ret = LoadFile(i_sFilename);
106*cdf0e10cSrcweir 	if (ret)
107*cdf0e10cSrcweir 		Parse();
108*cdf0e10cSrcweir 	return ret;
109*cdf0e10cSrcweir }
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir void
112*cdf0e10cSrcweir X2CParser::Parse_XmlDeclaration()
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir 	Goto('<');
115*cdf0e10cSrcweir 	if ( IsText("<?xml") )
116*cdf0e10cSrcweir 	{
117*cdf0e10cSrcweir 		Goto_And_Pass('>');
118*cdf0e10cSrcweir 	}
119*cdf0e10cSrcweir }
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir void
122*cdf0e10cSrcweir X2CParser::Parse_Doctype()
123*cdf0e10cSrcweir {
124*cdf0e10cSrcweir 	Goto('<');
125*cdf0e10cSrcweir 	if ( IsText("<!DOCTYPE") )
126*cdf0e10cSrcweir 		Goto_And_Pass('>');
127*cdf0e10cSrcweir }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir void
130*cdf0e10cSrcweir X2CParser::Parse_Sequence( DynamicList<XmlElement> & o_rElements,
131*cdf0e10cSrcweir 						   const Simstr &			 i_sElementName  )
132*cdf0e10cSrcweir {
133*cdf0e10cSrcweir 	CheckAndPassBeginTag(i_sElementName.str());
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	unsigned int i_max = o_rElements.size();
136*cdf0e10cSrcweir 	for (unsigned i = 0; i < i_max; ++i)
137*cdf0e10cSrcweir 	{
138*cdf0e10cSrcweir 		o_rElements[i]->Parse(*this);
139*cdf0e10cSrcweir 	}  // end for
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 	CheckAndPassEndTag(i_sElementName.str());
142*cdf0e10cSrcweir }
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir void
145*cdf0e10cSrcweir X2CParser::Parse_FreeChoice( DynamicList<XmlElement> & o_rElements )
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir 	unsigned     	nSize = o_rElements.size();
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 	for ( bool bBreak = false;  !bBreak; )
150*cdf0e10cSrcweir 	{
151*cdf0e10cSrcweir 		bBreak = true;
152*cdf0e10cSrcweir 		for ( unsigned i = 0; i < nSize; ++i )
153*cdf0e10cSrcweir 		{
154*cdf0e10cSrcweir 			Goto('<');
155*cdf0e10cSrcweir 			if ( IsBeginTag(o_rElements[i]->Name().str()) )
156*cdf0e10cSrcweir 			{
157*cdf0e10cSrcweir 				o_rElements[i]->Parse(*this);
158*cdf0e10cSrcweir 				bBreak = false;
159*cdf0e10cSrcweir 				break;
160*cdf0e10cSrcweir 			}
161*cdf0e10cSrcweir 		}  	// end for i
162*cdf0e10cSrcweir 	} 	// end for !bBreak
163*cdf0e10cSrcweir }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir void
166*cdf0e10cSrcweir X2CParser::Parse_List( ListElement &  o_rListElem )
167*cdf0e10cSrcweir {
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 	for ( Goto('<'); IsBeginTag(o_rListElem.Name().str()); Goto('<') )
170*cdf0e10cSrcweir 	{
171*cdf0e10cSrcweir 		XmlElement * pNew = o_rListElem.Create_and_Add_NewElement();
172*cdf0e10cSrcweir 		pNew->Parse(*this);
173*cdf0e10cSrcweir 	}
174*cdf0e10cSrcweir }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir void
177*cdf0e10cSrcweir X2CParser::Parse_Text( Simstr &			o_sText,
178*cdf0e10cSrcweir 					   const Simstr &	i_sElementName,
179*cdf0e10cSrcweir 					   bool				i_bReverseName )
180*cdf0e10cSrcweir {
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 	if ( ! CheckAndPassBeginTag(i_sElementName.str()) )
183*cdf0e10cSrcweir         return;
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 	// Add new Element
186*cdf0e10cSrcweir 	GetTextTill( o_sText, '<', i_bReverseName );
187*cdf0e10cSrcweir 	o_sText.remove_trailing_blanks();
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 	CheckAndPassEndTag(i_sElementName.str());
190*cdf0e10cSrcweir }
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir void
193*cdf0e10cSrcweir X2CParser::Parse_MultipleText( List<Simstr> &	o_rTexts,
194*cdf0e10cSrcweir 							   const Simstr &	i_sElementName,
195*cdf0e10cSrcweir 							   bool				i_bReverseName )
196*cdf0e10cSrcweir {
197*cdf0e10cSrcweir 	for ( Goto('<'); IsBeginTag(i_sElementName.str()); Goto('<') )
198*cdf0e10cSrcweir 	{
199*cdf0e10cSrcweir         Simstr sNew;
200*cdf0e10cSrcweir 		Parse_Text(sNew, i_sElementName, i_bReverseName);
201*cdf0e10cSrcweir         if (sNew.l() > 0)
202*cdf0e10cSrcweir     		o_rTexts.push_back(sNew);
203*cdf0e10cSrcweir 	}
204*cdf0e10cSrcweir }
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir void
207*cdf0e10cSrcweir X2CParser::Parse_SglAttr( Simstr &			o_sAttrValue,
208*cdf0e10cSrcweir 						  const Simstr &	i_sElementName,
209*cdf0e10cSrcweir 						  const Simstr &	i_sAttrName )
210*cdf0e10cSrcweir {
211*cdf0e10cSrcweir 	Goto('<');
212*cdf0e10cSrcweir 	if ( !IsBeginTag(i_sElementName.str()) )
213*cdf0e10cSrcweir 		SyntaxError("unexpected element");
214*cdf0e10cSrcweir 	Move( i_sElementName.l() + 1 );
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir 	Pass_White();
217*cdf0e10cSrcweir 	if (*text == '>')
218*cdf0e10cSrcweir 		SyntaxError("no attribute found, where one was expected");
219*cdf0e10cSrcweir 	Simstr sAttrName;
220*cdf0e10cSrcweir 	Get_Attribute(o_sAttrValue, sAttrName);
221*cdf0e10cSrcweir 	if (sAttrName != i_sAttrName)
222*cdf0e10cSrcweir 		SyntaxError("unknown attribute found");
223*cdf0e10cSrcweir 	Pass_White();
224*cdf0e10cSrcweir 	if (strncmp(text,"/>",2) != 0)
225*cdf0e10cSrcweir 		SyntaxError("missing \"/>\" at end of empty element");
226*cdf0e10cSrcweir 	Move(2);
227*cdf0e10cSrcweir }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir void
230*cdf0e10cSrcweir X2CParser::Parse_MultipleAttr( List<Simstr> &		o_rAttrValues,
231*cdf0e10cSrcweir 							   const Simstr &		i_sElementName,
232*cdf0e10cSrcweir 							   const List<Simstr> &	i_rAttrNames )
233*cdf0e10cSrcweir {
234*cdf0e10cSrcweir 	Goto('<');
235*cdf0e10cSrcweir 	if ( !IsBeginTag(i_sElementName.str()) )
236*cdf0e10cSrcweir 		SyntaxError("unexpected element");
237*cdf0e10cSrcweir 	Move( i_sElementName.l() + 1 );
238*cdf0e10cSrcweir 	Simstr sAttrName;
239*cdf0e10cSrcweir 	Simstr sAttrValue;
240*cdf0e10cSrcweir 	unsigned nSize = i_rAttrNames.size();
241*cdf0e10cSrcweir 	unsigned i;
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 	for ( Pass_White(); *text != '/'; Pass_White() )
244*cdf0e10cSrcweir 	{
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir 		Get_Attribute(sAttrValue, sAttrName);
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 		for ( i = 0; i < nSize; ++i )
249*cdf0e10cSrcweir 		{
250*cdf0e10cSrcweir 			if ( i_rAttrNames[i] == sAttrName )
251*cdf0e10cSrcweir             {
252*cdf0e10cSrcweir 				o_rAttrValues[i] = sAttrValue;
253*cdf0e10cSrcweir 				break;
254*cdf0e10cSrcweir 			}
255*cdf0e10cSrcweir 		}
256*cdf0e10cSrcweir 		if (i == nSize)
257*cdf0e10cSrcweir 			SyntaxError("unknown attribute found");
258*cdf0e10cSrcweir 	}
259*cdf0e10cSrcweir 	Move(2);
260*cdf0e10cSrcweir }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir void
264*cdf0e10cSrcweir X2CParser::Get_Attribute( Simstr & o_rAttrValue,
265*cdf0e10cSrcweir 						  Simstr & o_rAttrName )
266*cdf0e10cSrcweir {
267*cdf0e10cSrcweir 	GetTextTill( o_rAttrName, '=');
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir 	while (*(++text) != '"')
270*cdf0e10cSrcweir 	{
271*cdf0e10cSrcweir 		if (*text == '\0')
272*cdf0e10cSrcweir 			SyntaxError("unexpected end of file");
273*cdf0e10cSrcweir 	}
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir 	++text;
276*cdf0e10cSrcweir 	GetTextTill( o_rAttrValue, '"');
277*cdf0e10cSrcweir 	++text;
278*cdf0e10cSrcweir }
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir bool
281*cdf0e10cSrcweir X2CParser::IsText( const char *	i_sComparedText )
282*cdf0e10cSrcweir {
283*cdf0e10cSrcweir 	return strnicmp( text, i_sComparedText, strlen(i_sComparedText) ) == 0;
284*cdf0e10cSrcweir }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir bool
287*cdf0e10cSrcweir X2CParser::IsBeginTag( const char *	i_sTagName )
288*cdf0e10cSrcweir {
289*cdf0e10cSrcweir 	return strnicmp( text+1, i_sTagName, strlen(i_sTagName) ) == 0
290*cdf0e10cSrcweir 		   && *text == '<';
291*cdf0e10cSrcweir }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir bool
294*cdf0e10cSrcweir X2CParser::IsEndTag( const char * i_sTagName )
295*cdf0e10cSrcweir {
296*cdf0e10cSrcweir 	return strnicmp( text+2, i_sTagName, strlen(i_sTagName) ) == 0
297*cdf0e10cSrcweir 		   && strnicmp( text, "</", 2 ) == 0;
298*cdf0e10cSrcweir }
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir void
301*cdf0e10cSrcweir X2CParser::Goto( char i_cNext )
302*cdf0e10cSrcweir {
303*cdf0e10cSrcweir 	while (*text != i_cNext)
304*cdf0e10cSrcweir 	{
305*cdf0e10cSrcweir 		TestCurChar();
306*cdf0e10cSrcweir 		++text;
307*cdf0e10cSrcweir 	}
308*cdf0e10cSrcweir }
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir void
311*cdf0e10cSrcweir X2CParser::Goto_And_Pass( char i_cNext )
312*cdf0e10cSrcweir {
313*cdf0e10cSrcweir 	Goto(i_cNext);
314*cdf0e10cSrcweir 	++text;
315*cdf0e10cSrcweir }
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir void
318*cdf0e10cSrcweir X2CParser::Move( int i_nForward )
319*cdf0e10cSrcweir {
320*cdf0e10cSrcweir 	text += i_nForward;
321*cdf0e10cSrcweir }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir void
324*cdf0e10cSrcweir X2CParser::Pass_White()
325*cdf0e10cSrcweir {
326*cdf0e10cSrcweir 	while (*text <= 32)
327*cdf0e10cSrcweir 	{
328*cdf0e10cSrcweir 		TestCurChar();
329*cdf0e10cSrcweir 		++text;
330*cdf0e10cSrcweir 	}
331*cdf0e10cSrcweir }
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir void
334*cdf0e10cSrcweir X2CParser::GetTextTill( Simstr & o_rText,
335*cdf0e10cSrcweir 						char     i_cEnd,
336*cdf0e10cSrcweir 						bool     i_bReverseName )
337*cdf0e10cSrcweir {
338*cdf0e10cSrcweir 	char * pResult = &sWord[0];
339*cdf0e10cSrcweir 	char * pSet;
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir 	for ( pSet = pResult;
342*cdf0e10cSrcweir 		  *text != i_cEnd;
343*cdf0e10cSrcweir 		  ++text )
344*cdf0e10cSrcweir 	{
345*cdf0e10cSrcweir 		TestCurChar();
346*cdf0e10cSrcweir 		*pSet++ = *text;
347*cdf0e10cSrcweir 	}
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir 	while ( *pResult < 33 && *pResult > 0 )
350*cdf0e10cSrcweir 		++pResult;
351*cdf0e10cSrcweir 	while ( pSet > pResult ? *(pSet-1) < 33 : false )
352*cdf0e10cSrcweir 		pSet--;
353*cdf0e10cSrcweir 	*pSet = '\0';
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir 	if (i_bReverseName)
357*cdf0e10cSrcweir 	{
358*cdf0e10cSrcweir         const unsigned int nMaxLen = 1000;
359*cdf0e10cSrcweir         if (strlen(pResult) < nMaxLen)
360*cdf0e10cSrcweir         {
361*cdf0e10cSrcweir     		char * sBreak = strrchr(pResult,'.');
362*cdf0e10cSrcweir 	    	if (sBreak != 0)
363*cdf0e10cSrcweir 		    {
364*cdf0e10cSrcweir 			    static char sScope[nMaxLen+10];
365*cdf0e10cSrcweir     			static char sName[nMaxLen+10];
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir         		unsigned nScopeLen = sBreak - pResult;
368*cdf0e10cSrcweir 		    	strncpy ( sScope, pResult, nScopeLen ); // STRNCPY SAFE HERE
369*cdf0e10cSrcweir 			    sScope[nScopeLen] = '\0';
370*cdf0e10cSrcweir 			    strcpy( sName, sBreak + 1 );            // STRCPY SAFE HERE
371*cdf0e10cSrcweir 			    strcat( sName, " in " );                // STRCAT SAFE HERE
372*cdf0e10cSrcweir 			    strcat( sName, sScope );                // STRCAT SAFE HERE
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir 			    o_rText = sName;
375*cdf0e10cSrcweir 			    return;
376*cdf0e10cSrcweir 		    }
377*cdf0e10cSrcweir         }
378*cdf0e10cSrcweir 	}   // endif (i_bReverseName)
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir 	o_rText = &sWord[0];
381*cdf0e10cSrcweir }
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir bool
384*cdf0e10cSrcweir X2CParser::CheckAndPassBeginTag( const char * i_sElementName )
385*cdf0e10cSrcweir {
386*cdf0e10cSrcweir     bool ret = true;
387*cdf0e10cSrcweir 	Goto('<');
388*cdf0e10cSrcweir 	if ( ! IsBeginTag(i_sElementName) )
389*cdf0e10cSrcweir 		SyntaxError( "unexpected element");
390*cdf0e10cSrcweir     if (IsAbsoluteEmpty())
391*cdf0e10cSrcweir         ret = false;
392*cdf0e10cSrcweir 	Goto_And_Pass('>');
393*cdf0e10cSrcweir     if (ret)
394*cdf0e10cSrcweir 	    Pass_White();
395*cdf0e10cSrcweir     return ret;
396*cdf0e10cSrcweir }
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir void
399*cdf0e10cSrcweir X2CParser::CheckAndPassEndTag( const char *	i_sElementName )
400*cdf0e10cSrcweir {
401*cdf0e10cSrcweir 	Pass_White();
402*cdf0e10cSrcweir 	if ( !IsEndTag(i_sElementName) )
403*cdf0e10cSrcweir 		SyntaxError("missing or not matching end tag");
404*cdf0e10cSrcweir 	Goto_And_Pass('>');
405*cdf0e10cSrcweir }
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir bool
408*cdf0e10cSrcweir X2CParser::IsAbsoluteEmpty() const
409*cdf0e10cSrcweir {
410*cdf0e10cSrcweir 	const char * pEnd = strchr(text+1, '>');
411*cdf0e10cSrcweir     if (pEnd != 0)
412*cdf0e10cSrcweir     {
413*cdf0e10cSrcweir         if ( *(pEnd-1) == '/' )
414*cdf0e10cSrcweir         {
415*cdf0e10cSrcweir             const char * pAttr = strchr(text+1, '"');
416*cdf0e10cSrcweir          	if (pAttr == 0)
417*cdf0e10cSrcweir                 return true;
418*cdf0e10cSrcweir             else if ( (pAttr-text) > (pEnd-text) )
419*cdf0e10cSrcweir                 return true;
420*cdf0e10cSrcweir         }
421*cdf0e10cSrcweir     }
422*cdf0e10cSrcweir     return false;
423*cdf0e10cSrcweir }
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir void
426*cdf0e10cSrcweir X2CParser::SyntaxError( const char * i_sText )
427*cdf0e10cSrcweir {
428*cdf0e10cSrcweir 	std::cerr
429*cdf0e10cSrcweir          << "Syntax error "
430*cdf0e10cSrcweir 		 << i_sText
431*cdf0e10cSrcweir 		 << " in file: "
432*cdf0e10cSrcweir 		 << sFileName.str()
433*cdf0e10cSrcweir 		 << " in line "
434*cdf0e10cSrcweir 		 << nFileLine
435*cdf0e10cSrcweir 		 << "."
436*cdf0e10cSrcweir 		 << std::endl;
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir 	 exit(3);
439*cdf0e10cSrcweir }
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir void
442*cdf0e10cSrcweir X2CParser::TestCurChar()
443*cdf0e10cSrcweir {
444*cdf0e10cSrcweir //	if (*text == '\0')
445*cdf0e10cSrcweir //		SyntaxError("unexpected end of file");
446*cdf0e10cSrcweir //	else
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir 	if (*text == '\n')
449*cdf0e10cSrcweir 		nFileLine++;
450*cdf0e10cSrcweir }
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir 
453