1*06b3ce53SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*06b3ce53SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*06b3ce53SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*06b3ce53SAndrew Rist * distributed with this work for additional information
6*06b3ce53SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*06b3ce53SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*06b3ce53SAndrew Rist * "License"); you may not use this file except in compliance
9*06b3ce53SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*06b3ce53SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*06b3ce53SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*06b3ce53SAndrew Rist * software distributed under the License is distributed on an
15*06b3ce53SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*06b3ce53SAndrew Rist * KIND, either express or implied. See the License for the
17*06b3ce53SAndrew Rist * specific language governing permissions and limitations
18*06b3ce53SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*06b3ce53SAndrew Rist *************************************************************/
21*06b3ce53SAndrew Rist
22*06b3ce53SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmlsecurity.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <rtl/ustring.hxx>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include "saxhelper.hxx"
30cdf0e10cSrcweir #include "libxml/parserInternals.h"
31cdf0e10cSrcweir
32cdf0e10cSrcweir #ifndef XMLSEC_NO_XSLT
33cdf0e10cSrcweir #include "libxslt/xslt.h"
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir
36cdf0e10cSrcweir namespace cssu = com::sun::star::uno;
37cdf0e10cSrcweir namespace cssxs = com::sun::star::xml::sax;
38cdf0e10cSrcweir namespace cssxcsax = com::sun::star::xml::csax;
39cdf0e10cSrcweir
40cdf0e10cSrcweir /**
41cdf0e10cSrcweir * The return value is NULL terminated. The application has the responsibilty to
42cdf0e10cSrcweir * deallocte the return value.
43cdf0e10cSrcweir */
ous_to_xmlstr(const rtl::OUString & oustr)44cdf0e10cSrcweir xmlChar* ous_to_xmlstr( const rtl::OUString& oustr )
45cdf0e10cSrcweir {
46cdf0e10cSrcweir rtl::OString ostr = rtl::OUStringToOString( oustr , RTL_TEXTENCODING_UTF8 ) ;
47cdf0e10cSrcweir return xmlStrndup( ( xmlChar* )ostr.getStr(), ( int )ostr.getLength() ) ;
48cdf0e10cSrcweir }
49cdf0e10cSrcweir
50cdf0e10cSrcweir /**
51cdf0e10cSrcweir * The return value is NULL terminated. The application has the responsibilty to
52cdf0e10cSrcweir * deallocte the return value.
53cdf0e10cSrcweir */
ous_to_nxmlstr(const rtl::OUString & oustr,int & length)54cdf0e10cSrcweir xmlChar* ous_to_nxmlstr( const rtl::OUString& oustr, int& length )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir rtl::OString ostr = rtl::OUStringToOString( oustr , RTL_TEXTENCODING_UTF8 ) ;
57cdf0e10cSrcweir length = ostr.getLength();
58cdf0e10cSrcweir
59cdf0e10cSrcweir return xmlStrndup( ( xmlChar* )ostr.getStr(), length ) ;
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
62cdf0e10cSrcweir /**
63cdf0e10cSrcweir * The input parameter isn't necessaryly NULL terminated.
64cdf0e10cSrcweir */
xmlchar_to_ous(const xmlChar * pChar,int length)65cdf0e10cSrcweir rtl::OUString xmlchar_to_ous( const xmlChar* pChar, int length )
66cdf0e10cSrcweir {
67cdf0e10cSrcweir if( pChar != NULL )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir return rtl::OUString( ( sal_Char* )pChar , length , RTL_TEXTENCODING_UTF8 ) ;
70cdf0e10cSrcweir }
71cdf0e10cSrcweir else
72cdf0e10cSrcweir {
73cdf0e10cSrcweir return rtl::OUString() ;
74cdf0e10cSrcweir }
75cdf0e10cSrcweir }
76cdf0e10cSrcweir
77cdf0e10cSrcweir /**
78cdf0e10cSrcweir * The input parameter is NULL terminated
79cdf0e10cSrcweir */
xmlstr_to_ous(const xmlChar * pStr)80cdf0e10cSrcweir rtl::OUString xmlstr_to_ous( const xmlChar* pStr )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir if( pStr != NULL )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir return xmlchar_to_ous( pStr , xmlStrlen( pStr ) ) ;
85cdf0e10cSrcweir }
86cdf0e10cSrcweir else
87cdf0e10cSrcweir {
88cdf0e10cSrcweir return rtl::OUString() ;
89cdf0e10cSrcweir }
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
92cdf0e10cSrcweir /**
93cdf0e10cSrcweir * The return value and the referenced value must be NULL terminated.
94cdf0e10cSrcweir * The application has the responsibilty to deallocte the return value.
95cdf0e10cSrcweir */
attrlist_to_nxmlstr(const cssu::Sequence<cssxcsax::XMLAttribute> & aAttributes)96cdf0e10cSrcweir const xmlChar** attrlist_to_nxmlstr( const cssu::Sequence< cssxcsax::XMLAttribute >& aAttributes )
97cdf0e10cSrcweir {
98cdf0e10cSrcweir xmlChar* attname = NULL ;
99cdf0e10cSrcweir xmlChar* attvalue = NULL ;
100cdf0e10cSrcweir const xmlChar** attrs = NULL ;
101cdf0e10cSrcweir rtl::OUString oustr ;
102cdf0e10cSrcweir
103cdf0e10cSrcweir sal_Int32 nLength = aAttributes.getLength();;
104cdf0e10cSrcweir
105cdf0e10cSrcweir if( nLength != 0 )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir attrs = ( const xmlChar** )xmlMalloc( ( nLength * 2 + 2 ) * sizeof( xmlChar* ) ) ;
108cdf0e10cSrcweir }
109cdf0e10cSrcweir else
110cdf0e10cSrcweir {
111cdf0e10cSrcweir return NULL ;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
114cdf0e10cSrcweir for( int i = 0 , j = 0 ; j < nLength ; ++j )
115cdf0e10cSrcweir {
116cdf0e10cSrcweir attname = ous_to_xmlstr( aAttributes[j].sName ) ;
117cdf0e10cSrcweir attvalue = ous_to_xmlstr( aAttributes[j].sValue ) ;
118cdf0e10cSrcweir
119cdf0e10cSrcweir if( attname != NULL && attvalue != NULL )
120cdf0e10cSrcweir {
121cdf0e10cSrcweir attrs[i++] = attname ;
122cdf0e10cSrcweir attrs[i++] = attvalue ;
123cdf0e10cSrcweir attrs[i] = NULL ;
124cdf0e10cSrcweir attrs[i+1] = NULL ;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir else
127cdf0e10cSrcweir {
128cdf0e10cSrcweir if( attname != NULL )
129cdf0e10cSrcweir xmlFree( attname ) ;
130cdf0e10cSrcweir if( attvalue != NULL )
131cdf0e10cSrcweir xmlFree( attvalue ) ;
132cdf0e10cSrcweir }
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
135cdf0e10cSrcweir return attrs ;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
138cdf0e10cSrcweir /**
139cdf0e10cSrcweir * Constructor
140cdf0e10cSrcweir *
141cdf0e10cSrcweir * In this constructor, a libxml sax parser context is initialized. a libxml
142cdf0e10cSrcweir * default sax handler is initialized with the context.
143cdf0e10cSrcweir */
SAXHelper()144cdf0e10cSrcweir SAXHelper::SAXHelper( )
145cdf0e10cSrcweir : m_pParserCtxt( NULL ),
146cdf0e10cSrcweir m_pSaxHandler( NULL )
147cdf0e10cSrcweir {
148cdf0e10cSrcweir xmlInitParser() ;
149cdf0e10cSrcweir LIBXML_TEST_VERSION ;
150cdf0e10cSrcweir
151cdf0e10cSrcweir /*
152cdf0e10cSrcweir * compile error:
153cdf0e10cSrcweir * xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS ;
154cdf0e10cSrcweir */
155cdf0e10cSrcweir xmlSubstituteEntitiesDefault( 1 ) ;
156cdf0e10cSrcweir
157cdf0e10cSrcweir #ifndef XMLSEC_NO_XSLT
158cdf0e10cSrcweir xmlIndentTreeOutput = 1 ;
159cdf0e10cSrcweir #endif /* XMLSEC_NO_XSLT */
160cdf0e10cSrcweir
161cdf0e10cSrcweir m_pParserCtxt = xmlNewParserCtxt() ;
162cdf0e10cSrcweir
163cdf0e10cSrcweir /*
164cdf0e10cSrcweir * i41748
165cdf0e10cSrcweir *
166cdf0e10cSrcweir * mmi : re-initialize the SAX handler to version 1
167cdf0e10cSrcweir */
168cdf0e10cSrcweir
169cdf0e10cSrcweir xmlSAXVersion(m_pParserCtxt->sax, 1);
170cdf0e10cSrcweir
171cdf0e10cSrcweir /* end */
172cdf0e10cSrcweir
173cdf0e10cSrcweir if( m_pParserCtxt->inputTab[0] != NULL )
174cdf0e10cSrcweir {
175cdf0e10cSrcweir m_pParserCtxt->inputTab[0] = NULL ;
176cdf0e10cSrcweir }
177cdf0e10cSrcweir
178cdf0e10cSrcweir if( m_pParserCtxt == NULL )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir #ifndef XMLSEC_NO_XSLT
181cdf0e10cSrcweir xsltCleanupGlobals() ;
182cdf0e10cSrcweir #endif
183cdf0e10cSrcweir // see issue i74334, we cannot call xmlCleanupParser when libxml is still used
184cdf0e10cSrcweir // in other parts of the office.
185cdf0e10cSrcweir // xmlCleanupParser() ;
186cdf0e10cSrcweir throw cssu::RuntimeException() ;
187cdf0e10cSrcweir }
188cdf0e10cSrcweir else if( m_pParserCtxt->sax == NULL )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir xmlFreeParserCtxt( m_pParserCtxt ) ;
191cdf0e10cSrcweir
192cdf0e10cSrcweir #ifndef XMLSEC_NO_XSLT
193cdf0e10cSrcweir xsltCleanupGlobals() ;
194cdf0e10cSrcweir #endif
195cdf0e10cSrcweir // see issue i74334, we cannot call xmlCleanupParser when libxml is still used
196cdf0e10cSrcweir // in other parts of the office.
197cdf0e10cSrcweir // xmlCleanupParser() ;
198cdf0e10cSrcweir m_pParserCtxt = NULL ;
199cdf0e10cSrcweir throw cssu::RuntimeException() ;
200cdf0e10cSrcweir }
201cdf0e10cSrcweir else
202cdf0e10cSrcweir {
203cdf0e10cSrcweir m_pSaxHandler = m_pParserCtxt->sax ;
204cdf0e10cSrcweir
205cdf0e10cSrcweir //Adjust the context
206cdf0e10cSrcweir m_pParserCtxt->recovery = 1 ;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir }
209cdf0e10cSrcweir
210cdf0e10cSrcweir /**
211cdf0e10cSrcweir * Destructor
212cdf0e10cSrcweir *
213cdf0e10cSrcweir * In this destructor, a libxml sax parser context is desturcted. The XML tree
214cdf0e10cSrcweir * in the context is not deallocated because the tree is bind with a document
215cdf0e10cSrcweir * model by the setTargetDocument method, which delegate the target document to
216cdf0e10cSrcweir * destruct the xml tree.
217cdf0e10cSrcweir */
~SAXHelper()218cdf0e10cSrcweir SAXHelper::~SAXHelper() {
219cdf0e10cSrcweir if( m_pParserCtxt != NULL )
220cdf0e10cSrcweir {
221cdf0e10cSrcweir /*
222cdf0e10cSrcweir * In the situation that no object refer the Document, this destructor
223cdf0e10cSrcweir * must deallocate the Document memory
224cdf0e10cSrcweir */
225cdf0e10cSrcweir if( m_pSaxHandler == m_pParserCtxt->sax )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir m_pSaxHandler = NULL ;
228cdf0e10cSrcweir }
229cdf0e10cSrcweir
230cdf0e10cSrcweir xmlFreeParserCtxt( m_pParserCtxt ) ;
231cdf0e10cSrcweir m_pParserCtxt = NULL ;
232cdf0e10cSrcweir }
233cdf0e10cSrcweir
234cdf0e10cSrcweir if( m_pSaxHandler != NULL )
235cdf0e10cSrcweir {
236cdf0e10cSrcweir xmlFree( m_pSaxHandler ) ;
237cdf0e10cSrcweir m_pSaxHandler = NULL ;
238cdf0e10cSrcweir }
239cdf0e10cSrcweir // see issue i74334, we cannot call xmlCleanupParser when libxml is still used
240cdf0e10cSrcweir // in other parts of the office.
241cdf0e10cSrcweir // xmlCleanupParser() ;
242cdf0e10cSrcweir }
243cdf0e10cSrcweir
getCurrentNode()244cdf0e10cSrcweir xmlNodePtr SAXHelper::getCurrentNode()
245cdf0e10cSrcweir {
246cdf0e10cSrcweir return m_pParserCtxt->node;
247cdf0e10cSrcweir }
248cdf0e10cSrcweir
setCurrentNode(const xmlNodePtr pNode)249cdf0e10cSrcweir void SAXHelper::setCurrentNode(const xmlNodePtr pNode)
250cdf0e10cSrcweir {
251cdf0e10cSrcweir /*
252cdf0e10cSrcweir * This is really a black trick.
253cdf0e10cSrcweir * When the current node is replaced, the nodeTab
254cdf0e10cSrcweir * stack's top has to been replaced with the same
255cdf0e10cSrcweir * node, in order to make compatibility.
256cdf0e10cSrcweir */
257cdf0e10cSrcweir m_pParserCtxt->nodeTab[m_pParserCtxt->nodeNr - 1]
258cdf0e10cSrcweir = m_pParserCtxt->node
259cdf0e10cSrcweir = pNode;
260cdf0e10cSrcweir }
261cdf0e10cSrcweir
getDocument()262cdf0e10cSrcweir xmlDocPtr SAXHelper::getDocument()
263cdf0e10cSrcweir {
264cdf0e10cSrcweir return m_pParserCtxt->myDoc;
265cdf0e10cSrcweir }
266cdf0e10cSrcweir
267cdf0e10cSrcweir /**
268cdf0e10cSrcweir * XDocumentHandler -- start an xml document
269cdf0e10cSrcweir */
startDocument(void)270cdf0e10cSrcweir void SAXHelper::startDocument( void )
271cdf0e10cSrcweir throw( cssxs::SAXException , cssu::RuntimeException )
272cdf0e10cSrcweir {
273cdf0e10cSrcweir /*
274cdf0e10cSrcweir * Adjust inputTab
275cdf0e10cSrcweir */
276cdf0e10cSrcweir xmlParserInputPtr pInput = xmlNewInputStream( m_pParserCtxt ) ;
277cdf0e10cSrcweir
278cdf0e10cSrcweir if( m_pParserCtxt->inputTab != NULL && m_pParserCtxt->inputMax != 0 )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir m_pParserCtxt->inputTab[0] = pInput ;
281cdf0e10cSrcweir m_pParserCtxt->input = pInput ;
282cdf0e10cSrcweir }
283cdf0e10cSrcweir
284cdf0e10cSrcweir m_pSaxHandler->startDocument( m_pParserCtxt ) ;
285cdf0e10cSrcweir
286cdf0e10cSrcweir if( m_pParserCtxt == NULL || m_pParserCtxt->myDoc == NULL )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir throw cssu::RuntimeException() ;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir }
291cdf0e10cSrcweir
292cdf0e10cSrcweir /**
293cdf0e10cSrcweir * XDocumentHandler -- end an xml document
294cdf0e10cSrcweir */
endDocument(void)295cdf0e10cSrcweir void SAXHelper::endDocument( void )
296cdf0e10cSrcweir throw( cssxs::SAXException , cssu::RuntimeException )
297cdf0e10cSrcweir {
298cdf0e10cSrcweir m_pSaxHandler->endDocument( m_pParserCtxt ) ;
299cdf0e10cSrcweir }
300cdf0e10cSrcweir
301cdf0e10cSrcweir /**
302cdf0e10cSrcweir * XDocumentHandler -- start an xml element
303cdf0e10cSrcweir */
startElement(const rtl::OUString & aName,const cssu::Sequence<cssxcsax::XMLAttribute> & aAttributes)304cdf0e10cSrcweir void SAXHelper::startElement(
305cdf0e10cSrcweir const rtl::OUString& aName,
306cdf0e10cSrcweir const cssu::Sequence< cssxcsax::XMLAttribute >& aAttributes )
307cdf0e10cSrcweir throw( cssxs::SAXException , cssu::RuntimeException )
308cdf0e10cSrcweir {
309cdf0e10cSrcweir const xmlChar* fullName = NULL ;
310cdf0e10cSrcweir const xmlChar** attrs = NULL ;
311cdf0e10cSrcweir
312cdf0e10cSrcweir fullName = ous_to_xmlstr( aName ) ;
313cdf0e10cSrcweir attrs = attrlist_to_nxmlstr( aAttributes ) ;
314cdf0e10cSrcweir
315cdf0e10cSrcweir if( fullName != NULL || attrs != NULL )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir m_pSaxHandler->startElement( m_pParserCtxt , fullName , attrs ) ;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir
320cdf0e10cSrcweir if( fullName != NULL )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir xmlFree( ( xmlChar* )fullName ) ;
323cdf0e10cSrcweir fullName = NULL ;
324cdf0e10cSrcweir }
325cdf0e10cSrcweir
326cdf0e10cSrcweir if( attrs != NULL )
327cdf0e10cSrcweir {
328cdf0e10cSrcweir for( int i = 0 ; attrs[i] != NULL ; ++i )
329cdf0e10cSrcweir {
330cdf0e10cSrcweir xmlFree( ( xmlChar* )attrs[i] ) ;
331cdf0e10cSrcweir attrs[i] = NULL ;
332cdf0e10cSrcweir }
333cdf0e10cSrcweir
334cdf0e10cSrcweir xmlFree( ( void* ) attrs ) ;
335cdf0e10cSrcweir attrs = NULL ;
336cdf0e10cSrcweir }
337cdf0e10cSrcweir }
338cdf0e10cSrcweir
339cdf0e10cSrcweir /**
340cdf0e10cSrcweir * XDocumentHandler -- end an xml element
341cdf0e10cSrcweir */
endElement(const rtl::OUString & aName)342cdf0e10cSrcweir void SAXHelper::endElement( const rtl::OUString& aName )
343cdf0e10cSrcweir throw( cssxs::SAXException , cssu::RuntimeException )
344cdf0e10cSrcweir {
345cdf0e10cSrcweir xmlChar* fullname = NULL ;
346cdf0e10cSrcweir
347cdf0e10cSrcweir fullname = ous_to_xmlstr( aName ) ;
348cdf0e10cSrcweir m_pSaxHandler->endElement( m_pParserCtxt , fullname ) ;
349cdf0e10cSrcweir
350cdf0e10cSrcweir if( fullname != NULL )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir xmlFree( ( xmlChar* )fullname ) ;
353cdf0e10cSrcweir fullname = NULL ;
354cdf0e10cSrcweir }
355cdf0e10cSrcweir }
356cdf0e10cSrcweir
357cdf0e10cSrcweir /**
358cdf0e10cSrcweir * XDocumentHandler -- an xml element or cdata characters
359cdf0e10cSrcweir */
characters(const rtl::OUString & aChars)360cdf0e10cSrcweir void SAXHelper::characters( const rtl::OUString& aChars )
361cdf0e10cSrcweir throw( cssxs::SAXException , cssu::RuntimeException )
362cdf0e10cSrcweir {
363cdf0e10cSrcweir const xmlChar* chars = NULL ;
364cdf0e10cSrcweir int length = 0 ;
365cdf0e10cSrcweir
366cdf0e10cSrcweir chars = ous_to_nxmlstr( aChars, length ) ;
367cdf0e10cSrcweir m_pSaxHandler->characters( m_pParserCtxt , chars , length ) ;
368cdf0e10cSrcweir
369cdf0e10cSrcweir if( chars != NULL )
370cdf0e10cSrcweir {
371cdf0e10cSrcweir xmlFree( ( xmlChar* )chars ) ;
372cdf0e10cSrcweir }
373cdf0e10cSrcweir }
374cdf0e10cSrcweir
375cdf0e10cSrcweir /**
376cdf0e10cSrcweir * XDocumentHandler -- ignorable xml white space
377cdf0e10cSrcweir */
ignorableWhitespace(const rtl::OUString & aWhitespaces)378cdf0e10cSrcweir void SAXHelper::ignorableWhitespace( const rtl::OUString& aWhitespaces )
379cdf0e10cSrcweir throw( cssxs::SAXException , cssu::RuntimeException )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir const xmlChar* chars = NULL ;
382cdf0e10cSrcweir int length = 0 ;
383cdf0e10cSrcweir
384cdf0e10cSrcweir chars = ous_to_nxmlstr( aWhitespaces, length ) ;
385cdf0e10cSrcweir m_pSaxHandler->ignorableWhitespace( m_pParserCtxt , chars , length ) ;
386cdf0e10cSrcweir
387cdf0e10cSrcweir if( chars != NULL )
388cdf0e10cSrcweir {
389cdf0e10cSrcweir xmlFree( ( xmlChar* )chars ) ;
390cdf0e10cSrcweir }
391cdf0e10cSrcweir }
392cdf0e10cSrcweir
393cdf0e10cSrcweir /**
394cdf0e10cSrcweir * XDocumentHandler -- preaorocessing instruction
395cdf0e10cSrcweir */
processingInstruction(const rtl::OUString & aTarget,const rtl::OUString & aData)396cdf0e10cSrcweir void SAXHelper::processingInstruction(
397cdf0e10cSrcweir const rtl::OUString& aTarget,
398cdf0e10cSrcweir const rtl::OUString& aData )
399cdf0e10cSrcweir throw( cssxs::SAXException , cssu::RuntimeException )
400cdf0e10cSrcweir {
401cdf0e10cSrcweir xmlChar* target = NULL ;
402cdf0e10cSrcweir xmlChar* data = NULL ;
403cdf0e10cSrcweir
404cdf0e10cSrcweir target = ous_to_xmlstr( aTarget ) ;
405cdf0e10cSrcweir data = ous_to_xmlstr( aData ) ;
406cdf0e10cSrcweir
407cdf0e10cSrcweir m_pSaxHandler->processingInstruction( m_pParserCtxt , target , data ) ;
408cdf0e10cSrcweir
409cdf0e10cSrcweir if( target != NULL )
410cdf0e10cSrcweir {
411cdf0e10cSrcweir xmlFree( ( xmlChar* )target ) ;
412cdf0e10cSrcweir target = NULL ;
413cdf0e10cSrcweir }
414cdf0e10cSrcweir
415cdf0e10cSrcweir if( data != NULL )
416cdf0e10cSrcweir {
417cdf0e10cSrcweir xmlFree( ( xmlChar* )data ) ;
418cdf0e10cSrcweir data = NULL ;
419cdf0e10cSrcweir }
420cdf0e10cSrcweir }
421cdf0e10cSrcweir
422cdf0e10cSrcweir /**
423cdf0e10cSrcweir * XDocumentHandler -- set document locator
424cdf0e10cSrcweir * In this case, locator is useless.
425cdf0e10cSrcweir */
setDocumentLocator(const cssu::Reference<cssxs::XLocator> &)426cdf0e10cSrcweir void SAXHelper::setDocumentLocator(
427cdf0e10cSrcweir const cssu::Reference< cssxs::XLocator > &)
428cdf0e10cSrcweir throw( cssxs::SAXException , cssu::RuntimeException )
429cdf0e10cSrcweir {
430cdf0e10cSrcweir //--Pseudo code if necessary
431cdf0e10cSrcweir //--m_pSaxLocator is a member defined as xmlSAXHabdlerPtr
432cdf0e10cSrcweir //--m_pSaxLocatorHdl is a member defined as Sax_Locator
433cdf0e10cSrcweir
434cdf0e10cSrcweir //if( m_pSaxLocator != NULL ) {
435cdf0e10cSrcweir // //Deallocate the memory
436cdf0e10cSrcweir //}
437cdf0e10cSrcweir //if( m_pSaxLocatorHdl != NULL ) {
438cdf0e10cSrcweir // //Deallocate the memory
439cdf0e10cSrcweir //}
440cdf0e10cSrcweir
441cdf0e10cSrcweir //m_pSaxLocatorHdl = new Sax_Locator( xLocator ) ;
442cdf0e10cSrcweir //m_pSaxLocator = { m_pSaxLocatorHdl->getPublicId , m_pSaxLocatorHdl->getSystemId , m_pSaxLocatorHdl->getLineNumber , m_pSaxLocatorHdl->getColumnNumber } ;
443cdf0e10cSrcweir
444cdf0e10cSrcweir //m_pSaxHandler->setDocumentLocator( m_pParserCtxt , m_pSaxLocator ) ;
445cdf0e10cSrcweir }
446cdf0e10cSrcweir
447