d3dx9/tests: Implemented ConvertAdjacencyToPointReps test.
[wine/multimedia.git] / dlls / msxml3 / saxreader.c
blob4f0a5f163450de3659f2e5c73c9bfbc8579eb450
1 /*
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
21 #define COBJMACROS
23 #include "config.h"
25 #include <stdarg.h>
26 #ifdef HAVE_LIBXML2
27 # include <libxml/parser.h>
28 # include <libxml/xmlerror.h>
29 # include <libxml/SAX2.h>
30 # include <libxml/parserInternals.h>
31 #endif
33 #include "windef.h"
34 #include "winbase.h"
35 #include "winuser.h"
36 #include "winnls.h"
37 #include "ole2.h"
38 #include "msxml6.h"
39 #include "wininet.h"
40 #include "urlmon.h"
41 #include "winreg.h"
42 #include "shlwapi.h"
44 #include "wine/debug.h"
46 #include "msxml_private.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
50 #ifdef HAVE_LIBXML2
52 typedef struct _saxreader
54 IVBSAXXMLReader IVBSAXXMLReader_iface;
55 ISAXXMLReader ISAXXMLReader_iface;
56 LONG ref;
57 struct ISAXContentHandler *contentHandler;
58 struct IVBSAXContentHandler *vbcontentHandler;
59 struct ISAXErrorHandler *errorHandler;
60 struct IVBSAXErrorHandler *vberrorHandler;
61 struct ISAXLexicalHandler *lexicalHandler;
62 struct IVBSAXLexicalHandler *vblexicalHandler;
63 struct ISAXDeclHandler *declHandler;
64 struct IVBSAXDeclHandler *vbdeclHandler;
65 xmlSAXHandler sax;
66 BOOL isParsing;
67 } saxreader;
69 typedef struct _saxlocator
71 IVBSAXLocator IVBSAXLocator_iface;
72 ISAXLocator ISAXLocator_iface;
73 LONG ref;
74 saxreader *saxreader;
75 HRESULT ret;
76 xmlParserCtxtPtr pParserCtxt;
77 WCHAR *publicId;
78 WCHAR *systemId;
79 xmlChar *lastCur;
80 int line;
81 int realLine;
82 int column;
83 int realColumn;
84 BOOL vbInterface;
85 int nsStackSize;
86 int nsStackLast;
87 int *nsStack;
88 } saxlocator;
90 typedef struct _saxattributes
92 IVBSAXAttributes IVBSAXAttributes_iface;
93 ISAXAttributes ISAXAttributes_iface;
94 LONG ref;
95 int nb_attributes;
96 BSTR *szLocalname;
97 BSTR *szURI;
98 BSTR *szValue;
99 BSTR *szQName;
100 } saxattributes;
102 static inline saxreader *impl_from_IVBSAXXMLReader( IVBSAXXMLReader *iface )
104 return CONTAINING_RECORD(iface, saxreader, IVBSAXXMLReader_iface);
107 static inline saxreader *impl_from_ISAXXMLReader( ISAXXMLReader *iface )
109 return CONTAINING_RECORD(iface, saxreader, ISAXXMLReader_iface);
112 static inline saxlocator *impl_from_IVBSAXLocator( IVBSAXLocator *iface )
114 return CONTAINING_RECORD(iface, saxlocator, IVBSAXLocator_iface);
117 static inline saxlocator *impl_from_ISAXLocator( ISAXLocator *iface )
119 return CONTAINING_RECORD(iface, saxlocator, ISAXLocator_iface);
122 static inline saxattributes *impl_from_IVBSAXAttributes( IVBSAXAttributes *iface )
124 return CONTAINING_RECORD(iface, saxattributes, IVBSAXAttributes_iface);
127 static inline saxattributes *impl_from_ISAXAttributes( ISAXAttributes *iface )
129 return CONTAINING_RECORD(iface, saxattributes, ISAXAttributes_iface);
132 static inline BOOL has_content_handler(const saxlocator *locator)
134 return (locator->vbInterface && locator->saxreader->vbcontentHandler) ||
135 (!locator->vbInterface && locator->saxreader->contentHandler);
138 static inline BOOL has_error_handler(const saxlocator *locator)
140 return (locator->vbInterface && locator->saxreader->vberrorHandler) ||
141 (!locator->vbInterface && locator->saxreader->errorHandler);
144 static HRESULT namespacePush(saxlocator *locator, int ns)
146 if(locator->nsStackLast>=locator->nsStackSize)
148 int *new_stack;
150 new_stack = HeapReAlloc(GetProcessHeap(), 0,
151 locator->nsStack, sizeof(int)*locator->nsStackSize*2);
152 if(!new_stack) return E_OUTOFMEMORY;
153 locator->nsStack = new_stack;
154 locator->nsStackSize *= 2;
156 locator->nsStack[locator->nsStackLast++] = ns;
158 return S_OK;
161 static int namespacePop(saxlocator *locator)
163 if(locator->nsStackLast == 0) return 0;
164 return locator->nsStack[--locator->nsStackLast];
167 static BSTR bstr_from_xmlCharN(const xmlChar *buf, int len)
169 DWORD dLen;
170 BSTR bstr;
172 if (!buf)
173 return NULL;
175 dLen = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, NULL, 0);
176 if(len != -1) dLen++;
177 bstr = SysAllocStringLen(NULL, dLen-1);
178 if (!bstr)
179 return NULL;
180 MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, bstr, dLen);
181 if(len != -1) bstr[dLen-1] = '\0';
183 return bstr;
186 static BSTR QName_from_xmlChar(const xmlChar *prefix, const xmlChar *name)
188 xmlChar *qname;
189 BSTR bstr;
191 if(!name) return NULL;
193 if(!prefix || !*prefix)
194 return bstr_from_xmlChar(name);
196 qname = xmlBuildQName(name, prefix, NULL, 0);
197 bstr = bstr_from_xmlChar(qname);
198 xmlFree(qname);
200 return bstr;
203 static void format_error_message_from_id(saxlocator *This, HRESULT hr)
205 xmlStopParser(This->pParserCtxt);
206 This->ret = hr;
208 if(has_error_handler(This))
210 WCHAR msg[1024];
211 if(!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM,
212 NULL, hr, 0, msg, sizeof(msg), NULL))
214 FIXME("MSXML errors not yet supported.\n");
215 msg[0] = '\0';
218 if(This->vbInterface)
220 BSTR bstrMsg = SysAllocString(msg);
221 IVBSAXErrorHandler_fatalError(This->saxreader->vberrorHandler,
222 &This->IVBSAXLocator_iface, &bstrMsg, hr);
223 SysFreeString(bstrMsg);
225 else
226 ISAXErrorHandler_fatalError(This->saxreader->errorHandler,
227 &This->ISAXLocator_iface, msg, hr);
231 static void update_position(saxlocator *This, xmlChar *end)
233 if(This->lastCur == NULL)
235 This->lastCur = (xmlChar*)This->pParserCtxt->input->base;
236 This->realLine = 1;
237 This->realColumn = 1;
239 else if(This->lastCur < This->pParserCtxt->input->base)
241 This->lastCur = (xmlChar*)This->pParserCtxt->input->base;
242 This->realLine = 1;
243 This->realColumn = 1;
246 if(This->pParserCtxt->input->cur<This->lastCur)
248 This->lastCur = (xmlChar*)This->pParserCtxt->input->base;
249 This->realLine -= 1;
250 This->realColumn = 1;
253 if(!end) end = (xmlChar*)This->pParserCtxt->input->cur;
255 while(This->lastCur < end)
257 if(*(This->lastCur) == '\n')
259 This->realLine++;
260 This->realColumn = 1;
262 else if(*(This->lastCur) == '\r' &&
263 (This->lastCur==This->pParserCtxt->input->end ||
264 *(This->lastCur+1)!='\n'))
266 This->realLine++;
267 This->realColumn = 1;
269 else This->realColumn++;
271 This->lastCur++;
273 /* Count multibyte UTF8 encoded characters once */
274 while((*(This->lastCur)&0xC0) == 0x80) This->lastCur++;
277 This->line = This->realLine;
278 This->column = This->realColumn;
281 /*** IVBSAXAttributes interface ***/
282 /*** IUnknown methods ***/
283 static HRESULT WINAPI ivbsaxattributes_QueryInterface(
284 IVBSAXAttributes* iface,
285 REFIID riid,
286 void **ppvObject)
288 saxattributes *This = impl_from_IVBSAXAttributes(iface);
290 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
292 *ppvObject = NULL;
294 if (IsEqualGUID(riid, &IID_IUnknown) ||
295 IsEqualGUID(riid, &IID_IDispatch) ||
296 IsEqualGUID(riid, &IID_IVBSAXAttributes))
298 *ppvObject = iface;
300 else
302 FIXME("interface %s not implemented\n", debugstr_guid(riid));
303 return E_NOINTERFACE;
306 IVBSAXAttributes_AddRef(iface);
308 return S_OK;
311 static ULONG WINAPI ivbsaxattributes_AddRef(IVBSAXAttributes* iface)
313 saxattributes *This = impl_from_IVBSAXAttributes(iface);
314 return ISAXAttributes_AddRef(&This->ISAXAttributes_iface);
317 static ULONG WINAPI ivbsaxattributes_Release(IVBSAXAttributes* iface)
319 saxattributes *This = impl_from_IVBSAXAttributes(iface);
320 return ISAXAttributes_Release(&This->ISAXAttributes_iface);
323 /*** IDispatch methods ***/
324 static HRESULT WINAPI ivbsaxattributes_GetTypeInfoCount( IVBSAXAttributes *iface, UINT* pctinfo )
326 saxattributes *This = impl_from_IVBSAXAttributes( iface );
328 TRACE("(%p)->(%p)\n", This, pctinfo);
330 *pctinfo = 1;
332 return S_OK;
335 static HRESULT WINAPI ivbsaxattributes_GetTypeInfo(
336 IVBSAXAttributes *iface,
337 UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
339 saxattributes *This = impl_from_IVBSAXAttributes( iface );
340 HRESULT hr;
342 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
344 hr = get_typeinfo(IVBSAXAttributes_tid, ppTInfo);
346 return hr;
349 static HRESULT WINAPI ivbsaxattributes_GetIDsOfNames(
350 IVBSAXAttributes *iface,
351 REFIID riid,
352 LPOLESTR* rgszNames,
353 UINT cNames,
354 LCID lcid,
355 DISPID* rgDispId)
357 saxattributes *This = impl_from_IVBSAXAttributes( iface );
358 ITypeInfo *typeinfo;
359 HRESULT hr;
361 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
362 lcid, rgDispId);
364 if(!rgszNames || cNames == 0 || !rgDispId)
365 return E_INVALIDARG;
367 hr = get_typeinfo(IVBSAXAttributes_tid, &typeinfo);
368 if(SUCCEEDED(hr))
370 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
371 ITypeInfo_Release(typeinfo);
374 return hr;
377 static HRESULT WINAPI ivbsaxattributes_Invoke(
378 IVBSAXAttributes *iface,
379 DISPID dispIdMember,
380 REFIID riid,
381 LCID lcid,
382 WORD wFlags,
383 DISPPARAMS* pDispParams,
384 VARIANT* pVarResult,
385 EXCEPINFO* pExcepInfo,
386 UINT* puArgErr)
388 saxattributes *This = impl_from_IVBSAXAttributes( iface );
389 ITypeInfo *typeinfo;
390 HRESULT hr;
392 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
393 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
395 hr = get_typeinfo(IVBSAXAttributes_tid, &typeinfo);
396 if(SUCCEEDED(hr))
398 hr = ITypeInfo_Invoke(typeinfo, &This->IVBSAXAttributes_iface, dispIdMember, wFlags,
399 pDispParams, pVarResult, pExcepInfo, puArgErr);
400 ITypeInfo_Release(typeinfo);
403 return hr;
406 /*** IVBSAXAttributes methods ***/
407 static HRESULT WINAPI ivbsaxattributes_get_length(
408 IVBSAXAttributes* iface,
409 int *nLength)
411 saxattributes *This = impl_from_IVBSAXAttributes( iface );
412 return ISAXAttributes_getLength(&This->ISAXAttributes_iface, nLength);
415 static HRESULT WINAPI ivbsaxattributes_getURI(
416 IVBSAXAttributes* iface,
417 int nIndex,
418 BSTR *uri)
420 int len;
421 saxattributes *This = impl_from_IVBSAXAttributes( iface );
422 return ISAXAttributes_getURI(&This->ISAXAttributes_iface, nIndex, (const WCHAR**)uri, &len);
425 static HRESULT WINAPI ivbsaxattributes_getLocalName(
426 IVBSAXAttributes* iface,
427 int nIndex,
428 BSTR *localName)
430 int len;
431 saxattributes *This = impl_from_IVBSAXAttributes( iface );
432 return ISAXAttributes_getLocalName(&This->ISAXAttributes_iface, nIndex,
433 (const WCHAR**)localName, &len);
436 static HRESULT WINAPI ivbsaxattributes_getQName(
437 IVBSAXAttributes* iface,
438 int nIndex,
439 BSTR *QName)
441 int len;
442 saxattributes *This = impl_from_IVBSAXAttributes( iface );
443 return ISAXAttributes_getQName(&This->ISAXAttributes_iface, nIndex, (const WCHAR**)QName, &len);
446 static HRESULT WINAPI ivbsaxattributes_getIndexFromName(
447 IVBSAXAttributes* iface,
448 BSTR uri,
449 BSTR localName,
450 int *index)
452 saxattributes *This = impl_from_IVBSAXAttributes( iface );
453 return ISAXAttributes_getIndexFromName(&This->ISAXAttributes_iface, uri, SysStringLen(uri),
454 localName, SysStringLen(localName), index);
457 static HRESULT WINAPI ivbsaxattributes_getIndexFromQName(
458 IVBSAXAttributes* iface,
459 BSTR QName,
460 int *index)
462 saxattributes *This = impl_from_IVBSAXAttributes( iface );
463 return ISAXAttributes_getIndexFromQName(&This->ISAXAttributes_iface, QName,
464 SysStringLen(QName), index);
467 static HRESULT WINAPI ivbsaxattributes_getType(
468 IVBSAXAttributes* iface,
469 int nIndex,
470 BSTR *type)
472 int len;
473 saxattributes *This = impl_from_IVBSAXAttributes( iface );
474 return ISAXAttributes_getType(&This->ISAXAttributes_iface, nIndex, (const WCHAR**)type, &len);
477 static HRESULT WINAPI ivbsaxattributes_getTypeFromName(
478 IVBSAXAttributes* iface,
479 BSTR uri,
480 BSTR localName,
481 BSTR *type)
483 int len;
484 saxattributes *This = impl_from_IVBSAXAttributes( iface );
485 return ISAXAttributes_getTypeFromName(&This->ISAXAttributes_iface, uri, SysStringLen(uri),
486 localName, SysStringLen(localName), (const WCHAR**)type, &len);
489 static HRESULT WINAPI ivbsaxattributes_getTypeFromQName(
490 IVBSAXAttributes* iface,
491 BSTR QName,
492 BSTR *type)
494 int len;
495 saxattributes *This = impl_from_IVBSAXAttributes( iface );
496 return ISAXAttributes_getTypeFromQName(&This->ISAXAttributes_iface, QName, SysStringLen(QName),
497 (const WCHAR**)type, &len);
500 static HRESULT WINAPI ivbsaxattributes_getValue(
501 IVBSAXAttributes* iface,
502 int nIndex,
503 BSTR *value)
505 int len;
506 saxattributes *This = impl_from_IVBSAXAttributes( iface );
507 return ISAXAttributes_getValue(&This->ISAXAttributes_iface, nIndex, (const WCHAR**)value, &len);
510 static HRESULT WINAPI ivbsaxattributes_getValueFromName(
511 IVBSAXAttributes* iface,
512 BSTR uri,
513 BSTR localName,
514 BSTR *value)
516 int len;
517 saxattributes *This = impl_from_IVBSAXAttributes( iface );
518 return ISAXAttributes_getValueFromName(&This->ISAXAttributes_iface, uri, SysStringLen(uri),
519 localName, SysStringLen(localName), (const WCHAR**)value, &len);
522 static HRESULT WINAPI ivbsaxattributes_getValueFromQName(
523 IVBSAXAttributes* iface,
524 BSTR QName,
525 BSTR *value)
527 int len;
528 saxattributes *This = impl_from_IVBSAXAttributes( iface );
529 return ISAXAttributes_getValueFromQName(&This->ISAXAttributes_iface, QName,
530 SysStringLen(QName), (const WCHAR**)value, &len);
533 static const struct IVBSAXAttributesVtbl ivbsaxattributes_vtbl =
535 ivbsaxattributes_QueryInterface,
536 ivbsaxattributes_AddRef,
537 ivbsaxattributes_Release,
538 ivbsaxattributes_GetTypeInfoCount,
539 ivbsaxattributes_GetTypeInfo,
540 ivbsaxattributes_GetIDsOfNames,
541 ivbsaxattributes_Invoke,
542 ivbsaxattributes_get_length,
543 ivbsaxattributes_getURI,
544 ivbsaxattributes_getLocalName,
545 ivbsaxattributes_getQName,
546 ivbsaxattributes_getIndexFromName,
547 ivbsaxattributes_getIndexFromQName,
548 ivbsaxattributes_getType,
549 ivbsaxattributes_getTypeFromName,
550 ivbsaxattributes_getTypeFromQName,
551 ivbsaxattributes_getValue,
552 ivbsaxattributes_getValueFromName,
553 ivbsaxattributes_getValueFromQName
556 /*** ISAXAttributes interface ***/
557 /*** IUnknown methods ***/
558 static HRESULT WINAPI isaxattributes_QueryInterface(
559 ISAXAttributes* iface,
560 REFIID riid,
561 void **ppvObject)
563 saxattributes *This = impl_from_ISAXAttributes(iface);
565 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
567 *ppvObject = NULL;
569 if (IsEqualGUID(riid, &IID_IUnknown) ||
570 IsEqualGUID(riid, &IID_ISAXAttributes))
572 *ppvObject = iface;
574 else
576 FIXME("interface %s not implemented\n", debugstr_guid(riid));
577 return E_NOINTERFACE;
580 ISAXAttributes_AddRef(iface);
582 return S_OK;
585 static ULONG WINAPI isaxattributes_AddRef(ISAXAttributes* iface)
587 saxattributes *This = impl_from_ISAXAttributes(iface);
588 TRACE("%p\n", This);
589 return InterlockedIncrement(&This->ref);
592 static ULONG WINAPI isaxattributes_Release(ISAXAttributes* iface)
594 saxattributes *This = impl_from_ISAXAttributes(iface);
595 LONG ref;
597 TRACE("%p\n", This);
599 ref = InterlockedDecrement(&This->ref);
600 if (ref==0)
602 int index;
603 for(index=0; index<This->nb_attributes; index++)
605 SysFreeString(This->szLocalname[index]);
606 SysFreeString(This->szURI[index]);
607 SysFreeString(This->szValue[index]);
608 SysFreeString(This->szQName[index]);
611 heap_free(This->szLocalname);
612 heap_free(This->szURI);
613 heap_free(This->szValue);
614 heap_free(This->szQName);
616 heap_free(This);
619 return ref;
622 /*** ISAXAttributes methods ***/
623 static HRESULT WINAPI isaxattributes_getLength(
624 ISAXAttributes* iface,
625 int *length)
627 saxattributes *This = impl_from_ISAXAttributes( iface );
629 *length = This->nb_attributes;
630 TRACE("Length set to %d\n", *length);
631 return S_OK;
634 static HRESULT WINAPI isaxattributes_getURI(
635 ISAXAttributes* iface,
636 int nIndex,
637 const WCHAR **pUrl,
638 int *pUriSize)
640 saxattributes *This = impl_from_ISAXAttributes( iface );
641 TRACE("(%p)->(%d)\n", This, nIndex);
643 if(nIndex>=This->nb_attributes || nIndex<0) return E_INVALIDARG;
644 if(!pUrl || !pUriSize) return E_POINTER;
646 *pUriSize = SysStringLen(This->szURI[nIndex]);
647 *pUrl = This->szURI[nIndex];
649 return S_OK;
652 static HRESULT WINAPI isaxattributes_getLocalName(
653 ISAXAttributes* iface,
654 int nIndex,
655 const WCHAR **pLocalName,
656 int *pLocalNameLength)
658 saxattributes *This = impl_from_ISAXAttributes( iface );
659 TRACE("(%p)->(%d)\n", This, nIndex);
661 if(nIndex>=This->nb_attributes || nIndex<0) return E_INVALIDARG;
662 if(!pLocalName || !pLocalNameLength) return E_POINTER;
664 *pLocalNameLength = SysStringLen(This->szLocalname[nIndex]);
665 *pLocalName = This->szLocalname[nIndex];
667 return S_OK;
670 static HRESULT WINAPI isaxattributes_getQName(
671 ISAXAttributes* iface,
672 int nIndex,
673 const WCHAR **pQName,
674 int *pQNameLength)
676 saxattributes *This = impl_from_ISAXAttributes( iface );
677 TRACE("(%p)->(%d)\n", This, nIndex);
679 if(nIndex>=This->nb_attributes || nIndex<0) return E_INVALIDARG;
680 if(!pQName || !pQNameLength) return E_POINTER;
682 *pQNameLength = SysStringLen(This->szQName[nIndex]);
683 *pQName = This->szQName[nIndex];
685 return S_OK;
688 static HRESULT WINAPI isaxattributes_getName(
689 ISAXAttributes* iface,
690 int nIndex,
691 const WCHAR **pUri,
692 int *pUriLength,
693 const WCHAR **pLocalName,
694 int *pLocalNameSize,
695 const WCHAR **pQName,
696 int *pQNameLength)
698 saxattributes *This = impl_from_ISAXAttributes( iface );
699 TRACE("(%p)->(%d)\n", This, nIndex);
701 if(nIndex>=This->nb_attributes || nIndex<0) return E_INVALIDARG;
702 if(!pUri || !pUriLength || !pLocalName || !pLocalNameSize
703 || !pQName || !pQNameLength) return E_POINTER;
705 *pUriLength = SysStringLen(This->szURI[nIndex]);
706 *pUri = This->szURI[nIndex];
707 *pLocalNameSize = SysStringLen(This->szLocalname[nIndex]);
708 *pLocalName = This->szLocalname[nIndex];
709 *pQNameLength = SysStringLen(This->szQName[nIndex]);
710 *pQName = This->szQName[nIndex];
712 return S_OK;
715 static HRESULT WINAPI isaxattributes_getIndexFromName(
716 ISAXAttributes* iface,
717 const WCHAR *pUri,
718 int cUriLength,
719 const WCHAR *pLocalName,
720 int cocalNameLength,
721 int *index)
723 saxattributes *This = impl_from_ISAXAttributes( iface );
724 int i;
725 TRACE("(%p)->(%s, %d, %s, %d)\n", This, debugstr_w(pUri), cUriLength,
726 debugstr_w(pLocalName), cocalNameLength);
728 if(!pUri || !pLocalName || !index) return E_POINTER;
730 for(i=0; i<This->nb_attributes; i++)
732 if(cUriLength!=SysStringLen(This->szURI[i])
733 || cocalNameLength!=SysStringLen(This->szLocalname[i]))
734 continue;
735 if(cUriLength && memcmp(pUri, This->szURI[i],
736 sizeof(WCHAR)*cUriLength))
737 continue;
738 if(cocalNameLength && memcmp(pLocalName, This->szLocalname[i],
739 sizeof(WCHAR)*cocalNameLength))
740 continue;
742 *index = i;
743 return S_OK;
746 return E_INVALIDARG;
749 static HRESULT WINAPI isaxattributes_getIndexFromQName(
750 ISAXAttributes* iface,
751 const WCHAR *pQName,
752 int nQNameLength,
753 int *index)
755 saxattributes *This = impl_from_ISAXAttributes( iface );
756 int i;
757 TRACE("(%p)->(%s, %d)\n", This, debugstr_w(pQName), nQNameLength);
759 if(!pQName || !index) return E_POINTER;
760 if(!nQNameLength) return E_INVALIDARG;
762 for(i=0; i<This->nb_attributes; i++)
764 if(nQNameLength!=SysStringLen(This->szQName[i])) continue;
765 if(memcmp(pQName, This->szQName, sizeof(WCHAR)*nQNameLength)) continue;
767 *index = i;
768 return S_OK;
771 return E_INVALIDARG;
774 static HRESULT WINAPI isaxattributes_getType(
775 ISAXAttributes* iface,
776 int nIndex,
777 const WCHAR **pType,
778 int *pTypeLength)
780 saxattributes *This = impl_from_ISAXAttributes( iface );
782 FIXME("(%p)->(%d) stub\n", This, nIndex);
783 return E_NOTIMPL;
786 static HRESULT WINAPI isaxattributes_getTypeFromName(
787 ISAXAttributes* iface,
788 const WCHAR *pUri,
789 int nUri,
790 const WCHAR *pLocalName,
791 int nLocalName,
792 const WCHAR **pType,
793 int *nType)
795 saxattributes *This = impl_from_ISAXAttributes( iface );
797 FIXME("(%p)->(%s, %d, %s, %d) stub\n", This, debugstr_w(pUri), nUri,
798 debugstr_w(pLocalName), nLocalName);
799 return E_NOTIMPL;
802 static HRESULT WINAPI isaxattributes_getTypeFromQName(
803 ISAXAttributes* iface,
804 const WCHAR *pQName,
805 int nQName,
806 const WCHAR **pType,
807 int *nType)
809 saxattributes *This = impl_from_ISAXAttributes( iface );
811 FIXME("(%p)->(%s, %d) stub\n", This, debugstr_w(pQName), nQName);
812 return E_NOTIMPL;
815 static HRESULT WINAPI isaxattributes_getValue(
816 ISAXAttributes* iface,
817 int nIndex,
818 const WCHAR **pValue,
819 int *nValue)
821 saxattributes *This = impl_from_ISAXAttributes( iface );
822 TRACE("(%p)->(%d)\n", This, nIndex);
824 if(nIndex>=This->nb_attributes || nIndex<0) return E_INVALIDARG;
825 if(!pValue || !nValue) return E_POINTER;
827 *nValue = SysStringLen(This->szValue[nIndex]);
828 *pValue = This->szValue[nIndex];
830 return S_OK;
833 static HRESULT WINAPI isaxattributes_getValueFromName(
834 ISAXAttributes* iface,
835 const WCHAR *pUri,
836 int nUri,
837 const WCHAR *pLocalName,
838 int nLocalName,
839 const WCHAR **pValue,
840 int *nValue)
842 HRESULT hr;
843 int index;
844 saxattributes *This = impl_from_ISAXAttributes( iface );
845 TRACE("(%p)->(%s, %d, %s, %d)\n", This, debugstr_w(pUri), nUri,
846 debugstr_w(pLocalName), nLocalName);
848 hr = ISAXAttributes_getIndexFromName(iface,
849 pUri, nUri, pLocalName, nLocalName, &index);
850 if(hr==S_OK) hr = ISAXAttributes_getValue(iface, index, pValue, nValue);
852 return hr;
855 static HRESULT WINAPI isaxattributes_getValueFromQName(
856 ISAXAttributes* iface,
857 const WCHAR *pQName,
858 int nQName,
859 const WCHAR **pValue,
860 int *nValue)
862 HRESULT hr;
863 int index;
864 saxattributes *This = impl_from_ISAXAttributes( iface );
865 TRACE("(%p)->(%s, %d)\n", This, debugstr_w(pQName), nQName);
867 hr = ISAXAttributes_getIndexFromQName(iface, pQName, nQName, &index);
868 if(hr==S_OK) hr = ISAXAttributes_getValue(iface, index, pValue, nValue);
870 return hr;
873 static const struct ISAXAttributesVtbl isaxattributes_vtbl =
875 isaxattributes_QueryInterface,
876 isaxattributes_AddRef,
877 isaxattributes_Release,
878 isaxattributes_getLength,
879 isaxattributes_getURI,
880 isaxattributes_getLocalName,
881 isaxattributes_getQName,
882 isaxattributes_getName,
883 isaxattributes_getIndexFromName,
884 isaxattributes_getIndexFromQName,
885 isaxattributes_getType,
886 isaxattributes_getTypeFromName,
887 isaxattributes_getTypeFromQName,
888 isaxattributes_getValue,
889 isaxattributes_getValueFromName,
890 isaxattributes_getValueFromQName
893 static HRESULT SAXAttributes_create(saxattributes **attr,
894 int nb_namespaces, const xmlChar **xmlNamespaces,
895 int nb_attributes, const xmlChar **xmlAttributes)
897 saxattributes *attributes;
898 int index;
899 static const xmlChar xmlns[] = "xmlns";
901 attributes = heap_alloc(sizeof(*attributes));
902 if(!attributes)
903 return E_OUTOFMEMORY;
905 attributes->IVBSAXAttributes_iface.lpVtbl = &ivbsaxattributes_vtbl;
906 attributes->ISAXAttributes_iface.lpVtbl = &isaxattributes_vtbl;
907 attributes->ref = 1;
909 attributes->nb_attributes = nb_namespaces+nb_attributes;
911 attributes->szLocalname = heap_alloc(sizeof(BSTR)*attributes->nb_attributes);
912 attributes->szURI = heap_alloc(sizeof(BSTR)*attributes->nb_attributes);
913 attributes->szValue = heap_alloc(sizeof(BSTR)*attributes->nb_attributes);
914 attributes->szQName = heap_alloc(sizeof(BSTR)*attributes->nb_attributes);
916 if(!attributes->szLocalname || !attributes->szURI
917 || !attributes->szValue || !attributes->szQName)
919 heap_free(attributes->szLocalname);
920 heap_free(attributes->szURI);
921 heap_free(attributes->szValue);
922 heap_free(attributes->szQName);
923 heap_free(attributes);
924 return E_FAIL;
927 for(index=0; index<nb_namespaces; index++)
929 attributes->szLocalname[index] = SysAllocStringLen(NULL, 0);
930 attributes->szURI[index] = SysAllocStringLen(NULL, 0);
931 attributes->szValue[index] = bstr_from_xmlChar(xmlNamespaces[2*index+1]);
932 attributes->szQName[index] = QName_from_xmlChar(xmlns, xmlNamespaces[2*index]);
935 for(index=0; index<nb_attributes; index++)
937 attributes->szLocalname[nb_namespaces+index] =
938 bstr_from_xmlChar(xmlAttributes[index*5]);
939 attributes->szURI[nb_namespaces+index] =
940 bstr_from_xmlChar(xmlAttributes[index*5+2]);
941 attributes->szValue[nb_namespaces+index] =
942 bstr_from_xmlCharN(xmlAttributes[index*5+3],
943 xmlAttributes[index*5+4]-xmlAttributes[index*5+3]);
944 attributes->szQName[nb_namespaces+index] =
945 QName_from_xmlChar(xmlAttributes[index*5+1], xmlAttributes[index*5]);
948 *attr = attributes;
950 TRACE("returning %p\n", *attr);
952 return S_OK;
955 /*** LibXML callbacks ***/
956 static void libxmlStartDocument(void *ctx)
958 saxlocator *This = ctx;
959 HRESULT hr;
961 if(has_content_handler(This))
963 if(This->vbInterface)
964 hr = IVBSAXContentHandler_startDocument(This->saxreader->vbcontentHandler);
965 else
966 hr = ISAXContentHandler_startDocument(This->saxreader->contentHandler);
968 if(hr != S_OK)
969 format_error_message_from_id(This, hr);
972 update_position(This, NULL);
975 static void libxmlEndDocument(void *ctx)
977 saxlocator *This = ctx;
978 HRESULT hr;
980 This->column = 0;
981 This->line = 0;
983 if(This->ret != S_OK) return;
985 if(has_content_handler(This))
987 if(This->vbInterface)
988 hr = IVBSAXContentHandler_endDocument(This->saxreader->vbcontentHandler);
989 else
990 hr = ISAXContentHandler_endDocument(This->saxreader->contentHandler);
992 if(hr != S_OK)
993 format_error_message_from_id(This, hr);
997 static void libxmlStartElementNS(
998 void *ctx,
999 const xmlChar *localname,
1000 const xmlChar *prefix,
1001 const xmlChar *URI,
1002 int nb_namespaces,
1003 const xmlChar **namespaces,
1004 int nb_attributes,
1005 int nb_defaulted,
1006 const xmlChar **attributes)
1008 BSTR NamespaceUri, LocalName, QName, Prefix, Uri;
1009 saxlocator *This = ctx;
1010 HRESULT hr;
1011 saxattributes *attr;
1012 int index;
1014 if(*(This->pParserCtxt->input->cur) == '/')
1015 update_position(This, (xmlChar*)This->pParserCtxt->input->cur+2);
1016 else
1017 update_position(This, (xmlChar*)This->pParserCtxt->input->cur+1);
1019 hr = namespacePush(This, nb_namespaces);
1020 if(hr==S_OK && has_content_handler(This))
1022 for(index=0; index<nb_namespaces; index++)
1024 Prefix = bstr_from_xmlChar(namespaces[2*index]);
1025 Uri = bstr_from_xmlChar(namespaces[2*index+1]);
1027 if(This->vbInterface)
1028 hr = IVBSAXContentHandler_startPrefixMapping(
1029 This->saxreader->vbcontentHandler,
1030 &Prefix, &Uri);
1031 else
1032 hr = ISAXContentHandler_startPrefixMapping(
1033 This->saxreader->contentHandler,
1034 Prefix, SysStringLen(Prefix),
1035 Uri, SysStringLen(Uri));
1037 SysFreeString(Prefix);
1038 SysFreeString(Uri);
1040 if(hr != S_OK)
1042 format_error_message_from_id(This, hr);
1043 return;
1047 NamespaceUri = bstr_from_xmlChar(URI);
1048 LocalName = bstr_from_xmlChar(localname);
1049 QName = QName_from_xmlChar(prefix, localname);
1051 hr = SAXAttributes_create(&attr, nb_namespaces, namespaces, nb_attributes, attributes);
1052 if(hr == S_OK)
1054 if(This->vbInterface)
1055 hr = IVBSAXContentHandler_startElement(This->saxreader->vbcontentHandler,
1056 &NamespaceUri, &LocalName, &QName, &attr->IVBSAXAttributes_iface);
1057 else
1058 hr = ISAXContentHandler_startElement(This->saxreader->contentHandler, NamespaceUri,
1059 SysStringLen(NamespaceUri), LocalName, SysStringLen(LocalName), QName,
1060 SysStringLen(QName), &attr->ISAXAttributes_iface);
1062 ISAXAttributes_Release(&attr->ISAXAttributes_iface);
1065 SysFreeString(NamespaceUri);
1066 SysFreeString(LocalName);
1067 SysFreeString(QName);
1070 if(hr != S_OK)
1071 format_error_message_from_id(This, hr);
1074 static void libxmlEndElementNS(
1075 void *ctx,
1076 const xmlChar *localname,
1077 const xmlChar *prefix,
1078 const xmlChar *URI)
1080 BSTR NamespaceUri, LocalName, QName, Prefix;
1081 saxlocator *This = ctx;
1082 HRESULT hr;
1083 xmlChar *end;
1084 int nsNr, index;
1086 end = (xmlChar*)This->pParserCtxt->input->cur;
1087 if(*(end-1) != '>' || *(end-2) != '/')
1088 while(end-2>=This->pParserCtxt->input->base
1089 && *(end-2)!='<' && *(end-1)!='/') end--;
1091 update_position(This, end);
1093 nsNr = namespacePop(This);
1095 if(has_content_handler(This))
1097 NamespaceUri = bstr_from_xmlChar(URI);
1098 LocalName = bstr_from_xmlChar(localname);
1099 QName = QName_from_xmlChar(prefix, localname);
1101 if(This->vbInterface)
1102 hr = IVBSAXContentHandler_endElement(
1103 This->saxreader->vbcontentHandler,
1104 &NamespaceUri, &LocalName, &QName);
1105 else
1106 hr = ISAXContentHandler_endElement(
1107 This->saxreader->contentHandler,
1108 NamespaceUri, SysStringLen(NamespaceUri),
1109 LocalName, SysStringLen(LocalName),
1110 QName, SysStringLen(QName));
1112 SysFreeString(NamespaceUri);
1113 SysFreeString(LocalName);
1114 SysFreeString(QName);
1116 if(hr != S_OK)
1118 format_error_message_from_id(This, hr);
1119 return;
1122 for(index=This->pParserCtxt->nsNr-2;
1123 index>=This->pParserCtxt->nsNr-nsNr*2; index-=2)
1125 Prefix = bstr_from_xmlChar(This->pParserCtxt->nsTab[index]);
1127 if(This->vbInterface)
1128 hr = IVBSAXContentHandler_endPrefixMapping(
1129 This->saxreader->vbcontentHandler, &Prefix);
1130 else
1131 hr = ISAXContentHandler_endPrefixMapping(
1132 This->saxreader->contentHandler,
1133 Prefix, SysStringLen(Prefix));
1135 SysFreeString(Prefix);
1137 if(hr != S_OK)
1139 format_error_message_from_id(This, hr);
1140 return;
1146 update_position(This, NULL);
1149 static void libxmlCharacters(
1150 void *ctx,
1151 const xmlChar *ch,
1152 int len)
1154 saxlocator *This = ctx;
1155 BSTR Chars;
1156 HRESULT hr;
1157 xmlChar *cur;
1158 xmlChar *end;
1159 BOOL lastEvent = FALSE;
1161 if(!(has_content_handler(This))) return;
1163 cur = (xmlChar*)ch;
1164 if(*(ch-1)=='\r') cur--;
1165 end = cur;
1167 if(ch<This->pParserCtxt->input->base || ch>This->pParserCtxt->input->end)
1168 This->column++;
1170 while(1)
1172 while(end-ch<len && *end!='\r') end++;
1173 if(end-ch==len)
1175 end--;
1176 lastEvent = TRUE;
1179 if(!lastEvent) *end = '\n';
1181 Chars = bstr_from_xmlCharN(cur, end-cur+1);
1182 if(This->vbInterface)
1183 hr = IVBSAXContentHandler_characters(
1184 This->saxreader->vbcontentHandler, &Chars);
1185 else
1186 hr = ISAXContentHandler_characters(
1187 This->saxreader->contentHandler,
1188 Chars, SysStringLen(Chars));
1189 SysFreeString(Chars);
1191 if(hr != S_OK)
1193 format_error_message_from_id(This, hr);
1194 return;
1197 This->column += end-cur+1;
1199 if(lastEvent)
1200 break;
1202 *end = '\r';
1203 end++;
1204 if(*end == '\n')
1206 end++;
1207 This->column++;
1209 cur = end;
1211 if(end-ch == len) break;
1214 if(ch<This->pParserCtxt->input->base || ch>This->pParserCtxt->input->end)
1215 This->column = This->realColumn
1216 +This->pParserCtxt->input->cur-This->lastCur;
1219 static void libxmlSetDocumentLocator(
1220 void *ctx,
1221 xmlSAXLocatorPtr loc)
1223 saxlocator *This = ctx;
1224 HRESULT hr = S_OK;
1226 if(has_content_handler(This))
1228 if(This->vbInterface)
1229 hr = IVBSAXContentHandler_putref_documentLocator(This->saxreader->vbcontentHandler,
1230 &This->IVBSAXLocator_iface);
1231 else
1232 hr = ISAXContentHandler_putDocumentLocator(This->saxreader->contentHandler,
1233 &This->ISAXLocator_iface);
1236 if(FAILED(hr))
1237 format_error_message_from_id(This, hr);
1240 static void libxmlComment(void *ctx, const xmlChar *value)
1242 saxlocator *This = ctx;
1243 BSTR bValue;
1244 HRESULT hr;
1245 xmlChar *beg = (xmlChar*)This->pParserCtxt->input->cur;
1247 while(beg-4>=This->pParserCtxt->input->base
1248 && memcmp(beg-4, "<!--", sizeof(char[4]))) beg--;
1249 update_position(This, beg);
1251 if(!This->vbInterface && !This->saxreader->lexicalHandler) return;
1252 if(This->vbInterface && !This->saxreader->vblexicalHandler) return;
1254 bValue = bstr_from_xmlChar(value);
1256 if(This->vbInterface)
1257 hr = IVBSAXLexicalHandler_comment(
1258 This->saxreader->vblexicalHandler, &bValue);
1259 else
1260 hr = ISAXLexicalHandler_comment(
1261 This->saxreader->lexicalHandler,
1262 bValue, SysStringLen(bValue));
1264 SysFreeString(bValue);
1266 if(FAILED(hr))
1267 format_error_message_from_id(This, hr);
1269 update_position(This, NULL);
1272 static void libxmlFatalError(void *ctx, const char *msg, ...)
1274 saxlocator *This = ctx;
1275 char message[1024];
1276 WCHAR *error;
1277 DWORD len;
1278 va_list args;
1280 va_start(args, msg);
1281 vsprintf(message, msg, args);
1282 va_end(args);
1284 len = MultiByteToWideChar(CP_UNIXCP, 0, message, -1, NULL, 0);
1285 error = heap_alloc(sizeof(WCHAR)*len);
1286 if(error)
1288 MultiByteToWideChar(CP_UNIXCP, 0, message, -1, error, len);
1289 TRACE("fatal error for %p: %s\n", This, debugstr_w(error));
1292 if(!has_error_handler(This))
1294 xmlStopParser(This->pParserCtxt);
1295 This->ret = E_FAIL;
1296 heap_free(error);
1297 return;
1300 FIXME("Error handling is not compatible.\n");
1302 if(This->vbInterface)
1304 BSTR bstrError = SysAllocString(error);
1305 IVBSAXErrorHandler_fatalError(This->saxreader->vberrorHandler, &This->IVBSAXLocator_iface,
1306 &bstrError, E_FAIL);
1307 SysFreeString(bstrError);
1309 else
1310 ISAXErrorHandler_fatalError(This->saxreader->errorHandler, &This->ISAXLocator_iface,
1311 error, E_FAIL);
1313 heap_free(error);
1315 xmlStopParser(This->pParserCtxt);
1316 This->ret = E_FAIL;
1319 static void libxmlCDataBlock(void *ctx, const xmlChar *value, int len)
1321 saxlocator *This = ctx;
1322 HRESULT hr = S_OK;
1323 xmlChar *beg = (xmlChar*)This->pParserCtxt->input->cur-len;
1324 xmlChar *cur, *end;
1325 int realLen;
1326 BSTR Chars;
1327 BOOL lastEvent = FALSE, change;
1329 while(beg-9>=This->pParserCtxt->input->base
1330 && memcmp(beg-9, "<![CDATA[", sizeof(char[9]))) beg--;
1331 update_position(This, beg);
1333 if(This->vbInterface && This->saxreader->vblexicalHandler)
1334 hr = IVBSAXLexicalHandler_startCDATA(This->saxreader->vblexicalHandler);
1335 if(!This->vbInterface && This->saxreader->lexicalHandler)
1336 hr = ISAXLexicalHandler_startCDATA(This->saxreader->lexicalHandler);
1338 if(FAILED(hr))
1340 format_error_message_from_id(This, hr);
1341 return;
1344 realLen = This->pParserCtxt->input->cur-beg-3;
1345 cur = beg;
1346 end = beg;
1348 while(1)
1350 while(end-beg<realLen && *end!='\r') end++;
1351 if(end-beg==realLen)
1353 end--;
1354 lastEvent = TRUE;
1356 else if(end-beg==realLen-1 && *end=='\r' && *(end+1)=='\n')
1357 lastEvent = TRUE;
1359 if(*end == '\r') change = TRUE;
1360 else change = FALSE;
1362 if(change) *end = '\n';
1364 if(has_content_handler(This))
1366 Chars = bstr_from_xmlCharN(cur, end-cur+1);
1367 if(This->vbInterface)
1368 hr = IVBSAXContentHandler_characters(
1369 This->saxreader->vbcontentHandler, &Chars);
1370 else
1371 hr = ISAXContentHandler_characters(
1372 This->saxreader->contentHandler,
1373 Chars, SysStringLen(Chars));
1374 SysFreeString(Chars);
1377 if(change) *end = '\r';
1379 if(lastEvent)
1380 break;
1382 This->column += end-cur+2;
1383 end += 2;
1384 cur = end;
1387 if(This->vbInterface && This->saxreader->vblexicalHandler)
1388 hr = IVBSAXLexicalHandler_endCDATA(This->saxreader->vblexicalHandler);
1389 if(!This->vbInterface && This->saxreader->lexicalHandler)
1390 hr = ISAXLexicalHandler_endCDATA(This->saxreader->lexicalHandler);
1392 if(FAILED(hr))
1393 format_error_message_from_id(This, hr);
1395 This->column += 4+end-cur;
1398 /*** IVBSAXLocator interface ***/
1399 /*** IUnknown methods ***/
1400 static HRESULT WINAPI ivbsaxlocator_QueryInterface(IVBSAXLocator* iface, REFIID riid, void **ppvObject)
1402 saxlocator *This = impl_from_IVBSAXLocator( iface );
1404 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject);
1406 *ppvObject = NULL;
1408 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
1409 IsEqualGUID( riid, &IID_IDispatch) ||
1410 IsEqualGUID( riid, &IID_IVBSAXLocator ))
1412 *ppvObject = iface;
1414 else
1416 FIXME("interface %s not implemented\n", debugstr_guid(riid));
1417 return E_NOINTERFACE;
1420 IVBSAXLocator_AddRef( iface );
1422 return S_OK;
1425 static ULONG WINAPI ivbsaxlocator_AddRef(IVBSAXLocator* iface)
1427 saxlocator *This = impl_from_IVBSAXLocator( iface );
1428 TRACE("%p\n", This );
1429 return InterlockedIncrement( &This->ref );
1432 static ULONG WINAPI ivbsaxlocator_Release(
1433 IVBSAXLocator* iface)
1435 saxlocator *This = impl_from_IVBSAXLocator( iface );
1436 return ISAXLocator_Release((ISAXLocator*)&This->IVBSAXLocator_iface);
1439 /*** IDispatch methods ***/
1440 static HRESULT WINAPI ivbsaxlocator_GetTypeInfoCount( IVBSAXLocator *iface, UINT* pctinfo )
1442 saxlocator *This = impl_from_IVBSAXLocator( iface );
1444 TRACE("(%p)->(%p)\n", This, pctinfo);
1446 *pctinfo = 1;
1448 return S_OK;
1451 static HRESULT WINAPI ivbsaxlocator_GetTypeInfo(
1452 IVBSAXLocator *iface,
1453 UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
1455 saxlocator *This = impl_from_IVBSAXLocator( iface );
1456 HRESULT hr;
1458 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
1460 hr = get_typeinfo(IVBSAXLocator_tid, ppTInfo);
1462 return hr;
1465 static HRESULT WINAPI ivbsaxlocator_GetIDsOfNames(
1466 IVBSAXLocator *iface,
1467 REFIID riid,
1468 LPOLESTR* rgszNames,
1469 UINT cNames,
1470 LCID lcid,
1471 DISPID* rgDispId)
1473 saxlocator *This = impl_from_IVBSAXLocator( iface );
1474 ITypeInfo *typeinfo;
1475 HRESULT hr;
1477 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
1478 lcid, rgDispId);
1480 if(!rgszNames || cNames == 0 || !rgDispId)
1481 return E_INVALIDARG;
1483 hr = get_typeinfo(IVBSAXLocator_tid, &typeinfo);
1484 if(SUCCEEDED(hr))
1486 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
1487 ITypeInfo_Release(typeinfo);
1490 return hr;
1493 static HRESULT WINAPI ivbsaxlocator_Invoke(
1494 IVBSAXLocator *iface,
1495 DISPID dispIdMember,
1496 REFIID riid,
1497 LCID lcid,
1498 WORD wFlags,
1499 DISPPARAMS* pDispParams,
1500 VARIANT* pVarResult,
1501 EXCEPINFO* pExcepInfo,
1502 UINT* puArgErr)
1504 saxlocator *This = impl_from_IVBSAXLocator( iface );
1505 ITypeInfo *typeinfo;
1506 HRESULT hr;
1508 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1509 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1511 hr = get_typeinfo(IVBSAXLocator_tid, &typeinfo);
1512 if(SUCCEEDED(hr))
1514 hr = ITypeInfo_Invoke(typeinfo, &This->IVBSAXLocator_iface, dispIdMember, wFlags,
1515 pDispParams, pVarResult, pExcepInfo, puArgErr);
1516 ITypeInfo_Release(typeinfo);
1519 return hr;
1522 /*** IVBSAXLocator methods ***/
1523 static HRESULT WINAPI ivbsaxlocator_get_columnNumber(
1524 IVBSAXLocator* iface,
1525 int *pnColumn)
1527 saxlocator *This = impl_from_IVBSAXLocator( iface );
1528 return ISAXLocator_getColumnNumber((ISAXLocator*)&This->IVBSAXLocator_iface, pnColumn);
1531 static HRESULT WINAPI ivbsaxlocator_get_lineNumber(
1532 IVBSAXLocator* iface,
1533 int *pnLine)
1535 saxlocator *This = impl_from_IVBSAXLocator( iface );
1536 return ISAXLocator_getLineNumber((ISAXLocator*)&This->IVBSAXLocator_iface, pnLine);
1539 static HRESULT WINAPI ivbsaxlocator_get_publicId(
1540 IVBSAXLocator* iface,
1541 BSTR* publicId)
1543 saxlocator *This = impl_from_IVBSAXLocator( iface );
1544 return ISAXLocator_getPublicId((ISAXLocator*)&This->IVBSAXLocator_iface,
1545 (const WCHAR**)publicId);
1548 static HRESULT WINAPI ivbsaxlocator_get_systemId(
1549 IVBSAXLocator* iface,
1550 BSTR* systemId)
1552 saxlocator *This = impl_from_IVBSAXLocator( iface );
1553 return ISAXLocator_getSystemId((ISAXLocator*)&This->IVBSAXLocator_iface,
1554 (const WCHAR**)systemId);
1557 static const struct IVBSAXLocatorVtbl ivbsaxlocator_vtbl =
1559 ivbsaxlocator_QueryInterface,
1560 ivbsaxlocator_AddRef,
1561 ivbsaxlocator_Release,
1562 ivbsaxlocator_GetTypeInfoCount,
1563 ivbsaxlocator_GetTypeInfo,
1564 ivbsaxlocator_GetIDsOfNames,
1565 ivbsaxlocator_Invoke,
1566 ivbsaxlocator_get_columnNumber,
1567 ivbsaxlocator_get_lineNumber,
1568 ivbsaxlocator_get_publicId,
1569 ivbsaxlocator_get_systemId
1572 /*** ISAXLocator interface ***/
1573 /*** IUnknown methods ***/
1574 static HRESULT WINAPI isaxlocator_QueryInterface(ISAXLocator* iface, REFIID riid, void **ppvObject)
1576 saxlocator *This = impl_from_ISAXLocator( iface );
1578 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
1580 *ppvObject = NULL;
1582 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
1583 IsEqualGUID( riid, &IID_ISAXLocator ))
1585 *ppvObject = iface;
1587 else
1589 FIXME("interface %s not implemented\n", debugstr_guid(riid));
1590 return E_NOINTERFACE;
1593 ISAXLocator_AddRef( iface );
1595 return S_OK;
1598 static ULONG WINAPI isaxlocator_AddRef(ISAXLocator* iface)
1600 saxlocator *This = impl_from_ISAXLocator( iface );
1601 TRACE("%p\n", This );
1602 return InterlockedIncrement( &This->ref );
1605 static ULONG WINAPI isaxlocator_Release(
1606 ISAXLocator* iface)
1608 saxlocator *This = impl_from_ISAXLocator( iface );
1609 LONG ref;
1611 TRACE("%p\n", This );
1613 ref = InterlockedDecrement( &This->ref );
1614 if ( ref == 0 )
1616 SysFreeString(This->publicId);
1617 SysFreeString(This->systemId);
1618 heap_free(This->nsStack);
1620 ISAXXMLReader_Release(&This->saxreader->ISAXXMLReader_iface);
1621 heap_free( This );
1624 return ref;
1627 /*** ISAXLocator methods ***/
1628 static HRESULT WINAPI isaxlocator_getColumnNumber(
1629 ISAXLocator* iface,
1630 int *pnColumn)
1632 saxlocator *This = impl_from_ISAXLocator( iface );
1634 *pnColumn = This->column;
1635 return S_OK;
1638 static HRESULT WINAPI isaxlocator_getLineNumber(
1639 ISAXLocator* iface,
1640 int *pnLine)
1642 saxlocator *This = impl_from_ISAXLocator( iface );
1644 *pnLine = This->line;
1645 return S_OK;
1648 static HRESULT WINAPI isaxlocator_getPublicId(
1649 ISAXLocator* iface,
1650 const WCHAR ** ppwchPublicId)
1652 BSTR publicId;
1653 saxlocator *This = impl_from_ISAXLocator( iface );
1655 SysFreeString(This->publicId);
1657 publicId = bstr_from_xmlChar(xmlSAX2GetPublicId(This->pParserCtxt));
1658 if(SysStringLen(publicId))
1659 This->publicId = (WCHAR*)&publicId;
1660 else
1662 SysFreeString(publicId);
1663 This->publicId = NULL;
1666 *ppwchPublicId = This->publicId;
1667 return S_OK;
1670 static HRESULT WINAPI isaxlocator_getSystemId(
1671 ISAXLocator* iface,
1672 const WCHAR ** ppwchSystemId)
1674 BSTR systemId;
1675 saxlocator *This = impl_from_ISAXLocator( iface );
1677 SysFreeString(This->systemId);
1679 systemId = bstr_from_xmlChar(xmlSAX2GetSystemId(This->pParserCtxt));
1680 if(SysStringLen(systemId))
1681 This->systemId = (WCHAR*)&systemId;
1682 else
1684 SysFreeString(systemId);
1685 This->systemId = NULL;
1688 *ppwchSystemId = This->systemId;
1689 return S_OK;
1692 static const struct ISAXLocatorVtbl isaxlocator_vtbl =
1694 isaxlocator_QueryInterface,
1695 isaxlocator_AddRef,
1696 isaxlocator_Release,
1697 isaxlocator_getColumnNumber,
1698 isaxlocator_getLineNumber,
1699 isaxlocator_getPublicId,
1700 isaxlocator_getSystemId
1703 static HRESULT SAXLocator_create(saxreader *reader, saxlocator **ppsaxlocator, BOOL vbInterface)
1705 saxlocator *locator;
1707 locator = heap_alloc( sizeof (*locator) );
1708 if( !locator )
1709 return E_OUTOFMEMORY;
1711 locator->IVBSAXLocator_iface.lpVtbl = &ivbsaxlocator_vtbl;
1712 locator->ISAXLocator_iface.lpVtbl = &isaxlocator_vtbl;
1713 locator->ref = 1;
1714 locator->vbInterface = vbInterface;
1716 locator->saxreader = reader;
1717 ISAXXMLReader_AddRef(&reader->ISAXXMLReader_iface);
1719 locator->pParserCtxt = NULL;
1720 locator->publicId = NULL;
1721 locator->systemId = NULL;
1722 locator->lastCur = NULL;
1723 locator->line = 0;
1724 locator->column = 0;
1725 locator->ret = S_OK;
1726 locator->nsStackSize = 8;
1727 locator->nsStackLast = 0;
1728 locator->nsStack = heap_alloc(sizeof(int)*locator->nsStackSize);
1729 if(!locator->nsStack)
1731 ISAXXMLReader_Release(&reader->ISAXXMLReader_iface);
1732 heap_free(locator);
1733 return E_OUTOFMEMORY;
1736 *ppsaxlocator = locator;
1738 TRACE("returning %p\n", *ppsaxlocator);
1740 return S_OK;
1743 /*** SAXXMLReader internal functions ***/
1744 static HRESULT internal_parseBuffer(saxreader *This, const char *buffer, int size, BOOL vbInterface)
1746 xmlCharEncoding encoding = XML_CHAR_ENCODING_NONE;
1747 xmlChar *enc_name = NULL;
1748 saxlocator *locator;
1749 HRESULT hr;
1751 hr = SAXLocator_create(This, &locator, vbInterface);
1752 if(FAILED(hr))
1753 return hr;
1755 if (size >= 4)
1757 const unsigned char *buff = (unsigned char*)buffer;
1759 encoding = xmlDetectCharEncoding((xmlChar*)buffer, 4);
1760 enc_name = (xmlChar*)xmlGetCharEncodingName(encoding);
1761 TRACE("detected encoding: %s\n", enc_name);
1762 /* skip BOM, parser won't switch encodings and so won't skip it on its own */
1763 if ((encoding == XML_CHAR_ENCODING_UTF8) &&
1764 buff[0] == 0xEF && buff[1] == 0xBB && buff[2] == 0xBF)
1766 buffer += 3;
1767 size -= 3;
1771 locator->pParserCtxt = xmlCreateMemoryParserCtxt(buffer, size);
1772 if(!locator->pParserCtxt)
1774 ISAXLocator_Release(&locator->ISAXLocator_iface);
1775 return E_FAIL;
1778 if (encoding == XML_CHAR_ENCODING_UTF8)
1779 locator->pParserCtxt->encoding = xmlStrdup(enc_name);
1781 xmlFree(locator->pParserCtxt->sax);
1782 locator->pParserCtxt->sax = &locator->saxreader->sax;
1783 locator->pParserCtxt->userData = locator;
1785 This->isParsing = TRUE;
1786 if(xmlParseDocument(locator->pParserCtxt) == -1) hr = E_FAIL;
1787 else hr = locator->ret;
1788 This->isParsing = FALSE;
1790 if(locator->pParserCtxt)
1792 locator->pParserCtxt->sax = NULL;
1793 xmlFreeParserCtxt(locator->pParserCtxt);
1794 locator->pParserCtxt = NULL;
1797 ISAXLocator_Release(&locator->ISAXLocator_iface);
1798 return hr;
1801 static HRESULT internal_parseStream(saxreader *This, IStream *stream, BOOL vbInterface)
1803 saxlocator *locator;
1804 HRESULT hr;
1805 ULONG dataRead;
1806 char data[1024];
1808 hr = IStream_Read(stream, data, sizeof(data), &dataRead);
1809 if(hr != S_OK)
1810 return hr;
1812 hr = SAXLocator_create(This, &locator, vbInterface);
1813 if(FAILED(hr))
1814 return hr;
1816 locator->pParserCtxt = xmlCreatePushParserCtxt(
1817 &locator->saxreader->sax, locator,
1818 data, dataRead, NULL);
1819 if(!locator->pParserCtxt)
1821 ISAXLocator_Release(&locator->ISAXLocator_iface);
1822 return E_FAIL;
1825 This->isParsing = TRUE;
1826 while(1)
1828 hr = IStream_Read(stream, data, sizeof(data), &dataRead);
1829 if(hr != S_OK)
1830 break;
1832 if(xmlParseChunk(locator->pParserCtxt, data, dataRead, 0) != XML_ERR_OK) hr = E_FAIL;
1833 else hr = locator->ret;
1835 if(hr != S_OK) break;
1837 if(dataRead != sizeof(data))
1839 if(xmlParseChunk(locator->pParserCtxt, data, 0, 1) != XML_ERR_OK) hr = E_FAIL;
1840 else hr = locator->ret;
1842 break;
1845 This->isParsing = FALSE;
1847 xmlFreeParserCtxt(locator->pParserCtxt);
1848 locator->pParserCtxt = NULL;
1849 ISAXLocator_Release(&locator->ISAXLocator_iface);
1850 return hr;
1853 static HRESULT internal_getEntityResolver(
1854 saxreader *This,
1855 void *pEntityResolver,
1856 BOOL vbInterface)
1858 FIXME("(%p)->(%p) stub\n", This, pEntityResolver);
1859 return E_NOTIMPL;
1862 static HRESULT internal_putEntityResolver(
1863 saxreader *This,
1864 void *pEntityResolver,
1865 BOOL vbInterface)
1867 FIXME("(%p)->(%p) stub\n", This, pEntityResolver);
1868 return E_NOTIMPL;
1871 static HRESULT internal_getContentHandler(
1872 saxreader* This,
1873 void *pContentHandler,
1874 BOOL vbInterface)
1876 TRACE("(%p)->(%p)\n", This, pContentHandler);
1877 if(pContentHandler == NULL)
1878 return E_POINTER;
1879 if((vbInterface && This->vbcontentHandler)
1880 || (!vbInterface && This->contentHandler))
1882 if(vbInterface)
1883 IVBSAXContentHandler_AddRef(This->vbcontentHandler);
1884 else
1885 ISAXContentHandler_AddRef(This->contentHandler);
1887 if(vbInterface) *(IVBSAXContentHandler**)pContentHandler =
1888 This->vbcontentHandler;
1889 else *(ISAXContentHandler**)pContentHandler = This->contentHandler;
1891 return S_OK;
1894 static HRESULT internal_putContentHandler(
1895 saxreader* This,
1896 void *contentHandler,
1897 BOOL vbInterface)
1899 TRACE("(%p)->(%p)\n", This, contentHandler);
1900 if(contentHandler)
1902 if(vbInterface)
1903 IVBSAXContentHandler_AddRef((IVBSAXContentHandler*)contentHandler);
1904 else
1905 ISAXContentHandler_AddRef((ISAXContentHandler*)contentHandler);
1907 if((vbInterface && This->vbcontentHandler)
1908 || (!vbInterface && This->contentHandler))
1910 if(vbInterface)
1911 IVBSAXContentHandler_Release(This->vbcontentHandler);
1912 else
1913 ISAXContentHandler_Release(This->contentHandler);
1915 if(vbInterface)
1916 This->vbcontentHandler = contentHandler;
1917 else
1918 This->contentHandler = contentHandler;
1920 return S_OK;
1923 static HRESULT internal_getDTDHandler(
1924 saxreader* This,
1925 void *pDTDHandler,
1926 BOOL vbInterface)
1928 FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
1929 return E_NOTIMPL;
1932 static HRESULT internal_putDTDHandler(
1933 saxreader* This,
1934 void *pDTDHandler,
1935 BOOL vbInterface)
1937 FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
1938 return E_NOTIMPL;
1941 static HRESULT internal_getErrorHandler(
1942 saxreader* This,
1943 void *pErrorHandler,
1944 BOOL vbInterface)
1946 TRACE("(%p)->(%p)\n", This, pErrorHandler);
1947 if(pErrorHandler == NULL)
1948 return E_POINTER;
1950 if(vbInterface && This->vberrorHandler)
1951 IVBSAXErrorHandler_AddRef(This->vberrorHandler);
1952 else if(!vbInterface && This->errorHandler)
1953 ISAXErrorHandler_AddRef(This->errorHandler);
1955 if(vbInterface)
1956 *(IVBSAXErrorHandler**)pErrorHandler = This->vberrorHandler;
1957 else
1958 *(ISAXErrorHandler**)pErrorHandler = This->errorHandler;
1960 return S_OK;
1964 static HRESULT internal_putErrorHandler(
1965 saxreader* This,
1966 void *errorHandler,
1967 BOOL vbInterface)
1969 TRACE("(%p)->(%p)\n", This, errorHandler);
1970 if(errorHandler)
1972 if(vbInterface)
1973 IVBSAXErrorHandler_AddRef((IVBSAXErrorHandler*)errorHandler);
1974 else
1975 ISAXErrorHandler_AddRef((ISAXErrorHandler*)errorHandler);
1978 if(vbInterface && This->vberrorHandler)
1979 IVBSAXErrorHandler_Release(This->vberrorHandler);
1980 else if(!vbInterface && This->errorHandler)
1981 ISAXErrorHandler_Release(This->errorHandler);
1983 if(vbInterface)
1984 This->vberrorHandler = errorHandler;
1985 else
1986 This->errorHandler = errorHandler;
1988 return S_OK;
1992 static HRESULT internal_parse(
1993 saxreader* This,
1994 VARIANT varInput,
1995 BOOL vbInterface)
1997 HRESULT hr;
1999 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varInput));
2001 switch(V_VT(&varInput))
2003 case VT_BSTR:
2004 hr = internal_parseBuffer(This, (const char*)V_BSTR(&varInput),
2005 SysStringByteLen(V_BSTR(&varInput)), vbInterface);
2006 break;
2007 case VT_ARRAY|VT_UI1: {
2008 void *pSAData;
2009 LONG lBound, uBound;
2010 ULONG dataRead;
2012 hr = SafeArrayGetLBound(V_ARRAY(&varInput), 1, &lBound);
2013 if(hr != S_OK) break;
2014 hr = SafeArrayGetUBound(V_ARRAY(&varInput), 1, &uBound);
2015 if(hr != S_OK) break;
2016 dataRead = (uBound-lBound)*SafeArrayGetElemsize(V_ARRAY(&varInput));
2017 hr = SafeArrayAccessData(V_ARRAY(&varInput), &pSAData);
2018 if(hr != S_OK) break;
2019 hr = internal_parseBuffer(This, pSAData, dataRead, vbInterface);
2020 SafeArrayUnaccessData(V_ARRAY(&varInput));
2021 break;
2023 case VT_UNKNOWN:
2024 case VT_DISPATCH: {
2025 IPersistStream *persistStream;
2026 IStream *stream = NULL;
2027 IXMLDOMDocument *xmlDoc;
2029 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput),
2030 &IID_IXMLDOMDocument, (void**)&xmlDoc) == S_OK)
2032 BSTR bstrData;
2034 IXMLDOMDocument_get_xml(xmlDoc, &bstrData);
2035 hr = internal_parseBuffer(This, (const char*)bstrData,
2036 SysStringByteLen(bstrData), vbInterface);
2037 IXMLDOMDocument_Release(xmlDoc);
2038 SysFreeString(bstrData);
2039 break;
2042 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput),
2043 &IID_IPersistStream, (void**)&persistStream) == S_OK)
2045 hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
2046 if(hr != S_OK)
2048 IPersistStream_Release(persistStream);
2049 return hr;
2052 hr = IPersistStream_Save(persistStream, stream, TRUE);
2053 IPersistStream_Release(persistStream);
2054 if(hr != S_OK)
2056 IStream_Release(stream);
2057 break;
2060 if(stream || IUnknown_QueryInterface(V_UNKNOWN(&varInput),
2061 &IID_IStream, (void**)&stream) == S_OK)
2063 hr = internal_parseStream(This, stream, vbInterface);
2064 IStream_Release(stream);
2065 break;
2068 default:
2069 WARN("vt %d not implemented\n", V_VT(&varInput));
2070 hr = E_INVALIDARG;
2073 return hr;
2076 static HRESULT internal_vbonDataAvailable(void *obj, char *ptr, DWORD len)
2078 saxreader *This = obj;
2080 return internal_parseBuffer(This, ptr, len, TRUE);
2083 static HRESULT internal_onDataAvailable(void *obj, char *ptr, DWORD len)
2085 saxreader *This = obj;
2087 return internal_parseBuffer(This, ptr, len, FALSE);
2090 static HRESULT internal_parseURL(
2091 saxreader* This,
2092 const WCHAR *url,
2093 BOOL vbInterface)
2095 bsc_t *bsc;
2096 HRESULT hr;
2098 TRACE("(%p)->(%s)\n", This, debugstr_w(url));
2100 if(vbInterface) hr = bind_url(url, internal_vbonDataAvailable, This, &bsc);
2101 else hr = bind_url(url, internal_onDataAvailable, This, &bsc);
2103 if(FAILED(hr))
2104 return hr;
2106 detach_bsc(bsc);
2108 return S_OK;
2111 static HRESULT internal_putProperty(
2112 saxreader* This,
2113 const WCHAR *pProp,
2114 VARIANT value,
2115 BOOL vbInterface)
2117 static const WCHAR wszCharset[] = {
2118 'c','h','a','r','s','e','t',0
2120 static const WCHAR wszDeclarationHandler[] = {
2121 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
2122 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
2123 'd','e','c','l','a','r','a','t','i','o','n',
2124 '-','h','a','n','d','l','e','r',0
2126 static const WCHAR wszDomNode[] = {
2127 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
2128 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
2129 'd','o','m','-','n','o','d','e',0
2131 static const WCHAR wszInputSource[] = {
2132 'i','n','p','u','t','-','s','o','u','r','c','e',0
2134 static const WCHAR wszLexicalHandler[] = {
2135 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
2136 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
2137 'l','e','x','i','c','a','l','-','h','a','n','d','l','e','r',0
2139 static const WCHAR wszMaxElementDepth[] = {
2140 'm','a','x','-','e','l','e','m','e','n','t','-','d','e','p','t','h',0
2142 static const WCHAR wszMaxXMLSize[] = {
2143 'm','a','x','-','x','m','l','-','s','i','z','e',0
2145 static const WCHAR wszSchemaDeclarationHandler[] = {
2146 's','c','h','e','m','a','-',
2147 'd','e','c','l','a','r','a','t','i','o','n','-',
2148 'h','a','n','d','l','e','r',0
2150 static const WCHAR wszXMLDeclEncoding[] = {
2151 'x','m','l','d','e','c','l','-','e','n','c','o','d','i','n','g',0
2153 static const WCHAR wszXMLDeclStandalone[] = {
2154 'x','m','l','d','e','c','l',
2155 '-','s','t','a','n','d','a','l','o','n','e',0
2157 static const WCHAR wszXMLDeclVersion[] = {
2158 'x','m','l','d','e','c','l','-','v','e','r','s','i','o','n',0
2161 TRACE("(%p)->(%s %s)\n", This, debugstr_w(pProp), debugstr_variant(&value));
2163 if(!memcmp(pProp, wszDeclarationHandler, sizeof(wszDeclarationHandler)))
2165 if(This->isParsing) return E_FAIL;
2167 if(V_UNKNOWN(&value))
2169 if(vbInterface)
2170 IVBSAXDeclHandler_AddRef((IVBSAXDeclHandler*)V_UNKNOWN(&value));
2171 else
2172 ISAXDeclHandler_AddRef((ISAXDeclHandler*)V_UNKNOWN(&value));
2174 if((vbInterface && This->vbdeclHandler)
2175 || (!vbInterface && This->declHandler))
2177 if(vbInterface)
2178 IVBSAXDeclHandler_Release(This->vbdeclHandler);
2179 else
2180 ISAXDeclHandler_Release(This->declHandler);
2182 if(vbInterface)
2183 This->vbdeclHandler = (IVBSAXDeclHandler*)V_UNKNOWN(&value);
2184 else
2185 This->declHandler = (ISAXDeclHandler*)V_UNKNOWN(&value);
2186 return S_OK;
2189 if(!memcmp(pProp, wszLexicalHandler, sizeof(wszLexicalHandler)))
2191 if(This->isParsing) return E_FAIL;
2193 if(V_UNKNOWN(&value))
2195 if(vbInterface)
2196 IVBSAXLexicalHandler_AddRef(
2197 (IVBSAXLexicalHandler*)V_UNKNOWN(&value));
2198 else
2199 ISAXLexicalHandler_AddRef(
2200 (ISAXLexicalHandler*)V_UNKNOWN(&value));
2202 if((vbInterface && This->vblexicalHandler)
2203 || (!vbInterface && This->lexicalHandler))
2205 if(vbInterface)
2206 IVBSAXLexicalHandler_Release(This->vblexicalHandler);
2207 else
2208 ISAXLexicalHandler_Release(This->lexicalHandler);
2210 if(vbInterface)
2211 This->vblexicalHandler = (IVBSAXLexicalHandler*)V_UNKNOWN(&value);
2212 else
2213 This->lexicalHandler = (ISAXLexicalHandler*)V_UNKNOWN(&value);
2214 return S_OK;
2217 FIXME("(%p)->(%s): unsupported property\n", This, debugstr_w(pProp));
2219 if(!memcmp(pProp, wszCharset, sizeof(wszCharset)))
2220 return E_NOTIMPL;
2222 if(!memcmp(pProp, wszDomNode, sizeof(wszDomNode)))
2223 return E_FAIL;
2225 if(!memcmp(pProp, wszInputSource, sizeof(wszInputSource)))
2226 return E_NOTIMPL;
2228 if(!memcmp(pProp, wszMaxElementDepth, sizeof(wszMaxElementDepth)))
2229 return E_NOTIMPL;
2231 if(!memcmp(pProp, wszMaxXMLSize, sizeof(wszMaxXMLSize)))
2232 return E_NOTIMPL;
2234 if(!memcmp(pProp, wszSchemaDeclarationHandler,
2235 sizeof(wszSchemaDeclarationHandler)))
2236 return E_NOTIMPL;
2238 if(!memcmp(pProp, wszXMLDeclEncoding, sizeof(wszXMLDeclEncoding)))
2239 return E_FAIL;
2241 if(!memcmp(pProp, wszXMLDeclStandalone, sizeof(wszXMLDeclStandalone)))
2242 return E_FAIL;
2244 if(!memcmp(pProp, wszXMLDeclVersion, sizeof(wszXMLDeclVersion)))
2245 return E_FAIL;
2247 return E_INVALIDARG;
2250 /*** IVBSAXXMLReader interface ***/
2251 /*** IUnknown methods ***/
2252 static HRESULT WINAPI saxxmlreader_QueryInterface(IVBSAXXMLReader* iface, REFIID riid, void **ppvObject)
2254 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2256 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
2258 *ppvObject = NULL;
2260 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
2261 IsEqualGUID( riid, &IID_IDispatch ) ||
2262 IsEqualGUID( riid, &IID_IVBSAXXMLReader ))
2264 *ppvObject = iface;
2266 else if( IsEqualGUID( riid, &IID_ISAXXMLReader ))
2268 *ppvObject = &This->ISAXXMLReader_iface;
2270 else
2272 FIXME("interface %s not implemented\n", debugstr_guid(riid));
2273 return E_NOINTERFACE;
2276 IVBSAXXMLReader_AddRef( iface );
2278 return S_OK;
2281 static ULONG WINAPI saxxmlreader_AddRef(IVBSAXXMLReader* iface)
2283 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2284 TRACE("%p\n", This );
2285 return InterlockedIncrement( &This->ref );
2288 static ULONG WINAPI saxxmlreader_Release(
2289 IVBSAXXMLReader* iface)
2291 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2292 LONG ref;
2294 TRACE("%p\n", This );
2296 ref = InterlockedDecrement( &This->ref );
2297 if ( ref == 0 )
2299 if(This->contentHandler)
2300 ISAXContentHandler_Release(This->contentHandler);
2302 if(This->vbcontentHandler)
2303 IVBSAXContentHandler_Release(This->vbcontentHandler);
2305 if(This->errorHandler)
2306 ISAXErrorHandler_Release(This->errorHandler);
2308 if(This->vberrorHandler)
2309 IVBSAXErrorHandler_Release(This->vberrorHandler);
2311 if(This->lexicalHandler)
2312 ISAXLexicalHandler_Release(This->lexicalHandler);
2314 if(This->vblexicalHandler)
2315 IVBSAXLexicalHandler_Release(This->vblexicalHandler);
2317 if(This->declHandler)
2318 ISAXDeclHandler_Release(This->declHandler);
2320 if(This->vbdeclHandler)
2321 IVBSAXDeclHandler_Release(This->vbdeclHandler);
2323 heap_free( This );
2326 return ref;
2328 /*** IDispatch ***/
2329 static HRESULT WINAPI saxxmlreader_GetTypeInfoCount( IVBSAXXMLReader *iface, UINT* pctinfo )
2331 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2333 TRACE("(%p)->(%p)\n", This, pctinfo);
2335 *pctinfo = 1;
2337 return S_OK;
2340 static HRESULT WINAPI saxxmlreader_GetTypeInfo(
2341 IVBSAXXMLReader *iface,
2342 UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
2344 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2345 HRESULT hr;
2347 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
2349 hr = get_typeinfo(IVBSAXXMLReader_tid, ppTInfo);
2351 return hr;
2354 static HRESULT WINAPI saxxmlreader_GetIDsOfNames(
2355 IVBSAXXMLReader *iface,
2356 REFIID riid,
2357 LPOLESTR* rgszNames,
2358 UINT cNames,
2359 LCID lcid,
2360 DISPID* rgDispId)
2362 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2363 ITypeInfo *typeinfo;
2364 HRESULT hr;
2366 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
2367 lcid, rgDispId);
2369 if(!rgszNames || cNames == 0 || !rgDispId)
2370 return E_INVALIDARG;
2372 hr = get_typeinfo(IVBSAXXMLReader_tid, &typeinfo);
2373 if(SUCCEEDED(hr))
2375 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
2376 ITypeInfo_Release(typeinfo);
2379 return hr;
2382 static HRESULT WINAPI saxxmlreader_Invoke(
2383 IVBSAXXMLReader *iface,
2384 DISPID dispIdMember,
2385 REFIID riid,
2386 LCID lcid,
2387 WORD wFlags,
2388 DISPPARAMS* pDispParams,
2389 VARIANT* pVarResult,
2390 EXCEPINFO* pExcepInfo,
2391 UINT* puArgErr)
2393 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2394 ITypeInfo *typeinfo;
2395 HRESULT hr;
2397 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
2398 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2400 hr = get_typeinfo(IVBSAXXMLReader_tid, &typeinfo);
2401 if(SUCCEEDED(hr))
2403 hr = ITypeInfo_Invoke(typeinfo, &This->IVBSAXXMLReader_iface, dispIdMember, wFlags,
2404 pDispParams, pVarResult, pExcepInfo, puArgErr);
2405 ITypeInfo_Release(typeinfo);
2408 return hr;
2411 /*** IVBSAXXMLReader methods ***/
2412 static HRESULT WINAPI saxxmlreader_getFeature(
2413 IVBSAXXMLReader* iface,
2414 const WCHAR *pFeature,
2415 VARIANT_BOOL *pValue)
2417 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2419 FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(pFeature), pValue);
2420 return E_NOTIMPL;
2423 static HRESULT WINAPI saxxmlreader_putFeature(
2424 IVBSAXXMLReader* iface,
2425 const WCHAR *pFeature,
2426 VARIANT_BOOL vfValue)
2428 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2430 FIXME("(%p)->(%s %x) stub\n", This, debugstr_w(pFeature), vfValue);
2431 return E_NOTIMPL;
2434 static HRESULT WINAPI saxxmlreader_getProperty(
2435 IVBSAXXMLReader* iface,
2436 const WCHAR *pProp,
2437 VARIANT *pValue)
2439 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2441 FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(pProp), pValue);
2442 return E_NOTIMPL;
2445 static HRESULT WINAPI saxxmlreader_putProperty(
2446 IVBSAXXMLReader* iface,
2447 const WCHAR *pProp,
2448 VARIANT value)
2450 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2451 return internal_putProperty(This, pProp, value, TRUE);
2454 static HRESULT WINAPI saxxmlreader_get_entityResolver(
2455 IVBSAXXMLReader* iface,
2456 IVBSAXEntityResolver **pEntityResolver)
2458 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2459 return internal_getEntityResolver(This, pEntityResolver, TRUE);
2462 static HRESULT WINAPI saxxmlreader_put_entityResolver(
2463 IVBSAXXMLReader* iface,
2464 IVBSAXEntityResolver *pEntityResolver)
2466 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2467 return internal_putEntityResolver(This, pEntityResolver, TRUE);
2470 static HRESULT WINAPI saxxmlreader_get_contentHandler(
2471 IVBSAXXMLReader* iface,
2472 IVBSAXContentHandler **ppContentHandler)
2474 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2475 return internal_getContentHandler(This, ppContentHandler, TRUE);
2478 static HRESULT WINAPI saxxmlreader_put_contentHandler(
2479 IVBSAXXMLReader* iface,
2480 IVBSAXContentHandler *contentHandler)
2482 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2483 return internal_putContentHandler(This, contentHandler, TRUE);
2486 static HRESULT WINAPI saxxmlreader_get_dtdHandler(
2487 IVBSAXXMLReader* iface,
2488 IVBSAXDTDHandler **pDTDHandler)
2490 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2491 return internal_getDTDHandler(This, pDTDHandler, TRUE);
2494 static HRESULT WINAPI saxxmlreader_put_dtdHandler(
2495 IVBSAXXMLReader* iface,
2496 IVBSAXDTDHandler *pDTDHandler)
2498 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2499 return internal_putDTDHandler(This, pDTDHandler, TRUE);
2502 static HRESULT WINAPI saxxmlreader_get_errorHandler(
2503 IVBSAXXMLReader* iface,
2504 IVBSAXErrorHandler **pErrorHandler)
2506 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2507 return internal_getErrorHandler(This, pErrorHandler, TRUE);
2510 static HRESULT WINAPI saxxmlreader_put_errorHandler(
2511 IVBSAXXMLReader* iface,
2512 IVBSAXErrorHandler *errorHandler)
2514 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2515 return internal_putErrorHandler(This, errorHandler, TRUE);
2518 static HRESULT WINAPI saxxmlreader_get_baseURL(
2519 IVBSAXXMLReader* iface,
2520 const WCHAR **pBaseUrl)
2522 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2524 FIXME("(%p)->(%p) stub\n", This, pBaseUrl);
2525 return E_NOTIMPL;
2528 static HRESULT WINAPI saxxmlreader_put_baseURL(
2529 IVBSAXXMLReader* iface,
2530 const WCHAR *pBaseUrl)
2532 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2534 FIXME("(%p)->(%s) stub\n", This, debugstr_w(pBaseUrl));
2535 return E_NOTIMPL;
2538 static HRESULT WINAPI saxxmlreader_get_secureBaseURL(
2539 IVBSAXXMLReader* iface,
2540 const WCHAR **pSecureBaseUrl)
2542 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2544 FIXME("(%p)->(%p) stub\n", This, pSecureBaseUrl);
2545 return E_NOTIMPL;
2549 static HRESULT WINAPI saxxmlreader_put_secureBaseURL(
2550 IVBSAXXMLReader* iface,
2551 const WCHAR *secureBaseUrl)
2553 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2555 FIXME("(%p)->(%s) stub\n", This, debugstr_w(secureBaseUrl));
2556 return E_NOTIMPL;
2559 static HRESULT WINAPI saxxmlreader_parse(
2560 IVBSAXXMLReader* iface,
2561 VARIANT varInput)
2563 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2564 return internal_parse(This, varInput, TRUE);
2567 static HRESULT WINAPI saxxmlreader_parseURL(
2568 IVBSAXXMLReader* iface,
2569 const WCHAR *url)
2571 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2572 return internal_parseURL(This, url, TRUE);
2575 static const struct IVBSAXXMLReaderVtbl saxreader_vtbl =
2577 saxxmlreader_QueryInterface,
2578 saxxmlreader_AddRef,
2579 saxxmlreader_Release,
2580 saxxmlreader_GetTypeInfoCount,
2581 saxxmlreader_GetTypeInfo,
2582 saxxmlreader_GetIDsOfNames,
2583 saxxmlreader_Invoke,
2584 saxxmlreader_getFeature,
2585 saxxmlreader_putFeature,
2586 saxxmlreader_getProperty,
2587 saxxmlreader_putProperty,
2588 saxxmlreader_get_entityResolver,
2589 saxxmlreader_put_entityResolver,
2590 saxxmlreader_get_contentHandler,
2591 saxxmlreader_put_contentHandler,
2592 saxxmlreader_get_dtdHandler,
2593 saxxmlreader_put_dtdHandler,
2594 saxxmlreader_get_errorHandler,
2595 saxxmlreader_put_errorHandler,
2596 saxxmlreader_get_baseURL,
2597 saxxmlreader_put_baseURL,
2598 saxxmlreader_get_secureBaseURL,
2599 saxxmlreader_put_secureBaseURL,
2600 saxxmlreader_parse,
2601 saxxmlreader_parseURL
2604 /*** ISAXXMLReader interface ***/
2605 /*** IUnknown methods ***/
2606 static HRESULT WINAPI isaxxmlreader_QueryInterface(ISAXXMLReader* iface, REFIID riid, void **ppvObject)
2608 saxreader *This = impl_from_ISAXXMLReader( iface );
2609 return saxxmlreader_QueryInterface(&This->IVBSAXXMLReader_iface, riid, ppvObject);
2612 static ULONG WINAPI isaxxmlreader_AddRef(ISAXXMLReader* iface)
2614 saxreader *This = impl_from_ISAXXMLReader( iface );
2615 return saxxmlreader_AddRef(&This->IVBSAXXMLReader_iface);
2618 static ULONG WINAPI isaxxmlreader_Release(ISAXXMLReader* iface)
2620 saxreader *This = impl_from_ISAXXMLReader( iface );
2621 return saxxmlreader_Release(&This->IVBSAXXMLReader_iface);
2624 /*** ISAXXMLReader methods ***/
2625 static HRESULT WINAPI isaxxmlreader_getFeature(
2626 ISAXXMLReader* iface,
2627 const WCHAR *pFeature,
2628 VARIANT_BOOL *pValue)
2630 saxreader *This = impl_from_ISAXXMLReader( iface );
2631 return IVBSAXXMLReader_getFeature(&This->IVBSAXXMLReader_iface, pFeature, pValue);
2634 static HRESULT WINAPI isaxxmlreader_putFeature(
2635 ISAXXMLReader* iface,
2636 const WCHAR *pFeature,
2637 VARIANT_BOOL vfValue)
2639 saxreader *This = impl_from_ISAXXMLReader( iface );
2640 return IVBSAXXMLReader_putFeature(&This->IVBSAXXMLReader_iface, pFeature, vfValue);
2643 static HRESULT WINAPI isaxxmlreader_getProperty(
2644 ISAXXMLReader* iface,
2645 const WCHAR *pProp,
2646 VARIANT *pValue)
2648 saxreader *This = impl_from_ISAXXMLReader( iface );
2649 return IVBSAXXMLReader_getProperty(&This->IVBSAXXMLReader_iface, pProp, pValue);
2652 static HRESULT WINAPI isaxxmlreader_putProperty(
2653 ISAXXMLReader* iface,
2654 const WCHAR *pProp,
2655 VARIANT value)
2657 saxreader *This = impl_from_ISAXXMLReader( iface );
2658 return internal_putProperty(This, pProp, value, FALSE);
2661 static HRESULT WINAPI isaxxmlreader_getEntityResolver(
2662 ISAXXMLReader* iface,
2663 ISAXEntityResolver **ppEntityResolver)
2665 saxreader *This = impl_from_ISAXXMLReader( iface );
2666 return internal_getEntityResolver(This, ppEntityResolver, FALSE);
2669 static HRESULT WINAPI isaxxmlreader_putEntityResolver(
2670 ISAXXMLReader* iface,
2671 ISAXEntityResolver *pEntityResolver)
2673 saxreader *This = impl_from_ISAXXMLReader( iface );
2674 return internal_putEntityResolver(This, pEntityResolver, FALSE);
2677 static HRESULT WINAPI isaxxmlreader_getContentHandler(
2678 ISAXXMLReader* iface,
2679 ISAXContentHandler **pContentHandler)
2681 saxreader *This = impl_from_ISAXXMLReader( iface );
2682 return internal_getContentHandler(This, pContentHandler, FALSE);
2685 static HRESULT WINAPI isaxxmlreader_putContentHandler(
2686 ISAXXMLReader* iface,
2687 ISAXContentHandler *contentHandler)
2689 saxreader *This = impl_from_ISAXXMLReader( iface );
2690 return internal_putContentHandler(This, contentHandler, FALSE);
2693 static HRESULT WINAPI isaxxmlreader_getDTDHandler(
2694 ISAXXMLReader* iface,
2695 ISAXDTDHandler **pDTDHandler)
2697 saxreader *This = impl_from_ISAXXMLReader( iface );
2698 return internal_getDTDHandler(This, pDTDHandler, FALSE);
2701 static HRESULT WINAPI isaxxmlreader_putDTDHandler(
2702 ISAXXMLReader* iface,
2703 ISAXDTDHandler *pDTDHandler)
2705 saxreader *This = impl_from_ISAXXMLReader( iface );
2706 return internal_putDTDHandler(This, pDTDHandler, FALSE);
2709 static HRESULT WINAPI isaxxmlreader_getErrorHandler(
2710 ISAXXMLReader* iface,
2711 ISAXErrorHandler **pErrorHandler)
2713 saxreader *This = impl_from_ISAXXMLReader( iface );
2714 return internal_getErrorHandler(This, pErrorHandler, FALSE);
2717 static HRESULT WINAPI isaxxmlreader_putErrorHandler(
2718 ISAXXMLReader* iface,
2719 ISAXErrorHandler *errorHandler)
2721 saxreader *This = impl_from_ISAXXMLReader( iface );
2722 return internal_putErrorHandler(This, errorHandler, FALSE);
2725 static HRESULT WINAPI isaxxmlreader_getBaseURL(
2726 ISAXXMLReader* iface,
2727 const WCHAR **pBaseUrl)
2729 saxreader *This = impl_from_ISAXXMLReader( iface );
2730 return IVBSAXXMLReader_get_baseURL(&This->IVBSAXXMLReader_iface, pBaseUrl);
2733 static HRESULT WINAPI isaxxmlreader_putBaseURL(
2734 ISAXXMLReader* iface,
2735 const WCHAR *pBaseUrl)
2737 saxreader *This = impl_from_ISAXXMLReader( iface );
2738 return IVBSAXXMLReader_put_baseURL(&This->IVBSAXXMLReader_iface, pBaseUrl);
2741 static HRESULT WINAPI isaxxmlreader_getSecureBaseURL(
2742 ISAXXMLReader* iface,
2743 const WCHAR **pSecureBaseUrl)
2745 saxreader *This = impl_from_ISAXXMLReader( iface );
2746 return IVBSAXXMLReader_get_secureBaseURL(&This->IVBSAXXMLReader_iface, pSecureBaseUrl);
2749 static HRESULT WINAPI isaxxmlreader_putSecureBaseURL(
2750 ISAXXMLReader* iface,
2751 const WCHAR *secureBaseUrl)
2753 saxreader *This = impl_from_ISAXXMLReader( iface );
2754 return IVBSAXXMLReader_put_secureBaseURL(&This->IVBSAXXMLReader_iface, secureBaseUrl);
2757 static HRESULT WINAPI isaxxmlreader_parse(
2758 ISAXXMLReader* iface,
2759 VARIANT varInput)
2761 saxreader *This = impl_from_ISAXXMLReader( iface );
2762 return internal_parse(This, varInput, FALSE);
2765 static HRESULT WINAPI isaxxmlreader_parseURL(
2766 ISAXXMLReader* iface,
2767 const WCHAR *url)
2769 saxreader *This = impl_from_ISAXXMLReader( iface );
2770 return internal_parseURL(This, url, FALSE);
2773 static const struct ISAXXMLReaderVtbl isaxreader_vtbl =
2775 isaxxmlreader_QueryInterface,
2776 isaxxmlreader_AddRef,
2777 isaxxmlreader_Release,
2778 isaxxmlreader_getFeature,
2779 isaxxmlreader_putFeature,
2780 isaxxmlreader_getProperty,
2781 isaxxmlreader_putProperty,
2782 isaxxmlreader_getEntityResolver,
2783 isaxxmlreader_putEntityResolver,
2784 isaxxmlreader_getContentHandler,
2785 isaxxmlreader_putContentHandler,
2786 isaxxmlreader_getDTDHandler,
2787 isaxxmlreader_putDTDHandler,
2788 isaxxmlreader_getErrorHandler,
2789 isaxxmlreader_putErrorHandler,
2790 isaxxmlreader_getBaseURL,
2791 isaxxmlreader_putBaseURL,
2792 isaxxmlreader_getSecureBaseURL,
2793 isaxxmlreader_putSecureBaseURL,
2794 isaxxmlreader_parse,
2795 isaxxmlreader_parseURL
2798 HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj)
2800 saxreader *reader;
2802 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
2804 reader = heap_alloc( sizeof (*reader) );
2805 if( !reader )
2806 return E_OUTOFMEMORY;
2808 reader->IVBSAXXMLReader_iface.lpVtbl = &saxreader_vtbl;
2809 reader->ISAXXMLReader_iface.lpVtbl = &isaxreader_vtbl;
2810 reader->ref = 1;
2811 reader->contentHandler = NULL;
2812 reader->vbcontentHandler = NULL;
2813 reader->errorHandler = NULL;
2814 reader->vberrorHandler = NULL;
2815 reader->lexicalHandler = NULL;
2816 reader->vblexicalHandler = NULL;
2817 reader->declHandler = NULL;
2818 reader->vbdeclHandler = NULL;
2819 reader->isParsing = FALSE;
2821 memset(&reader->sax, 0, sizeof(xmlSAXHandler));
2822 reader->sax.initialized = XML_SAX2_MAGIC;
2823 reader->sax.startDocument = libxmlStartDocument;
2824 reader->sax.endDocument = libxmlEndDocument;
2825 reader->sax.startElementNs = libxmlStartElementNS;
2826 reader->sax.endElementNs = libxmlEndElementNS;
2827 reader->sax.characters = libxmlCharacters;
2828 reader->sax.setDocumentLocator = libxmlSetDocumentLocator;
2829 reader->sax.comment = libxmlComment;
2830 reader->sax.error = libxmlFatalError;
2831 reader->sax.fatalError = libxmlFatalError;
2832 reader->sax.cdataBlock = libxmlCDataBlock;
2834 *ppObj = &reader->IVBSAXXMLReader_iface;
2836 TRACE("returning iface %p\n", *ppObj);
2838 return S_OK;
2841 #else
2843 HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj)
2845 MESSAGE("This program tried to use a SAX XML Reader object, but\n"
2846 "libxml2 support was not present at compile time.\n");
2847 return E_NOTIMPL;
2850 #endif