1449ab281SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3449ab281SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4449ab281SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5449ab281SAndrew Rist  * distributed with this work for additional information
6449ab281SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7449ab281SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8449ab281SAndrew Rist  * "License"); you may not use this file except in compliance
9449ab281SAndrew Rist  * with the License.  You may obtain a copy of the License at
10449ab281SAndrew Rist  *
11449ab281SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12449ab281SAndrew Rist  *
13449ab281SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14449ab281SAndrew Rist  * software distributed under the License is distributed on an
15449ab281SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16449ab281SAndrew Rist  * KIND, either express or implied.  See the License for the
17449ab281SAndrew Rist  * specific language governing permissions and limitations
18449ab281SAndrew Rist  * under the License.
19449ab281SAndrew Rist  *
20449ab281SAndrew Rist  *************************************************************/
21449ab281SAndrew Rist 
22449ab281SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_i18npool.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <stdio.h>
28cdf0e10cSrcweir #include <string.h>
29cdf0e10cSrcweir #include <stack>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "sal/main.h"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <com/sun/star/xml/sax/SAXParseException.hpp>
36cdf0e10cSrcweir #include <com/sun/star/xml/sax/XParser.hpp>
37cdf0e10cSrcweir #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
40cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSource.hpp>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx>
43cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
44cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include <vos/diagnose.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include "LocaleNode.hxx"
49cdf0e10cSrcweir 
50cdf0e10cSrcweir using namespace ::rtl;
51cdf0e10cSrcweir using namespace ::std;
52cdf0e10cSrcweir using namespace ::cppu;
53cdf0e10cSrcweir using namespace ::com::sun::star::uno;
54cdf0e10cSrcweir using namespace ::com::sun::star::lang;
55cdf0e10cSrcweir using namespace ::com::sun::star::registry;
56cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax;
57cdf0e10cSrcweir using namespace ::com::sun::star::io;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 
64cdf0e10cSrcweir /************
65cdf0e10cSrcweir  * Sequence of bytes -> InputStream
66cdf0e10cSrcweir  ************/
67cdf0e10cSrcweir class OInputStream : public WeakImplHelper1 < XInputStream >
68cdf0e10cSrcweir {
69cdf0e10cSrcweir public:
OInputStream(const Sequence<sal_Int8> & seq)70cdf0e10cSrcweir 	OInputStream( const Sequence< sal_Int8 >&seq ) :
71cdf0e10cSrcweir 		nPos( 0 ),
72cdf0e10cSrcweir 		m_seq( seq )
73cdf0e10cSrcweir 		{}
74cdf0e10cSrcweir 
75cdf0e10cSrcweir public:
readBytes(Sequence<sal_Int8> & aData,sal_Int32 nBytesToRead)76cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL readBytes( Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
77cdf0e10cSrcweir 		throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
78cdf0e10cSrcweir 		{
79cdf0e10cSrcweir 			nBytesToRead = (nBytesToRead > m_seq.getLength() - nPos ) ?
80cdf0e10cSrcweir 				m_seq.getLength() - nPos :
81cdf0e10cSrcweir 				nBytesToRead;
82cdf0e10cSrcweir 			aData = Sequence< sal_Int8 > ( &(m_seq.getConstArray()[nPos]) , nBytesToRead );
83cdf0e10cSrcweir 			nPos += nBytesToRead;
84cdf0e10cSrcweir 			return nBytesToRead;
85cdf0e10cSrcweir 		}
readSomeBytes(::com::sun::star::uno::Sequence<sal_Int8> & aData,sal_Int32 nMaxBytesToRead)86cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL readSomeBytes(
87cdf0e10cSrcweir 		::com::sun::star::uno::Sequence< sal_Int8 >& aData,
88cdf0e10cSrcweir 		sal_Int32 nMaxBytesToRead )
89cdf0e10cSrcweir 		throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
90cdf0e10cSrcweir 		{
91cdf0e10cSrcweir 			return readBytes( aData, nMaxBytesToRead );
92cdf0e10cSrcweir 		}
skipBytes(sal_Int32)93cdf0e10cSrcweir     virtual void SAL_CALL skipBytes( sal_Int32 /*nBytesToSkip*/ )
94cdf0e10cSrcweir 		throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
95cdf0e10cSrcweir 		{
96cdf0e10cSrcweir 			// not implemented
97cdf0e10cSrcweir 		}
available()98cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL available(  )
99cdf0e10cSrcweir 		throw(NotConnectedException, IOException, RuntimeException)
100cdf0e10cSrcweir 		{
101cdf0e10cSrcweir 			return m_seq.getLength() - nPos;
102cdf0e10cSrcweir 		}
closeInput()103cdf0e10cSrcweir     virtual void SAL_CALL closeInput(  )
104cdf0e10cSrcweir 		throw(NotConnectedException, IOException, RuntimeException)
105cdf0e10cSrcweir 		{
106cdf0e10cSrcweir 			// not needed
107cdf0e10cSrcweir 		}
108cdf0e10cSrcweir 	sal_Int32 nPos;
109cdf0e10cSrcweir 	Sequence< sal_Int8> m_seq;
110cdf0e10cSrcweir };
111cdf0e10cSrcweir 
112cdf0e10cSrcweir //-------------------------------
113cdf0e10cSrcweir // Helper : create an input stream from a file
114cdf0e10cSrcweir //------------------------------
createStreamFromFile(const char * pcFile)115cdf0e10cSrcweir Reference< XInputStream > createStreamFromFile(
116cdf0e10cSrcweir 	const char *pcFile )
117cdf0e10cSrcweir {
118cdf0e10cSrcweir 	FILE *f = fopen( pcFile , "rb" );
119cdf0e10cSrcweir 	Reference<  XInputStream >  r;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	if( f ) {
122cdf0e10cSrcweir 		fseek( f , 0 , SEEK_END );
123cdf0e10cSrcweir 		size_t nLength = ftell( f );
124cdf0e10cSrcweir 		fseek( f , 0 , SEEK_SET );
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 		Sequence<sal_Int8> seqIn(nLength);
127cdf0e10cSrcweir 		if (fread( seqIn.getArray() , nLength , 1 , f ) == 1)
128cdf0e10cSrcweir 			r = Reference< XInputStream > ( new OInputStream( seqIn ) );
129cdf0e10cSrcweir 		else
130cdf0e10cSrcweir 			fprintf(stderr, "failure reading %s\n", pcFile);
131cdf0e10cSrcweir 		fclose( f );
132cdf0e10cSrcweir 	}
133cdf0e10cSrcweir 	return r;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 
137cdf0e10cSrcweir class TestDocumentHandler :
138cdf0e10cSrcweir 	public WeakImplHelper3< XExtendedDocumentHandler , XEntityResolver , XErrorHandler >
139cdf0e10cSrcweir {
140cdf0e10cSrcweir public:
TestDocumentHandler(const char * locale,const char * outFile)141cdf0e10cSrcweir 	TestDocumentHandler(const char* locale, const char* outFile ) :
142cdf0e10cSrcweir       rootNode(0), nError(0), nbOfCurrencies(0), nbOfCalendars(0), nbOfFormatElements(0),
143cdf0e10cSrcweir       nbOfTransliterations(0), nbOfCollations(0), nbOfDays(50), nbOfMonths(50), nbOfEras(10),
144cdf0e10cSrcweir       flag(-1), of(outFile, locale), isStartDayOfWeek(false), foundDefaultName(false),
145cdf0e10cSrcweir       foundVariant(false), openElement(false)
146cdf0e10cSrcweir 	{
147cdf0e10cSrcweir         strncpy( theLocale, locale, sizeof(theLocale) );
148cdf0e10cSrcweir         theLocale[sizeof(theLocale)-1] = 0;
149cdf0e10cSrcweir 	}
150cdf0e10cSrcweir 
~TestDocumentHandler()151cdf0e10cSrcweir 	~TestDocumentHandler(  )
152cdf0e10cSrcweir 	{
153cdf0e10cSrcweir 		of.closeOutput();
154cdf0e10cSrcweir 	}
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 
157cdf0e10cSrcweir public: // Error handler
error(const Any & aSAXParseException)158cdf0e10cSrcweir     virtual void SAL_CALL error(const Any& aSAXParseException) throw (SAXException, RuntimeException)
159cdf0e10cSrcweir     {
160cdf0e10cSrcweir         ++nError;
161cdf0e10cSrcweir     	printf( "Error !\n" );
162cdf0e10cSrcweir     	throw  SAXException(
163cdf0e10cSrcweir 			OUString( RTL_CONSTASCII_USTRINGPARAM("error from error handler")) ,
164cdf0e10cSrcweir 			Reference < XInterface >() ,
165cdf0e10cSrcweir 			aSAXParseException );
166cdf0e10cSrcweir     }
fatalError(const Any &)167cdf0e10cSrcweir     virtual void SAL_CALL fatalError(const Any& /*aSAXParseException*/) throw (SAXException, RuntimeException)
168cdf0e10cSrcweir     {
169cdf0e10cSrcweir         ++nError;
170cdf0e10cSrcweir     	printf( "Fatal Error !\n" );
171cdf0e10cSrcweir     }
warning(const Any &)172cdf0e10cSrcweir     virtual void SAL_CALL warning(const Any& /*aSAXParseException*/) throw (SAXException, RuntimeException)
173cdf0e10cSrcweir     {
174cdf0e10cSrcweir     	printf( "Warning !\n" );
175cdf0e10cSrcweir     }
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 
178cdf0e10cSrcweir public: // ExtendedDocumentHandler
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 	stack<LocaleNode *> currentNode ;
183cdf0e10cSrcweir 	sal_Bool  fElement ;
184cdf0e10cSrcweir 	LocaleNode * rootNode;
185cdf0e10cSrcweir 
startDocument(void)186cdf0e10cSrcweir 	virtual void SAL_CALL startDocument(void) throw (SAXException, RuntimeException)
187cdf0e10cSrcweir     {
188cdf0e10cSrcweir 	printf( "parsing document %s started\n", theLocale);
189cdf0e10cSrcweir 	of.writeAsciiString("#include <sal/types.h>\n\n\n");
190cdf0e10cSrcweir 	of.writeAsciiString("#include <stdio.h> // debug printfs\n\n");
191cdf0e10cSrcweir 	of.writeAsciiString("extern \"C\" {\n\n");
192cdf0e10cSrcweir 	}
193cdf0e10cSrcweir 
endDocument(void)194cdf0e10cSrcweir     virtual void SAL_CALL endDocument(void) throw (SAXException, RuntimeException)
195cdf0e10cSrcweir     {
196cdf0e10cSrcweir 		if (rootNode)
197cdf0e10cSrcweir         {
198cdf0e10cSrcweir 			rootNode->generateCode(of);
199cdf0e10cSrcweir             int err = rootNode->getError();
200cdf0e10cSrcweir             if (err)
201cdf0e10cSrcweir             {
202cdf0e10cSrcweir                 printf( "Error: in data for %s: %d\n", theLocale, err);
203cdf0e10cSrcweir                 nError += err;
204cdf0e10cSrcweir             }
205cdf0e10cSrcweir         }
206cdf0e10cSrcweir         else
207cdf0e10cSrcweir         {
208cdf0e10cSrcweir             ++nError;
209cdf0e10cSrcweir             printf( "Error: no data for %s\n", theLocale);
210cdf0e10cSrcweir         }
211cdf0e10cSrcweir 		printf( "parsing document %s finished\n", theLocale);
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 		of.writeAsciiString("} // extern \"C\"\n\n");
214cdf0e10cSrcweir 		of.closeOutput();
215cdf0e10cSrcweir     }
216cdf0e10cSrcweir 
startElement(const OUString & aName,const Reference<XAttributeList> & xAttribs)217cdf0e10cSrcweir     virtual void SAL_CALL startElement(const OUString& aName,
218cdf0e10cSrcweir 							  const Reference< XAttributeList > & xAttribs)
219cdf0e10cSrcweir 		throw (SAXException,RuntimeException)
220cdf0e10cSrcweir 	{
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 		LocaleNode * l =  LocaleNode::createNode (aName, xAttribs);
223cdf0e10cSrcweir 		if (!currentNode.empty() ) {
224cdf0e10cSrcweir 			LocaleNode * ln = (LocaleNode *) currentNode . top();
225cdf0e10cSrcweir 			ln->addChild(l);
226cdf0e10cSrcweir 		} else {
227cdf0e10cSrcweir 			rootNode = l;
228cdf0e10cSrcweir 		}
229cdf0e10cSrcweir 		currentNode . push (l);
230cdf0e10cSrcweir 	}
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 
endElement(const OUString &)233cdf0e10cSrcweir 	virtual void SAL_CALL endElement(const OUString& /*aName*/) throw (SAXException,RuntimeException)
234cdf0e10cSrcweir     {
235cdf0e10cSrcweir     	currentNode . pop();
236cdf0e10cSrcweir     }
237cdf0e10cSrcweir 
characters(const OUString & aChars)238cdf0e10cSrcweir 	virtual void SAL_CALL characters(const OUString& aChars) throw (SAXException,RuntimeException)
239cdf0e10cSrcweir     {
240cdf0e10cSrcweir 
241cdf0e10cSrcweir     	LocaleNode * l = currentNode . top();
242cdf0e10cSrcweir     	l->setValue (aChars);
243cdf0e10cSrcweir 		::rtl::OUString str(aChars);
244cdf0e10cSrcweir 		sal_Unicode nonBreakSPace[2]= {0xa, 0x0};
245cdf0e10cSrcweir 		if(!openElement || str.equals(nonBreakSPace))
246cdf0e10cSrcweir 		  return;
247cdf0e10cSrcweir     }
248cdf0e10cSrcweir 
ignorableWhitespace(const OUString &)249cdf0e10cSrcweir 	virtual void SAL_CALL ignorableWhitespace(const OUString& /*aWhitespaces*/) throw (SAXException,RuntimeException)
250cdf0e10cSrcweir     {
251cdf0e10cSrcweir     }
252cdf0e10cSrcweir 
processingInstruction(const OUString &,const OUString &)253cdf0e10cSrcweir     virtual void SAL_CALL processingInstruction(const OUString& /*aTarget*/, const OUString& /*aData*/) throw (SAXException,RuntimeException)
254cdf0e10cSrcweir     {
255cdf0e10cSrcweir 		// ignored
256cdf0e10cSrcweir     }
257cdf0e10cSrcweir 
setDocumentLocator(const Reference<XLocator> &)258cdf0e10cSrcweir     virtual void SAL_CALL setDocumentLocator(const Reference< XLocator> & /*xLocator*/)
259cdf0e10cSrcweir 		throw (SAXException,RuntimeException)
260cdf0e10cSrcweir     {
261cdf0e10cSrcweir 		// ignored
262cdf0e10cSrcweir     }
263cdf0e10cSrcweir 
resolveEntity(const OUString & sPublicId,const OUString & sSystemId)264cdf0e10cSrcweir     virtual InputSource SAL_CALL resolveEntity(
265cdf0e10cSrcweir 		const OUString& sPublicId,
266cdf0e10cSrcweir 		const OUString& sSystemId)
267cdf0e10cSrcweir 		throw (RuntimeException)
268cdf0e10cSrcweir 	{
269cdf0e10cSrcweir 		InputSource source;
270cdf0e10cSrcweir 		source.sSystemId = sSystemId;
271cdf0e10cSrcweir 		source.sPublicId = sPublicId;
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 		source.aInputStream = createStreamFromFile(
274*24c56ab9SHerbert Dürr 			OUStringToOString( sSystemId.getStr(), RTL_TEXTENCODING_ASCII_US).getStr() );
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 		return source;
277cdf0e10cSrcweir 	}
278cdf0e10cSrcweir 
startCDATA(void)279cdf0e10cSrcweir     virtual void SAL_CALL startCDATA(void) throw (SAXException,RuntimeException)
280cdf0e10cSrcweir     {
281cdf0e10cSrcweir     }
endCDATA(void)282cdf0e10cSrcweir     virtual void SAL_CALL endCDATA(void) throw (RuntimeException)
283cdf0e10cSrcweir     {
284cdf0e10cSrcweir     }
comment(const OUString &)285cdf0e10cSrcweir     virtual void SAL_CALL comment(const OUString& /*sComment*/) throw (SAXException,RuntimeException)
286cdf0e10cSrcweir     {
287cdf0e10cSrcweir     }
unknown(const OUString &)288cdf0e10cSrcweir     virtual void SAL_CALL unknown(const OUString& /*sString*/) throw (SAXException,RuntimeException)
289cdf0e10cSrcweir     {
290cdf0e10cSrcweir     }
291cdf0e10cSrcweir 
allowLineBreak(void)292cdf0e10cSrcweir 	virtual void SAL_CALL allowLineBreak( void) throw (SAXException, RuntimeException )
293cdf0e10cSrcweir 	{
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 	}
296cdf0e10cSrcweir 
297cdf0e10cSrcweir public:
298cdf0e10cSrcweir     int nError;
299cdf0e10cSrcweir 	::rtl::OUString currentElement;
300cdf0e10cSrcweir 	sal_Int16 nbOfCurrencies;
301cdf0e10cSrcweir 	sal_Int16 nbOfCalendars;
302cdf0e10cSrcweir 	sal_Int16 nbOfFormatElements;
303cdf0e10cSrcweir 	sal_Int16 nbOfTransliterations;
304cdf0e10cSrcweir 	sal_Int16 nbOfCollations;
305cdf0e10cSrcweir 	Sequence<sal_Int16> nbOfDays;
306cdf0e10cSrcweir 	Sequence<sal_Int16> nbOfMonths;
307cdf0e10cSrcweir 	Sequence<sal_Int16> nbOfEras;
308cdf0e10cSrcweir 	sal_Char *elementTag;
309cdf0e10cSrcweir 	sal_Char theLocale[50];
310cdf0e10cSrcweir 	sal_Int16 flag;
311cdf0e10cSrcweir 	OFileWriter of;
312cdf0e10cSrcweir 	sal_Bool isStartDayOfWeek;
313cdf0e10cSrcweir 	sal_Bool foundDefaultName;
314cdf0e10cSrcweir 	sal_Bool foundVariant;
315cdf0e10cSrcweir         sal_Bool openElement;
316cdf0e10cSrcweir };
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 
SAL_IMPLEMENT_MAIN_WITH_ARGS(argc,argv)322cdf0e10cSrcweir SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
323cdf0e10cSrcweir {
324cdf0e10cSrcweir 	if( argc < 6) {
325cdf0e10cSrcweir 		printf( "usage : %s <locaLe> <XML inputfile> <destination file> <services.rdb location> <types.rdb location>\n", argv[0] );
326cdf0e10cSrcweir 		exit( 1 );
327cdf0e10cSrcweir 	}
328cdf0e10cSrcweir 
329cdf0e10cSrcweir 	// create service manager
330cdf0e10cSrcweir 	Reference< XMultiServiceFactory > xSMgr;
331cdf0e10cSrcweir 	try
332cdf0e10cSrcweir 	{
333cdf0e10cSrcweir 		xSMgr = createRegistryServiceFactory(
334cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(argv[4]),
335cdf0e10cSrcweir 			::rtl::OUString::createFromAscii(argv[5]), true );
336cdf0e10cSrcweir 	}
33727412a26SHerbert Dürr 	catch( const Exception& e)
338cdf0e10cSrcweir 	{
33927412a26SHerbert Dürr 		const OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8 );
34027412a26SHerbert Dürr 		printf( "Exception on createRegistryServiceFactory: \"%s\"\n", aMsg.getStr() );
341cdf0e10cSrcweir 		exit(1);
342cdf0e10cSrcweir 	}
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 	//--------------------------------
345cdf0e10cSrcweir 	// parser demo
346cdf0e10cSrcweir 	// read xml from a file and count elements
347cdf0e10cSrcweir 	//--------------------------------
348cdf0e10cSrcweir 	Reference< XInterface > x = xSMgr->createInstance(
349cdf0e10cSrcweir 		OUString::createFromAscii( "com.sun.star.xml.sax.Parser" ) );
350cdf0e10cSrcweir     int nError = 0;
351cdf0e10cSrcweir 	if( x.is() )
352cdf0e10cSrcweir 	{
353cdf0e10cSrcweir 		Reference< XParser > rParser( x , UNO_QUERY );
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 		// create and connect the document handler to the parser
356cdf0e10cSrcweir 		TestDocumentHandler *pDocHandler = new TestDocumentHandler( argv[1], argv[3]);
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 		Reference < XDocumentHandler >	rDocHandler( (XDocumentHandler *) pDocHandler );
359cdf0e10cSrcweir 		Reference< XEntityResolver > rEntityResolver( (XEntityResolver *) pDocHandler );
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 		rParser->setDocumentHandler( rDocHandler );
362cdf0e10cSrcweir 		rParser->setEntityResolver( rEntityResolver );
363cdf0e10cSrcweir 
364cdf0e10cSrcweir 		// create the input stream
365cdf0e10cSrcweir 		InputSource source;
366cdf0e10cSrcweir 		source.aInputStream = createStreamFromFile( argv[2] );
367cdf0e10cSrcweir 		source.sSystemId 	= OUString::createFromAscii( argv[2] );
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 		try
370cdf0e10cSrcweir 		{
371cdf0e10cSrcweir 			// start parsing
372cdf0e10cSrcweir 			rParser->parseStream( source );
373cdf0e10cSrcweir 		}
374cdf0e10cSrcweir 
37527412a26SHerbert Dürr 		catch( const Exception& e)
376cdf0e10cSrcweir 		{
37727412a26SHerbert Dürr 			const OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8 );
37827412a26SHerbert Dürr 			printf( "Exception during parsing : \"%s\"\n",  aMsg.getStr() );
379cdf0e10cSrcweir 			exit(1);
380cdf0e10cSrcweir 		}
381cdf0e10cSrcweir         nError = pDocHandler->nError;
382cdf0e10cSrcweir 	}
383cdf0e10cSrcweir 	else
384cdf0e10cSrcweir 	{
385cdf0e10cSrcweir 		printf( "couln't create sax-parser component\n" );
386cdf0e10cSrcweir 		exit(1);
387cdf0e10cSrcweir 	}
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 	return nError;
390cdf0e10cSrcweir }
391