2 * SAX Reader implementation
4 * Copyright 2008 Alistair Leslie-Hughes
5 * Copyright 2008 Piotr Caban
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
38 #include "wine/debug.h"
40 #include "msxml_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
46 #include <libxml/SAX2.h>
48 typedef struct _saxreader
50 const struct IVBSAXXMLReaderVtbl *lpVtbl;
51 const struct ISAXXMLReaderVtbl *lpSAXXMLReaderVtbl;
53 struct ISAXContentHandler *contentHandler;
54 struct ISAXErrorHandler *errorHandler;
58 typedef struct _saxlocator
60 const struct ISAXLocatorVtbl *lpSAXLocatorVtbl;
64 xmlParserCtxtPtr pParserCtxt;
69 static inline saxreader *impl_from_IVBSAXXMLReader( IVBSAXXMLReader *iface )
71 return (saxreader *)((char*)iface - FIELD_OFFSET(saxreader, lpVtbl));
74 static inline saxreader *impl_from_ISAXXMLReader( ISAXXMLReader *iface )
76 return (saxreader *)((char*)iface - FIELD_OFFSET(saxreader, lpSAXXMLReaderVtbl));
79 static inline saxlocator *impl_from_ISAXLocator( ISAXLocator *iface )
81 return (saxlocator *)((char*)iface - FIELD_OFFSET(saxlocator, lpSAXLocatorVtbl));
84 /*** LibXML callbacks ***/
85 static void libxmlStartDocument(void *ctx)
87 saxlocator *This = ctx;
90 if(This->saxreader->contentHandler)
92 hr = ISAXContentHandler_startDocument(This->saxreader->contentHandler);
95 xmlStopParser(This->pParserCtxt);
100 This->lastColumn = xmlSAX2GetColumnNumber(This->pParserCtxt);
101 This->lastLine = xmlSAX2GetLineNumber(This->pParserCtxt);
104 static void libxmlEndDocument(void *ctx)
106 saxlocator *This = ctx;
109 This->lastColumn = 0;
112 if(This->saxreader->contentHandler)
114 hr = ISAXContentHandler_endDocument(This->saxreader->contentHandler);
117 xmlStopParser(This->pParserCtxt);
123 static void libxmlStartElementNS(
125 const xmlChar *localname,
126 const xmlChar *prefix,
129 const xmlChar **namespaces,
132 const xmlChar **attributes)
134 BSTR NamespaceUri, LocalName, QName;
135 saxlocator *This = ctx;
138 FIXME("Arguments processing not yet implemented.\n");
140 This->lastColumn = xmlSAX2GetColumnNumber(This->pParserCtxt)+1;
141 This->lastLine = xmlSAX2GetLineNumber(This->pParserCtxt);
143 if(This->saxreader->contentHandler)
145 NamespaceUri = bstr_from_xmlChar(URI);
146 LocalName = bstr_from_xmlChar(localname);
147 QName = bstr_from_xmlChar(localname);
149 hr = ISAXContentHandler_startElement(
150 This->saxreader->contentHandler,
151 NamespaceUri, SysStringLen(NamespaceUri),
152 LocalName, SysStringLen(LocalName),
153 QName, SysStringLen(QName),
156 SysFreeString(NamespaceUri);
157 SysFreeString(LocalName);
158 SysFreeString(QName);
162 xmlStopParser(This->pParserCtxt);
168 /*** ISAXLocator interface ***/
169 /*** IUnknown methods ***/
170 static HRESULT WINAPI isaxlocator_QueryInterface(ISAXLocator* iface, REFIID riid, void **ppvObject)
172 saxlocator *This = impl_from_ISAXLocator( iface );
174 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
178 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
179 IsEqualGUID( riid, &IID_ISAXLocator ))
185 FIXME("interface %s not implemented\n", debugstr_guid(riid));
186 return E_NOINTERFACE;
189 ISAXLocator_AddRef( iface );
194 static ULONG WINAPI isaxlocator_AddRef(ISAXLocator* iface)
196 saxlocator *This = impl_from_ISAXLocator( iface );
197 TRACE("%p\n", This );
198 return InterlockedIncrement( &This->ref );
201 static ULONG WINAPI isaxlocator_Release(
204 saxlocator *This = impl_from_ISAXLocator( iface );
207 TRACE("%p\n", This );
209 ref = InterlockedDecrement( &This->ref );
212 ISAXXMLReader_Release((ISAXXMLReader*)&This->saxreader->lpSAXXMLReaderVtbl);
213 HeapFree( GetProcessHeap(), 0, This );
219 /*** ISAXLocator methods ***/
220 static HRESULT WINAPI isaxlocator_getColumnNumber(
224 saxlocator *This = impl_from_ISAXLocator( iface );
226 *pnColumn = This->lastColumn;
230 static HRESULT WINAPI isaxlocator_getLineNumber(
234 saxlocator *This = impl_from_ISAXLocator( iface );
236 *pnLine = This->lastLine;
240 static HRESULT WINAPI isaxlocator_getPublicId(
242 const WCHAR ** ppwchPublicId)
244 saxlocator *This = impl_from_ISAXLocator( iface );
246 FIXME("(%p)->(%p) stub\n", This, ppwchPublicId);
250 static HRESULT WINAPI isaxlocator_getSystemId(
252 const WCHAR ** ppwchSystemId)
254 saxlocator *This = impl_from_ISAXLocator( iface );
256 FIXME("(%p)->(%p) stub\n", This, ppwchSystemId);
260 static const struct ISAXLocatorVtbl isaxlocator_vtbl =
262 isaxlocator_QueryInterface,
265 isaxlocator_getColumnNumber,
266 isaxlocator_getLineNumber,
267 isaxlocator_getPublicId,
268 isaxlocator_getSystemId
271 static HRESULT SAXLocator_create(saxreader *reader, saxlocator **ppsaxlocator)
275 locator = HeapAlloc( GetProcessHeap(), 0, sizeof (*locator) );
277 return E_OUTOFMEMORY;
279 locator->lpSAXLocatorVtbl = &isaxlocator_vtbl;
282 locator->saxreader = reader;
283 ISAXXMLReader_AddRef((ISAXXMLReader*)&reader->lpSAXXMLReaderVtbl);
285 locator->pParserCtxt = NULL;
286 locator->lastLine = 0;
287 locator->lastColumn = 0;
290 *ppsaxlocator = locator;
292 TRACE("returning %p\n", *ppsaxlocator);
297 /*** IVBSAXXMLReader interface ***/
298 /*** IUnknown methods ***/
299 static HRESULT WINAPI saxxmlreader_QueryInterface(IVBSAXXMLReader* iface, REFIID riid, void **ppvObject)
301 saxreader *This = impl_from_IVBSAXXMLReader( iface );
303 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
307 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
308 IsEqualGUID( riid, &IID_IDispatch ) ||
309 IsEqualGUID( riid, &IID_IVBSAXXMLReader ))
313 else if( IsEqualGUID( riid, &IID_ISAXXMLReader ))
315 *ppvObject = (ISAXXMLReader*)&This->lpSAXXMLReaderVtbl;
319 FIXME("interface %s not implemented\n", debugstr_guid(riid));
320 return E_NOINTERFACE;
323 IVBSAXXMLReader_AddRef( iface );
328 static ULONG WINAPI saxxmlreader_AddRef(IVBSAXXMLReader* iface)
330 saxreader *This = impl_from_IVBSAXXMLReader( iface );
331 TRACE("%p\n", This );
332 return InterlockedIncrement( &This->ref );
335 static ULONG WINAPI saxxmlreader_Release(
336 IVBSAXXMLReader* iface)
338 saxreader *This = impl_from_IVBSAXXMLReader( iface );
341 TRACE("%p\n", This );
343 ref = InterlockedDecrement( &This->ref );
346 if(This->contentHandler)
347 ISAXContentHandler_Release(This->contentHandler);
349 if(This->errorHandler)
350 ISAXErrorHandler_Release(This->errorHandler);
352 HeapFree( GetProcessHeap(), 0, This );
358 static HRESULT WINAPI saxxmlreader_GetTypeInfoCount( IVBSAXXMLReader *iface, UINT* pctinfo )
360 saxreader *This = impl_from_IVBSAXXMLReader( iface );
362 TRACE("(%p)->(%p)\n", This, pctinfo);
369 static HRESULT WINAPI saxxmlreader_GetTypeInfo(
370 IVBSAXXMLReader *iface,
371 UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
373 saxreader *This = impl_from_IVBSAXXMLReader( iface );
376 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
378 hr = get_typeinfo(IVBSAXXMLReader_tid, ppTInfo);
383 static HRESULT WINAPI saxxmlreader_GetIDsOfNames(
384 IVBSAXXMLReader *iface,
391 saxreader *This = impl_from_IVBSAXXMLReader( iface );
395 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
398 if(!rgszNames || cNames == 0 || !rgDispId)
401 hr = get_typeinfo(IVBSAXXMLReader_tid, &typeinfo);
404 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
405 ITypeInfo_Release(typeinfo);
411 static HRESULT WINAPI saxxmlreader_Invoke(
412 IVBSAXXMLReader *iface,
417 DISPPARAMS* pDispParams,
419 EXCEPINFO* pExcepInfo,
422 saxreader *This = impl_from_IVBSAXXMLReader( iface );
426 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
427 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
429 hr = get_typeinfo(IVBSAXXMLReader_tid, &typeinfo);
432 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
433 pVarResult, pExcepInfo, puArgErr);
434 ITypeInfo_Release(typeinfo);
440 /*** IVBSAXXMLReader methods ***/
441 static HRESULT WINAPI saxxmlreader_getFeature(
442 IVBSAXXMLReader* iface,
443 const WCHAR *pFeature,
444 VARIANT_BOOL *pValue)
446 saxreader *This = impl_from_IVBSAXXMLReader( iface );
448 FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(pFeature), pValue);
452 static HRESULT WINAPI saxxmlreader_putFeature(
453 IVBSAXXMLReader* iface,
454 const WCHAR *pFeature,
455 VARIANT_BOOL vfValue)
457 saxreader *This = impl_from_IVBSAXXMLReader( iface );
459 FIXME("(%p)->(%s %x) stub\n", This, debugstr_w(pFeature), vfValue);
463 static HRESULT WINAPI saxxmlreader_getProperty(
464 IVBSAXXMLReader* iface,
468 saxreader *This = impl_from_IVBSAXXMLReader( iface );
470 FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(pProp), pValue);
474 static HRESULT WINAPI saxxmlreader_putProperty(
475 IVBSAXXMLReader* iface,
479 saxreader *This = impl_from_IVBSAXXMLReader( iface );
481 FIXME("(%p)->(%s) stub\n", This, debugstr_w(pProp));
485 static HRESULT WINAPI saxxmlreader_getEntityResolver(
486 IVBSAXXMLReader* iface,
487 IVBSAXEntityResolver **pEntityResolver)
489 saxreader *This = impl_from_IVBSAXXMLReader( iface );
491 FIXME("(%p)->(%p) stub\n", This, pEntityResolver);
495 static HRESULT WINAPI saxxmlreader_putEntityResolver(
496 IVBSAXXMLReader* iface,
497 IVBSAXEntityResolver *pEntityResolver)
499 saxreader *This = impl_from_IVBSAXXMLReader( iface );
501 FIXME("(%p)->(%p) stub\n", This, pEntityResolver);
505 static HRESULT WINAPI saxxmlreader_getContentHandler(
506 IVBSAXXMLReader* iface,
507 IVBSAXContentHandler **ppContentHandler)
509 saxreader *This = impl_from_IVBSAXXMLReader( iface );
511 FIXME("(%p)->(%p) stub\n", This, ppContentHandler);
515 static HRESULT WINAPI saxxmlreader_putContentHandler(
516 IVBSAXXMLReader* iface,
517 IVBSAXContentHandler *contentHandler)
519 saxreader *This = impl_from_IVBSAXXMLReader( iface );
521 FIXME("(%p)->(%p) stub\n", This, contentHandler);
525 static HRESULT WINAPI saxxmlreader_getDTDHandler(
526 IVBSAXXMLReader* iface,
527 IVBSAXDTDHandler **pDTDHandler)
529 saxreader *This = impl_from_IVBSAXXMLReader( iface );
531 FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
535 static HRESULT WINAPI saxxmlreader_putDTDHandler(
536 IVBSAXXMLReader* iface,
537 IVBSAXDTDHandler *pDTDHandler)
539 saxreader *This = impl_from_IVBSAXXMLReader( iface );
541 FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
545 static HRESULT WINAPI saxxmlreader_getErrorHandler(
546 IVBSAXXMLReader* iface,
547 IVBSAXErrorHandler **pErrorHandler)
549 saxreader *This = impl_from_IVBSAXXMLReader( iface );
551 FIXME("(%p)->(%p) stub\n", This, pErrorHandler);
555 static HRESULT WINAPI saxxmlreader_putErrorHandler(
556 IVBSAXXMLReader* iface,
557 IVBSAXErrorHandler *errorHandler)
559 saxreader *This = impl_from_IVBSAXXMLReader( iface );
561 FIXME("(%p)->(%p) stub\n", This, errorHandler);
565 static HRESULT WINAPI saxxmlreader_getBaseURL(
566 IVBSAXXMLReader* iface,
567 const WCHAR **pBaseUrl)
569 saxreader *This = impl_from_IVBSAXXMLReader( iface );
571 FIXME("(%p)->(%p) stub\n", This, pBaseUrl);
575 static HRESULT WINAPI saxxmlreader_putBaseURL(
576 IVBSAXXMLReader* iface,
577 const WCHAR *pBaseUrl)
579 saxreader *This = impl_from_IVBSAXXMLReader( iface );
581 FIXME("(%p)->(%s) stub\n", This, debugstr_w(pBaseUrl));
585 static HRESULT WINAPI saxxmlreader_getSecureBaseURL(
586 IVBSAXXMLReader* iface,
587 const WCHAR **pSecureBaseUrl)
589 saxreader *This = impl_from_IVBSAXXMLReader( iface );
591 FIXME("(%p)->(%p) stub\n", This, pSecureBaseUrl);
596 static HRESULT WINAPI saxxmlreader_putSecureBaseURL(
597 IVBSAXXMLReader* iface,
598 const WCHAR *secureBaseUrl)
600 saxreader *This = impl_from_IVBSAXXMLReader( iface );
602 FIXME("(%p)->(%s) stub\n", This, debugstr_w(secureBaseUrl));
606 static HRESULT WINAPI saxxmlreader_parse(
607 IVBSAXXMLReader* iface,
610 saxreader *This = impl_from_IVBSAXXMLReader( iface );
612 FIXME("(%p) stub\n", This);
616 static HRESULT WINAPI saxxmlreader_parseURL(
617 IVBSAXXMLReader* iface,
620 saxreader *This = impl_from_IVBSAXXMLReader( iface );
622 FIXME("(%p)->(%s) stub\n", This, debugstr_w(url));
626 static const struct IVBSAXXMLReaderVtbl saxreader_vtbl =
628 saxxmlreader_QueryInterface,
630 saxxmlreader_Release,
631 saxxmlreader_GetTypeInfoCount,
632 saxxmlreader_GetTypeInfo,
633 saxxmlreader_GetIDsOfNames,
635 saxxmlreader_getFeature,
636 saxxmlreader_putFeature,
637 saxxmlreader_getProperty,
638 saxxmlreader_putProperty,
639 saxxmlreader_getEntityResolver,
640 saxxmlreader_putEntityResolver,
641 saxxmlreader_getContentHandler,
642 saxxmlreader_putContentHandler,
643 saxxmlreader_getDTDHandler,
644 saxxmlreader_putDTDHandler,
645 saxxmlreader_getErrorHandler,
646 saxxmlreader_putErrorHandler,
647 saxxmlreader_getBaseURL,
648 saxxmlreader_putBaseURL,
649 saxxmlreader_getSecureBaseURL,
650 saxxmlreader_putSecureBaseURL,
652 saxxmlreader_parseURL
655 /*** ISAXXMLReader interface ***/
656 /*** IUnknown methods ***/
657 static HRESULT WINAPI isaxxmlreader_QueryInterface(ISAXXMLReader* iface, REFIID riid, void **ppvObject)
659 saxreader *This = impl_from_ISAXXMLReader( iface );
660 return saxxmlreader_QueryInterface((IVBSAXXMLReader*)&This->lpVtbl, riid, ppvObject);
663 static ULONG WINAPI isaxxmlreader_AddRef(ISAXXMLReader* iface)
665 saxreader *This = impl_from_ISAXXMLReader( iface );
666 return saxxmlreader_AddRef((IVBSAXXMLReader*)&This->lpVtbl);
669 static ULONG WINAPI isaxxmlreader_Release(ISAXXMLReader* iface)
671 saxreader *This = impl_from_ISAXXMLReader( iface );
672 return saxxmlreader_Release((IVBSAXXMLReader*)&This->lpVtbl);
675 /*** ISAXXMLReader methods ***/
676 static HRESULT WINAPI isaxxmlreader_getFeature(
677 ISAXXMLReader* iface,
678 const WCHAR *pFeature,
679 VARIANT_BOOL *pValue)
681 saxreader *This = impl_from_ISAXXMLReader( iface );
683 FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(pFeature), pValue);
687 static HRESULT WINAPI isaxxmlreader_putFeature(
688 ISAXXMLReader* iface,
689 const WCHAR *pFeature,
690 VARIANT_BOOL vfValue)
692 saxreader *This = impl_from_ISAXXMLReader( iface );
694 FIXME("(%p)->(%s %x) stub\n", This, debugstr_w(pFeature), vfValue);
698 static HRESULT WINAPI isaxxmlreader_getProperty(
699 ISAXXMLReader* iface,
703 saxreader *This = impl_from_ISAXXMLReader( iface );
705 FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(pProp), pValue);
709 static HRESULT WINAPI isaxxmlreader_putProperty(
710 ISAXXMLReader* iface,
714 saxreader *This = impl_from_ISAXXMLReader( iface );
716 FIXME("(%p)->(%s) stub\n", This, debugstr_w(pProp));
720 static HRESULT WINAPI isaxxmlreader_getEntityResolver(
721 ISAXXMLReader* iface,
722 ISAXEntityResolver **ppEntityResolver)
724 saxreader *This = impl_from_ISAXXMLReader( iface );
726 FIXME("(%p)->(%p) stub\n", This, ppEntityResolver);
730 static HRESULT WINAPI isaxxmlreader_putEntityResolver(
731 ISAXXMLReader* iface,
732 ISAXEntityResolver *pEntityResolver)
734 saxreader *This = impl_from_ISAXXMLReader( iface );
736 FIXME("(%p)->(%p) stub\n", This, pEntityResolver);
740 static HRESULT WINAPI isaxxmlreader_getContentHandler(
741 ISAXXMLReader* iface,
742 ISAXContentHandler **pContentHandler)
744 saxreader *This = impl_from_ISAXXMLReader( iface );
746 TRACE("(%p)->(%p)\n", This, pContentHandler);
747 if(pContentHandler == NULL)
749 if(This->contentHandler)
750 ISAXContentHandler_AddRef(This->contentHandler);
751 *pContentHandler = This->contentHandler;
756 static HRESULT WINAPI isaxxmlreader_putContentHandler(
757 ISAXXMLReader* iface,
758 ISAXContentHandler *contentHandler)
760 saxreader *This = impl_from_ISAXXMLReader( iface );
762 TRACE("(%p)->(%p)\n", This, contentHandler);
764 ISAXContentHandler_AddRef(contentHandler);
765 if(This->contentHandler)
766 ISAXContentHandler_Release(This->contentHandler);
767 This->contentHandler = contentHandler;
772 static HRESULT WINAPI isaxxmlreader_getDTDHandler(
773 ISAXXMLReader* iface,
774 ISAXDTDHandler **pDTDHandler)
776 saxreader *This = impl_from_ISAXXMLReader( iface );
778 FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
782 static HRESULT WINAPI isaxxmlreader_putDTDHandler(
783 ISAXXMLReader* iface,
784 ISAXDTDHandler *pDTDHandler)
786 saxreader *This = impl_from_ISAXXMLReader( iface );
788 FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
792 static HRESULT WINAPI isaxxmlreader_getErrorHandler(
793 ISAXXMLReader* iface,
794 ISAXErrorHandler **pErrorHandler)
796 saxreader *This = impl_from_ISAXXMLReader( iface );
798 TRACE("(%p)->(%p)\n", This, pErrorHandler);
799 if(pErrorHandler == NULL)
801 if(This->errorHandler)
802 ISAXErrorHandler_AddRef(This->errorHandler);
803 *pErrorHandler = This->errorHandler;
808 static HRESULT WINAPI isaxxmlreader_putErrorHandler(
809 ISAXXMLReader* iface,
810 ISAXErrorHandler *errorHandler)
812 saxreader *This = impl_from_ISAXXMLReader( iface );
814 TRACE("(%p)->(%p)\n", This, errorHandler);
816 ISAXErrorHandler_AddRef(errorHandler);
817 if(This->errorHandler)
818 ISAXErrorHandler_Release(This->errorHandler);
819 This->errorHandler = errorHandler;
824 static HRESULT WINAPI isaxxmlreader_getBaseURL(
825 ISAXXMLReader* iface,
826 const WCHAR **pBaseUrl)
828 saxreader *This = impl_from_ISAXXMLReader( iface );
830 FIXME("(%p)->(%p) stub\n", This, pBaseUrl);
834 static HRESULT WINAPI isaxxmlreader_putBaseURL(
835 ISAXXMLReader* iface,
836 const WCHAR *pBaseUrl)
838 saxreader *This = impl_from_ISAXXMLReader( iface );
840 FIXME("(%p)->(%s) stub\n", This, debugstr_w(pBaseUrl));
844 static HRESULT WINAPI isaxxmlreader_getSecureBaseURL(
845 ISAXXMLReader* iface,
846 const WCHAR **pSecureBaseUrl)
848 saxreader *This = impl_from_ISAXXMLReader( iface );
850 FIXME("(%p)->(%p) stub\n", This, pSecureBaseUrl);
854 static HRESULT WINAPI isaxxmlreader_putSecureBaseURL(
855 ISAXXMLReader* iface,
856 const WCHAR *secureBaseUrl)
858 saxreader *This = impl_from_ISAXXMLReader( iface );
860 FIXME("(%p)->(%s) stub\n", This, debugstr_w(secureBaseUrl));
864 static HRESULT WINAPI isaxxmlreader_parse(
865 ISAXXMLReader* iface,
868 saxreader *This = impl_from_ISAXXMLReader( iface );
870 xmlChar *data = NULL;
873 FIXME("(%p) semi-stub\n", This);
875 hr = SAXLocator_create(This, &locator);
880 switch(V_VT(&varInput))
883 locator->pParserCtxt = xmlNewParserCtxt();
884 if(!locator->pParserCtxt)
889 data = xmlChar_from_wchar(V_BSTR(&varInput));
890 xmlSetupParserForBuffer(locator->pParserCtxt, data, NULL);
892 locator->pParserCtxt->sax = &locator->saxreader->sax;
893 locator->pParserCtxt->userData = locator;
895 if(xmlParseDocument(locator->pParserCtxt)) hr = E_FAIL;
896 else hr = locator->ret;
902 if(locator->pParserCtxt)
904 locator->pParserCtxt->sax = NULL;
905 xmlFreeParserCtxt(locator->pParserCtxt);
906 locator->pParserCtxt = NULL;
908 if(data) HeapFree(GetProcessHeap(), 0, data);
909 ISAXLocator_Release((ISAXLocator*)&locator->lpSAXLocatorVtbl);
913 static HRESULT WINAPI isaxxmlreader_parseURL(
914 ISAXXMLReader* iface,
917 saxreader *This = impl_from_ISAXXMLReader( iface );
919 FIXME("(%p)->(%s) stub\n", This, debugstr_w(url));
923 static const struct ISAXXMLReaderVtbl isaxreader_vtbl =
925 isaxxmlreader_QueryInterface,
926 isaxxmlreader_AddRef,
927 isaxxmlreader_Release,
928 isaxxmlreader_getFeature,
929 isaxxmlreader_putFeature,
930 isaxxmlreader_getProperty,
931 isaxxmlreader_putProperty,
932 isaxxmlreader_getEntityResolver,
933 isaxxmlreader_putEntityResolver,
934 isaxxmlreader_getContentHandler,
935 isaxxmlreader_putContentHandler,
936 isaxxmlreader_getDTDHandler,
937 isaxxmlreader_putDTDHandler,
938 isaxxmlreader_getErrorHandler,
939 isaxxmlreader_putErrorHandler,
940 isaxxmlreader_getBaseURL,
941 isaxxmlreader_putBaseURL,
942 isaxxmlreader_getSecureBaseURL,
943 isaxxmlreader_putSecureBaseURL,
945 isaxxmlreader_parseURL
948 HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj)
952 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
954 reader = HeapAlloc( GetProcessHeap(), 0, sizeof (*reader) );
956 return E_OUTOFMEMORY;
958 reader->lpVtbl = &saxreader_vtbl;
959 reader->lpSAXXMLReaderVtbl = &isaxreader_vtbl;
961 reader->contentHandler = NULL;
962 reader->errorHandler = NULL;
964 memset(&reader->sax, 0, sizeof(xmlSAXHandler));
965 reader->sax.initialized = XML_SAX2_MAGIC;
966 reader->sax.startDocument = libxmlStartDocument;
967 reader->sax.endDocument = libxmlEndDocument;
968 reader->sax.startElementNs = libxmlStartElementNS;
970 *ppObj = &reader->lpVtbl;
972 TRACE("returning iface %p\n", *ppObj);
979 HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj)
981 MESSAGE("This program tried to use a SAX XML Reader object, but\n"
982 "libxml2 support was not present at compile time.\n");