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
27 # include <libxml/parser.h>
28 # include <libxml/xmlerror.h>
29 # include <libxml/SAX2.h>
30 # include <libxml/parserInternals.h>
44 #include "wine/debug.h"
45 #include "wine/list.h"
47 #include "msxml_private.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
56 ExhaustiveErrors = 1 << 1,
57 ExternalGeneralEntities = 1 << 2,
58 ExternalParameterEntities = 1 << 3,
59 ForcedResync = 1 << 4,
60 NamespacePrefixes = 1 << 5,
62 ParameterEntities = 1 << 7,
63 PreserveSystemIndentifiers = 1 << 8,
65 SchemaValidation = 1 << 10,
66 ServerHttpRequest = 1 << 11,
67 SuppressValidationfatalError = 1 << 12,
68 UseInlineSchema = 1 << 13,
69 UseSchemaLocation = 1 << 14,
70 LexicalHandlerParEntities = 1 << 15
74 static const WCHAR FeatureExternalGeneralEntitiesW[] = {
75 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/',
76 'f','e','a','t','u','r','e','s','/','e','x','t','e','r','n','a','l','-','g','e','n','e','r','a','l',
77 '-','e','n','t','i','t','i','e','s',0
80 static const WCHAR FeatureExternalParameterEntitiesW[] = {
81 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/','f','e','a','t','u','r','e','s',
82 '/','e','x','t','e','r','n','a','l','-','p','a','r','a','m','e','t','e','r','-','e','n','t','i','t','i','e','s',0
85 static const WCHAR FeatureLexicalHandlerParEntitiesW[] = {
86 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/','f','e','a','t','u','r','e','s',
87 '/','l','e','x','i','c','a','l','-','h','a','n','d','l','e','r','/','p','a','r','a','m','e','t','e','r','-','e','n','t','i','t','i','e','s',0
90 static const WCHAR FeatureProhibitDTDW[] = {
91 'p','r','o','h','i','b','i','t','-','d','t','d',0
94 static const WCHAR FeatureNamespacesW[] = {
95 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/','f','e','a','t','u','r','e','s',
96 '/','n','a','m','e','s','p','a','c','e','s',0
99 static const WCHAR FeatureNamespacePrefixesW[] = {
100 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/','f','e','a','t','u','r','e','s',
101 '/','n','a','m','e','s','p','a','c','e','-','p','r','e','f','i','x','e','s',0
104 struct saxreader_feature_pair
106 saxreader_feature feature;
110 static const struct saxreader_feature_pair saxreader_feature_map[] = {
111 { ExternalGeneralEntities, FeatureExternalGeneralEntitiesW },
112 { ExternalParameterEntities, FeatureExternalParameterEntitiesW },
113 { LexicalHandlerParEntities, FeatureLexicalHandlerParEntitiesW },
114 { NamespacePrefixes, FeatureNamespacePrefixesW },
115 { Namespaces, FeatureNamespacesW },
116 { ProhibitDTD, FeatureProhibitDTDW }
119 static saxreader_feature get_saxreader_feature(const WCHAR *name)
124 max = sizeof(saxreader_feature_map)/sizeof(struct saxreader_feature_pair) - 1;
130 c = strcmpW(saxreader_feature_map[n].name, name);
132 return saxreader_feature_map[n].feature;
140 return FeatureUnknown;
162 ns *ns; /* namespaces defined in this particular element */
168 SAXContentHandler = 0,
177 struct saxanyhandler_iface
183 struct saxcontenthandler_iface
185 ISAXContentHandler *handler;
186 IVBSAXContentHandler *vbhandler;
189 struct saxerrorhandler_iface
191 ISAXErrorHandler *handler;
192 IVBSAXErrorHandler *vbhandler;
195 struct saxlexicalhandler_iface
197 ISAXLexicalHandler *handler;
198 IVBSAXLexicalHandler *vbhandler;
201 struct saxentityresolver_iface
203 ISAXEntityResolver *handler;
204 IVBSAXEntityResolver *vbhandler;
207 struct saxhandler_iface
210 struct saxcontenthandler_iface content;
211 struct saxentityresolver_iface entityresolver;
212 struct saxerrorhandler_iface error;
213 struct saxlexicalhandler_iface lexical;
214 struct saxanyhandler_iface anyhandler;
221 IVBSAXXMLReader IVBSAXXMLReader_iface;
222 ISAXXMLReader ISAXXMLReader_iface;
225 struct saxhandler_iface saxhandlers[SAXHandler_Last];
228 struct bstrpool pool;
229 saxreader_feature features;
230 BSTR xmldecl_version;
231 MSXML_VERSION version;
234 static HRESULT saxreader_put_handler(saxreader *reader, enum saxhandler_type type, void *ptr, BOOL vb)
236 struct saxanyhandler_iface *iface = &reader->saxhandlers[type].u.anyhandler;
237 IUnknown *unk = (IUnknown*)ptr;
240 IUnknown_AddRef(unk);
242 if ((vb && iface->vbhandler) || (!vb && iface->handler))
243 IUnknown_Release(vb ? iface->vbhandler : iface->handler);
246 iface->vbhandler = unk;
248 iface->handler = unk;
253 static HRESULT saxreader_get_handler(const saxreader *reader, enum saxhandler_type type, BOOL vb, void **ret)
255 const struct saxanyhandler_iface *iface = &reader->saxhandlers[type].u.anyhandler;
257 if (!ret) return E_POINTER;
259 if ((vb && iface->vbhandler) || (!vb && iface->handler))
262 IUnknown_AddRef(iface->vbhandler);
264 IUnknown_AddRef(iface->handler);
267 *ret = vb ? iface->vbhandler : iface->handler;
272 static struct saxcontenthandler_iface *saxreader_get_contenthandler(saxreader *reader)
274 return &reader->saxhandlers[SAXContentHandler].u.content;
277 static struct saxerrorhandler_iface *saxreader_get_errorhandler(saxreader *reader)
279 return &reader->saxhandlers[SAXErrorHandler].u.error;
282 static struct saxlexicalhandler_iface *saxreader_get_lexicalhandler(saxreader *reader)
284 return &reader->saxhandlers[SAXLexicalHandler].u.lexical;
289 IVBSAXLocator IVBSAXLocator_iface;
290 ISAXLocator ISAXLocator_iface;
291 IVBSAXAttributes IVBSAXAttributes_iface;
292 ISAXAttributes ISAXAttributes_iface;
294 saxreader *saxreader;
296 xmlParserCtxtPtr pParserCtxt;
302 struct list elements;
316 static inline saxreader *impl_from_IVBSAXXMLReader( IVBSAXXMLReader *iface )
318 return CONTAINING_RECORD(iface, saxreader, IVBSAXXMLReader_iface);
321 static inline saxreader *impl_from_ISAXXMLReader( ISAXXMLReader *iface )
323 return CONTAINING_RECORD(iface, saxreader, ISAXXMLReader_iface);
326 static inline saxlocator *impl_from_IVBSAXLocator( IVBSAXLocator *iface )
328 return CONTAINING_RECORD(iface, saxlocator, IVBSAXLocator_iface);
331 static inline saxlocator *impl_from_ISAXLocator( ISAXLocator *iface )
333 return CONTAINING_RECORD(iface, saxlocator, ISAXLocator_iface);
336 static inline saxlocator *impl_from_IVBSAXAttributes( IVBSAXAttributes *iface )
338 return CONTAINING_RECORD(iface, saxlocator, IVBSAXAttributes_iface);
341 static inline saxlocator *impl_from_ISAXAttributes( ISAXAttributes *iface )
343 return CONTAINING_RECORD(iface, saxlocator, ISAXAttributes_iface);
346 static inline int saxreader_has_handler(const saxlocator *locator, enum saxhandler_type type)
348 struct saxanyhandler_iface *iface = &locator->saxreader->saxhandlers[type].u.anyhandler;
349 return (locator->vbInterface && iface->vbhandler) || (!locator->vbInterface && iface->handler);
353 static const WCHAR PropertyCharsetW[] = {
354 'c','h','a','r','s','e','t',0
356 static const WCHAR PropertyXmlDeclVersionW[] = {
357 'x','m','l','d','e','c','l','-','v','e','r','s','i','o','n',0
359 static const WCHAR PropertyDeclHandlerW[] = {
360 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
361 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
362 'd','e','c','l','a','r','a','t','i','o','n',
363 '-','h','a','n','d','l','e','r',0
365 static const WCHAR PropertyDomNodeW[] = {
366 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
367 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
368 'd','o','m','-','n','o','d','e',0
370 static const WCHAR PropertyInputSourceW[] = {
371 'i','n','p','u','t','-','s','o','u','r','c','e',0
373 static const WCHAR PropertyLexicalHandlerW[] = {
374 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
375 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
376 'l','e','x','i','c','a','l','-','h','a','n','d','l','e','r',0
378 static const WCHAR PropertyMaxElementDepthW[] = {
379 'm','a','x','-','e','l','e','m','e','n','t','-','d','e','p','t','h',0
381 static const WCHAR PropertyMaxXMLSizeW[] = {
382 'm','a','x','-','x','m','l','-','s','i','z','e',0
384 static const WCHAR PropertySchemaDeclHandlerW[] = {
385 's','c','h','e','m','a','-','d','e','c','l','a','r','a','t','i','o','n','-',
386 'h','a','n','d','l','e','r',0
388 static const WCHAR PropertyXMLDeclEncodingW[] = {
389 'x','m','l','d','e','c','l','-','e','n','c','o','d','i','n','g',0
391 static const WCHAR PropertyXMLDeclStandaloneW[] = {
392 'x','m','l','d','e','c','l','-','s','t','a','n','d','a','l','o','n','e',0
394 static const WCHAR PropertyXMLDeclVersionW[] = {
395 'x','m','l','d','e','c','l','-','v','e','r','s','i','o','n',0
398 static inline HRESULT set_feature_value(saxreader *reader, saxreader_feature feature, VARIANT_BOOL value)
400 /* handling of non-VARIANT_* values is version dependent */
401 if ((reader->version < MSXML4) && (value != VARIANT_TRUE))
402 value = VARIANT_FALSE;
403 if ((reader->version >= MSXML4) && (value != VARIANT_FALSE))
404 value = VARIANT_TRUE;
406 if (value == VARIANT_TRUE)
407 reader->features |= feature;
409 reader->features &= ~feature;
414 static inline HRESULT get_feature_value(const saxreader *reader, saxreader_feature feature, VARIANT_BOOL *value)
416 *value = reader->features & feature ? VARIANT_TRUE : VARIANT_FALSE;
420 static BOOL is_namespaces_enabled(const saxreader *reader)
422 return (reader->version < MSXML4) || (reader->features & Namespaces);
425 static BSTR build_qname(BSTR prefix, BSTR local)
427 if (prefix && *prefix)
429 BSTR qname = SysAllocStringLen(NULL, SysStringLen(prefix) + SysStringLen(local) + 1);
433 strcpyW(ptr, prefix);
434 ptr += SysStringLen(prefix);
440 return SysAllocString(local);
443 static element_entry* alloc_element_entry(const xmlChar *local, const xmlChar *prefix, int nb_ns,
444 const xmlChar **namespaces)
449 ret = heap_alloc(sizeof(*ret));
450 if (!ret) return ret;
452 ret->local = bstr_from_xmlChar(local);
453 ret->prefix = bstr_from_xmlChar(prefix);
454 ret->qname = build_qname(ret->prefix, ret->local);
455 ret->ns = nb_ns ? heap_alloc(nb_ns*sizeof(ns)) : NULL;
456 ret->ns_count = nb_ns;
458 for (i=0; i < nb_ns; i++)
460 ret->ns[i].prefix = bstr_from_xmlChar(namespaces[2*i]);
461 ret->ns[i].uri = bstr_from_xmlChar(namespaces[2*i+1]);
467 static void free_element_entry(element_entry *element)
471 for (i=0; i<element->ns_count;i++)
473 SysFreeString(element->ns[i].prefix);
474 SysFreeString(element->ns[i].uri);
477 SysFreeString(element->prefix);
478 SysFreeString(element->local);
480 heap_free(element->ns);
484 static void push_element_ns(saxlocator *locator, element_entry *element)
486 list_add_head(&locator->elements, &element->entry);
489 static element_entry * pop_element_ns(saxlocator *locator)
491 element_entry *element = LIST_ENTRY(list_head(&locator->elements), element_entry, entry);
494 list_remove(&element->entry);
499 static BSTR find_element_uri(saxlocator *locator, const xmlChar *uri)
501 element_entry *element;
505 if (!uri) return NULL;
507 uriW = bstr_from_xmlChar(uri);
509 LIST_FOR_EACH_ENTRY(element, &locator->elements, element_entry, entry)
511 for (i=0; i < element->ns_count; i++)
512 if (!strcmpW(uriW, element->ns[i].uri))
515 return element->ns[i].uri;
520 ERR("namespace uri not found, %s\n", debugstr_a((char*)uri));
524 /* used to localize version dependent error check behaviour */
525 static inline BOOL sax_callback_failed(saxlocator *This, HRESULT hr)
527 return This->saxreader->version >= MSXML4 ? FAILED(hr) : hr != S_OK;
530 /* index value -1 means it tries to loop for a first time */
531 static inline BOOL iterate_endprefix_index(saxlocator *This, const element_entry *element, int *i)
533 if (This->saxreader->version >= MSXML4)
535 if (*i == -1) *i = 0; else ++*i;
536 return *i < element->ns_count;
540 if (*i == -1) *i = element->ns_count-1; else --*i;
545 static BOOL bstr_pool_insert(struct bstrpool *pool, BSTR pool_entry)
549 pool->pool = HeapAlloc(GetProcessHeap(), 0, 16 * sizeof(*pool->pool));
556 else if (pool->index == pool->len)
558 BSTR *realloc = HeapReAlloc(GetProcessHeap(), 0, pool->pool, pool->len * 2 * sizeof(*realloc));
563 pool->pool = realloc;
567 pool->pool[pool->index++] = pool_entry;
571 static void free_bstr_pool(struct bstrpool *pool)
575 for (i = 0; i < pool->index; i++)
576 SysFreeString(pool->pool[i]);
578 HeapFree(GetProcessHeap(), 0, pool->pool);
581 pool->index = pool->len = 0;
584 static BSTR bstr_from_xmlCharN(const xmlChar *buf, int len)
592 dLen = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, NULL, 0);
593 if(len != -1) dLen++;
594 bstr = SysAllocStringLen(NULL, dLen-1);
597 MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, bstr, dLen);
598 if(len != -1) bstr[dLen-1] = '\0';
603 static BSTR QName_from_xmlChar(const xmlChar *prefix, const xmlChar *name)
608 if(!name) return NULL;
610 if(!prefix || !*prefix)
611 return bstr_from_xmlChar(name);
613 qname = xmlBuildQName(name, prefix, NULL, 0);
614 bstr = bstr_from_xmlChar(qname);
620 static BSTR pooled_bstr_from_xmlChar(struct bstrpool *pool, const xmlChar *buf)
622 BSTR pool_entry = bstr_from_xmlChar(buf);
624 if (pool_entry && !bstr_pool_insert(pool, pool_entry))
626 SysFreeString(pool_entry);
633 static BSTR pooled_bstr_from_xmlCharN(struct bstrpool *pool, const xmlChar *buf, int len)
635 BSTR pool_entry = bstr_from_xmlCharN(buf, len);
637 if (pool_entry && !bstr_pool_insert(pool, pool_entry))
639 SysFreeString(pool_entry);
646 static void format_error_message_from_id(saxlocator *This, HRESULT hr)
648 struct saxerrorhandler_iface *handler = saxreader_get_errorhandler(This->saxreader);
649 xmlStopParser(This->pParserCtxt);
652 if (saxreader_has_handler(This, SAXErrorHandler))
655 if(!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM,
656 NULL, hr, 0, msg, sizeof(msg), NULL))
658 FIXME("MSXML errors not yet supported.\n");
662 if(This->vbInterface)
664 BSTR bstrMsg = SysAllocString(msg);
665 IVBSAXErrorHandler_fatalError(handler->vbhandler,
666 &This->IVBSAXLocator_iface, &bstrMsg, hr);
667 SysFreeString(bstrMsg);
670 ISAXErrorHandler_fatalError(handler->handler,
671 &This->ISAXLocator_iface, msg, hr);
675 static void update_position(saxlocator *This, BOOL fix_column)
677 const xmlChar *p = This->pParserCtxt->input->cur-1;
679 This->line = xmlSAX2GetLineNumber(This->pParserCtxt);
683 for(; *p!='\n' && *p!='\r' && p>=This->pParserCtxt->input->base; p--)
688 This->column = xmlSAX2GetColumnNumber(This->pParserCtxt);
692 /*** IVBSAXAttributes interface ***/
693 /*** IUnknown methods ***/
694 static HRESULT WINAPI ivbsaxattributes_QueryInterface(
695 IVBSAXAttributes* iface,
699 saxlocator *This = impl_from_IVBSAXAttributes(iface);
700 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
701 return IVBSAXLocator_QueryInterface(&This->IVBSAXLocator_iface, riid, ppvObject);
704 static ULONG WINAPI ivbsaxattributes_AddRef(IVBSAXAttributes* iface)
706 saxlocator *This = impl_from_IVBSAXAttributes(iface);
707 return ISAXLocator_AddRef(&This->ISAXLocator_iface);
710 static ULONG WINAPI ivbsaxattributes_Release(IVBSAXAttributes* iface)
712 saxlocator *This = impl_from_IVBSAXAttributes(iface);
713 return ISAXLocator_Release(&This->ISAXLocator_iface);
716 /*** IDispatch methods ***/
717 static HRESULT WINAPI ivbsaxattributes_GetTypeInfoCount( IVBSAXAttributes *iface, UINT* pctinfo )
719 saxlocator *This = impl_from_IVBSAXAttributes( iface );
721 TRACE("(%p)->(%p)\n", This, pctinfo);
728 static HRESULT WINAPI ivbsaxattributes_GetTypeInfo(
729 IVBSAXAttributes *iface,
730 UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
732 saxlocator *This = impl_from_IVBSAXAttributes( iface );
735 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
737 hr = get_typeinfo(IVBSAXAttributes_tid, ppTInfo);
742 static HRESULT WINAPI ivbsaxattributes_GetIDsOfNames(
743 IVBSAXAttributes *iface,
750 saxlocator *This = impl_from_IVBSAXAttributes( iface );
754 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
757 if(!rgszNames || cNames == 0 || !rgDispId)
760 hr = get_typeinfo(IVBSAXAttributes_tid, &typeinfo);
763 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
764 ITypeInfo_Release(typeinfo);
770 static HRESULT WINAPI ivbsaxattributes_Invoke(
771 IVBSAXAttributes *iface,
776 DISPPARAMS* pDispParams,
778 EXCEPINFO* pExcepInfo,
781 saxlocator *This = impl_from_IVBSAXAttributes( iface );
785 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
786 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
788 hr = get_typeinfo(IVBSAXAttributes_tid, &typeinfo);
791 hr = ITypeInfo_Invoke(typeinfo, &This->IVBSAXAttributes_iface, dispIdMember, wFlags,
792 pDispParams, pVarResult, pExcepInfo, puArgErr);
793 ITypeInfo_Release(typeinfo);
799 /*** IVBSAXAttributes methods ***/
800 static HRESULT WINAPI ivbsaxattributes_get_length(
801 IVBSAXAttributes* iface,
804 saxlocator *This = impl_from_IVBSAXAttributes( iface );
805 return ISAXAttributes_getLength(&This->ISAXAttributes_iface, nLength);
808 static HRESULT WINAPI ivbsaxattributes_getURI(
809 IVBSAXAttributes* iface,
814 saxlocator *This = impl_from_IVBSAXAttributes( iface );
815 return ISAXAttributes_getURI(&This->ISAXAttributes_iface, nIndex, (const WCHAR**)uri, &len);
818 static HRESULT WINAPI ivbsaxattributes_getLocalName(
819 IVBSAXAttributes* iface,
824 saxlocator *This = impl_from_IVBSAXAttributes( iface );
825 return ISAXAttributes_getLocalName(&This->ISAXAttributes_iface, nIndex,
826 (const WCHAR**)localName, &len);
829 static HRESULT WINAPI ivbsaxattributes_getQName(
830 IVBSAXAttributes* iface,
835 saxlocator *This = impl_from_IVBSAXAttributes( iface );
836 return ISAXAttributes_getQName(&This->ISAXAttributes_iface, nIndex, (const WCHAR**)QName, &len);
839 static HRESULT WINAPI ivbsaxattributes_getIndexFromName(
840 IVBSAXAttributes* iface,
845 saxlocator *This = impl_from_IVBSAXAttributes( iface );
846 return ISAXAttributes_getIndexFromName(&This->ISAXAttributes_iface, uri, SysStringLen(uri),
847 localName, SysStringLen(localName), index);
850 static HRESULT WINAPI ivbsaxattributes_getIndexFromQName(
851 IVBSAXAttributes* iface,
855 saxlocator *This = impl_from_IVBSAXAttributes( iface );
856 return ISAXAttributes_getIndexFromQName(&This->ISAXAttributes_iface, QName,
857 SysStringLen(QName), index);
860 static HRESULT WINAPI ivbsaxattributes_getType(
861 IVBSAXAttributes* iface,
866 saxlocator *This = impl_from_IVBSAXAttributes( iface );
867 return ISAXAttributes_getType(&This->ISAXAttributes_iface, nIndex, (const WCHAR**)type, &len);
870 static HRESULT WINAPI ivbsaxattributes_getTypeFromName(
871 IVBSAXAttributes* iface,
877 saxlocator *This = impl_from_IVBSAXAttributes( iface );
878 return ISAXAttributes_getTypeFromName(&This->ISAXAttributes_iface, uri, SysStringLen(uri),
879 localName, SysStringLen(localName), (const WCHAR**)type, &len);
882 static HRESULT WINAPI ivbsaxattributes_getTypeFromQName(
883 IVBSAXAttributes* iface,
888 saxlocator *This = impl_from_IVBSAXAttributes( iface );
889 return ISAXAttributes_getTypeFromQName(&This->ISAXAttributes_iface, QName, SysStringLen(QName),
890 (const WCHAR**)type, &len);
893 static HRESULT WINAPI ivbsaxattributes_getValue(
894 IVBSAXAttributes* iface,
899 saxlocator *This = impl_from_IVBSAXAttributes( iface );
900 return ISAXAttributes_getValue(&This->ISAXAttributes_iface, nIndex, (const WCHAR**)value, &len);
903 static HRESULT WINAPI ivbsaxattributes_getValueFromName(
904 IVBSAXAttributes* iface,
910 saxlocator *This = impl_from_IVBSAXAttributes( iface );
911 return ISAXAttributes_getValueFromName(&This->ISAXAttributes_iface, uri, SysStringLen(uri),
912 localName, SysStringLen(localName), (const WCHAR**)value, &len);
915 static HRESULT WINAPI ivbsaxattributes_getValueFromQName(
916 IVBSAXAttributes* iface,
921 saxlocator *This = impl_from_IVBSAXAttributes( iface );
922 return ISAXAttributes_getValueFromQName(&This->ISAXAttributes_iface, QName,
923 SysStringLen(QName), (const WCHAR**)value, &len);
926 static const struct IVBSAXAttributesVtbl ivbsaxattributes_vtbl =
928 ivbsaxattributes_QueryInterface,
929 ivbsaxattributes_AddRef,
930 ivbsaxattributes_Release,
931 ivbsaxattributes_GetTypeInfoCount,
932 ivbsaxattributes_GetTypeInfo,
933 ivbsaxattributes_GetIDsOfNames,
934 ivbsaxattributes_Invoke,
935 ivbsaxattributes_get_length,
936 ivbsaxattributes_getURI,
937 ivbsaxattributes_getLocalName,
938 ivbsaxattributes_getQName,
939 ivbsaxattributes_getIndexFromName,
940 ivbsaxattributes_getIndexFromQName,
941 ivbsaxattributes_getType,
942 ivbsaxattributes_getTypeFromName,
943 ivbsaxattributes_getTypeFromQName,
944 ivbsaxattributes_getValue,
945 ivbsaxattributes_getValueFromName,
946 ivbsaxattributes_getValueFromQName
949 /*** ISAXAttributes interface ***/
950 /*** IUnknown methods ***/
951 static HRESULT WINAPI isaxattributes_QueryInterface(
952 ISAXAttributes* iface,
956 saxlocator *This = impl_from_ISAXAttributes(iface);
957 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
958 return ISAXLocator_QueryInterface(&This->ISAXLocator_iface, riid, ppvObject);
961 static ULONG WINAPI isaxattributes_AddRef(ISAXAttributes* iface)
963 saxlocator *This = impl_from_ISAXAttributes(iface);
965 return ISAXLocator_AddRef(&This->ISAXLocator_iface);
968 static ULONG WINAPI isaxattributes_Release(ISAXAttributes* iface)
970 saxlocator *This = impl_from_ISAXAttributes(iface);
973 return ISAXLocator_Release(&This->ISAXLocator_iface);
976 /*** ISAXAttributes methods ***/
977 static HRESULT WINAPI isaxattributes_getLength(
978 ISAXAttributes* iface,
981 saxlocator *This = impl_from_ISAXAttributes( iface );
983 *length = This->nb_attributes;
984 TRACE("Length set to %d\n", *length);
988 static HRESULT WINAPI isaxattributes_getURI(
989 ISAXAttributes* iface,
994 saxlocator *This = impl_from_ISAXAttributes( iface );
995 TRACE("(%p)->(%d)\n", This, index);
997 if(index >= This->nb_attributes || index < 0) return E_INVALIDARG;
998 if(!url || !size) return E_POINTER;
1000 *size = SysStringLen(This->attributes[index].szURI);
1001 *url = This->attributes[index].szURI;
1003 TRACE("(%s:%d)\n", debugstr_w(This->attributes[index].szURI), *size);
1008 static HRESULT WINAPI isaxattributes_getLocalName(
1009 ISAXAttributes* iface,
1011 const WCHAR **pLocalName,
1012 int *pLocalNameLength)
1014 saxlocator *This = impl_from_ISAXAttributes( iface );
1015 TRACE("(%p)->(%d)\n", This, nIndex);
1017 if(nIndex>=This->nb_attributes || nIndex<0) return E_INVALIDARG;
1018 if(!pLocalName || !pLocalNameLength) return E_POINTER;
1020 *pLocalNameLength = SysStringLen(This->attributes[nIndex].szLocalname);
1021 *pLocalName = This->attributes[nIndex].szLocalname;
1026 static HRESULT WINAPI isaxattributes_getQName(
1027 ISAXAttributes* iface,
1029 const WCHAR **pQName,
1032 saxlocator *This = impl_from_ISAXAttributes( iface );
1033 TRACE("(%p)->(%d)\n", This, nIndex);
1035 if(nIndex>=This->nb_attributes || nIndex<0) return E_INVALIDARG;
1036 if(!pQName || !pQNameLength) return E_POINTER;
1038 *pQNameLength = SysStringLen(This->attributes[nIndex].szQName);
1039 *pQName = This->attributes[nIndex].szQName;
1044 static HRESULT WINAPI isaxattributes_getName(
1045 ISAXAttributes* iface,
1049 const WCHAR **localName,
1050 int *pLocalNameSize,
1051 const WCHAR **QName,
1054 saxlocator *This = impl_from_ISAXAttributes( iface );
1055 TRACE("(%p)->(%d)\n", This, index);
1057 if(index>=This->nb_attributes || index<0) return E_INVALIDARG;
1058 if(!uri || !pUriLength || !localName || !pLocalNameSize
1059 || !QName || !pQNameLength) return E_POINTER;
1061 *pUriLength = SysStringLen(This->attributes[index].szURI);
1062 *uri = This->attributes[index].szURI;
1063 *pLocalNameSize = SysStringLen(This->attributes[index].szLocalname);
1064 *localName = This->attributes[index].szLocalname;
1065 *pQNameLength = SysStringLen(This->attributes[index].szQName);
1066 *QName = This->attributes[index].szQName;
1068 TRACE("(%s, %s, %s)\n", debugstr_w(*uri), debugstr_w(*localName), debugstr_w(*QName));
1073 static HRESULT WINAPI isaxattributes_getIndexFromName(
1074 ISAXAttributes* iface,
1077 const WCHAR *pLocalName,
1078 int cocalNameLength,
1081 saxlocator *This = impl_from_ISAXAttributes( iface );
1083 TRACE("(%p)->(%s, %d, %s, %d)\n", This, debugstr_w(pUri), cUriLength,
1084 debugstr_w(pLocalName), cocalNameLength);
1086 if(!pUri || !pLocalName || !index) return E_POINTER;
1088 for(i=0; i<This->nb_attributes; i++)
1090 if(cUriLength!=SysStringLen(This->attributes[i].szURI)
1091 || cocalNameLength!=SysStringLen(This->attributes[i].szLocalname))
1093 if(cUriLength && memcmp(pUri, This->attributes[i].szURI,
1094 sizeof(WCHAR)*cUriLength))
1096 if(cocalNameLength && memcmp(pLocalName, This->attributes[i].szLocalname,
1097 sizeof(WCHAR)*cocalNameLength))
1104 return E_INVALIDARG;
1107 static HRESULT WINAPI isaxattributes_getIndexFromQName(
1108 ISAXAttributes* iface,
1109 const WCHAR *pQName,
1113 saxlocator *This = impl_from_ISAXAttributes( iface );
1115 TRACE("(%p)->(%s, %d)\n", This, debugstr_w(pQName), nQNameLength);
1117 if(!pQName || !index) return E_POINTER;
1118 if(!nQNameLength) return E_INVALIDARG;
1120 for(i=0; i<This->nb_attributes; i++)
1122 if(nQNameLength!=SysStringLen(This->attributes[i].szQName)) continue;
1123 if(memcmp(pQName, This->attributes[i].szQName, sizeof(WCHAR)*nQNameLength)) continue;
1129 return E_INVALIDARG;
1132 static HRESULT WINAPI isaxattributes_getType(
1133 ISAXAttributes* iface,
1135 const WCHAR **pType,
1138 saxlocator *This = impl_from_ISAXAttributes( iface );
1140 FIXME("(%p)->(%d) stub\n", This, nIndex);
1144 static HRESULT WINAPI isaxattributes_getTypeFromName(
1145 ISAXAttributes* iface,
1148 const WCHAR *pLocalName,
1150 const WCHAR **pType,
1153 saxlocator *This = impl_from_ISAXAttributes( iface );
1155 FIXME("(%p)->(%s, %d, %s, %d) stub\n", This, debugstr_w(pUri), nUri,
1156 debugstr_w(pLocalName), nLocalName);
1160 static HRESULT WINAPI isaxattributes_getTypeFromQName(
1161 ISAXAttributes* iface,
1162 const WCHAR *pQName,
1164 const WCHAR **pType,
1167 saxlocator *This = impl_from_ISAXAttributes( iface );
1169 FIXME("(%p)->(%s, %d) stub\n", This, debugstr_w(pQName), nQName);
1173 static HRESULT WINAPI isaxattributes_getValue(
1174 ISAXAttributes* iface,
1176 const WCHAR **value,
1179 saxlocator *This = impl_from_ISAXAttributes( iface );
1180 TRACE("(%p)->(%d)\n", This, index);
1182 if(index>=This->nb_attributes || index<0) return E_INVALIDARG;
1183 if(!value || !nValue) return E_POINTER;
1185 *nValue = SysStringLen(This->attributes[index].szValue);
1186 *value = This->attributes[index].szValue;
1188 TRACE("(%s:%d)\n", debugstr_w(*value), *nValue);
1193 static HRESULT WINAPI isaxattributes_getValueFromName(
1194 ISAXAttributes* iface,
1197 const WCHAR *pLocalName,
1199 const WCHAR **pValue,
1204 saxlocator *This = impl_from_ISAXAttributes( iface );
1205 TRACE("(%p)->(%s, %d, %s, %d)\n", This, debugstr_w(pUri), nUri,
1206 debugstr_w(pLocalName), nLocalName);
1208 hr = ISAXAttributes_getIndexFromName(iface,
1209 pUri, nUri, pLocalName, nLocalName, &index);
1210 if(hr==S_OK) hr = ISAXAttributes_getValue(iface, index, pValue, nValue);
1215 static HRESULT WINAPI isaxattributes_getValueFromQName(
1216 ISAXAttributes* iface,
1217 const WCHAR *pQName,
1219 const WCHAR **pValue,
1224 saxlocator *This = impl_from_ISAXAttributes( iface );
1225 TRACE("(%p)->(%s, %d)\n", This, debugstr_w(pQName), nQName);
1227 hr = ISAXAttributes_getIndexFromQName(iface, pQName, nQName, &index);
1228 if(hr==S_OK) hr = ISAXAttributes_getValue(iface, index, pValue, nValue);
1233 static const struct ISAXAttributesVtbl isaxattributes_vtbl =
1235 isaxattributes_QueryInterface,
1236 isaxattributes_AddRef,
1237 isaxattributes_Release,
1238 isaxattributes_getLength,
1239 isaxattributes_getURI,
1240 isaxattributes_getLocalName,
1241 isaxattributes_getQName,
1242 isaxattributes_getName,
1243 isaxattributes_getIndexFromName,
1244 isaxattributes_getIndexFromQName,
1245 isaxattributes_getType,
1246 isaxattributes_getTypeFromName,
1247 isaxattributes_getTypeFromQName,
1248 isaxattributes_getValue,
1249 isaxattributes_getValueFromName,
1250 isaxattributes_getValueFromQName
1253 static HRESULT SAXAttributes_populate(saxlocator *locator,
1254 int nb_namespaces, const xmlChar **xmlNamespaces,
1255 int nb_attributes, const xmlChar **xmlAttributes)
1257 static const xmlChar xmlns[] = "xmlns";
1258 static const WCHAR xmlnsW[] = { 'x','m','l','n','s',0 };
1260 struct _attributes *attrs;
1263 /* skip namespace definitions */
1264 if ((locator->saxreader->features & NamespacePrefixes) == 0)
1267 locator->nb_attributes = nb_namespaces + nb_attributes;
1268 if(locator->nb_attributes > locator->attributesSize)
1270 attrs = heap_realloc(locator->attributes, sizeof(struct _attributes)*locator->nb_attributes*2);
1273 locator->nb_attributes = 0;
1274 return E_OUTOFMEMORY;
1276 locator->attributes = attrs;
1280 attrs = locator->attributes;
1283 for (i = 0; i < nb_namespaces; i++)
1285 attrs[nb_attributes+i].szLocalname = SysAllocStringLen(NULL, 0);
1286 attrs[nb_attributes+i].szURI = locator->namespaceUri;
1287 attrs[nb_attributes+i].szValue = bstr_from_xmlChar(xmlNamespaces[2*i+1]);
1288 if(!xmlNamespaces[2*i])
1289 attrs[nb_attributes+i].szQName = SysAllocString(xmlnsW);
1291 attrs[nb_attributes+i].szQName = QName_from_xmlChar(xmlns, xmlNamespaces[2*i]);
1294 for (i = 0; i < nb_attributes; i++)
1296 static const xmlChar xmlA[] = "xml";
1298 if (xmlStrEqual(xmlAttributes[i*5+1], xmlA))
1299 attrs[i].szURI = bstr_from_xmlChar(xmlAttributes[i*5+2]);
1301 /* that's an important feature to keep same uri pointer for every reported attribute */
1302 attrs[i].szURI = find_element_uri(locator, xmlAttributes[i*5+2]);
1304 attrs[i].szLocalname = bstr_from_xmlChar(xmlAttributes[i*5]);
1305 attrs[i].szValue = bstr_from_xmlCharN(xmlAttributes[i*5+3],
1306 xmlAttributes[i*5+4]-xmlAttributes[i*5+3]);
1307 attrs[i].szQName = QName_from_xmlChar(xmlAttributes[i*5+1],
1308 xmlAttributes[i*5]);
1314 /*** LibXML callbacks ***/
1315 static void libxmlStartDocument(void *ctx)
1317 saxlocator *This = ctx;
1318 struct saxcontenthandler_iface *handler = saxreader_get_contenthandler(This->saxreader);
1321 if (This->saxreader->version >= MSXML4)
1323 const xmlChar *p = This->pParserCtxt->input->cur-1;
1324 update_position(This, FALSE);
1325 while(p>This->pParserCtxt->input->base && *p!='>')
1327 if(*p=='\n' || (*p=='\r' && *(p+1)!='\n'))
1332 for(; p>=This->pParserCtxt->input->base && *p!='\n' && *p!='\r'; p--)
1336 /* store version value, declaration has to contain version attribute */
1337 if (This->pParserCtxt->standalone != -1)
1339 SysFreeString(This->saxreader->xmldecl_version);
1340 This->saxreader->xmldecl_version = bstr_from_xmlChar(This->pParserCtxt->version);
1343 if (saxreader_has_handler(This, SAXContentHandler))
1345 if(This->vbInterface)
1346 hr = IVBSAXContentHandler_startDocument(handler->vbhandler);
1348 hr = ISAXContentHandler_startDocument(handler->handler);
1350 if (sax_callback_failed(This, hr))
1351 format_error_message_from_id(This, hr);
1355 static void libxmlEndDocument(void *ctx)
1357 saxlocator *This = ctx;
1358 struct saxcontenthandler_iface *handler = saxreader_get_contenthandler(This->saxreader);
1361 if (This->saxreader->version >= MSXML4) {
1362 update_position(This, FALSE);
1363 if(This->column > 1)
1371 if(This->ret != S_OK) return;
1373 if (saxreader_has_handler(This, SAXContentHandler))
1375 if(This->vbInterface)
1376 hr = IVBSAXContentHandler_endDocument(handler->vbhandler);
1378 hr = ISAXContentHandler_endDocument(handler->handler);
1380 if (sax_callback_failed(This, hr))
1381 format_error_message_from_id(This, hr);
1385 static void libxmlStartElementNS(
1387 const xmlChar *localname,
1388 const xmlChar *prefix,
1391 const xmlChar **namespaces,
1394 const xmlChar **attributes)
1396 saxlocator *This = ctx;
1397 struct saxcontenthandler_iface *handler = saxreader_get_contenthandler(This->saxreader);
1398 element_entry *element;
1402 update_position(This, TRUE);
1403 if(*(This->pParserCtxt->input->cur) == '/')
1405 if(This->saxreader->version < MSXML4)
1408 element = alloc_element_entry(localname, prefix, nb_namespaces, namespaces);
1409 push_element_ns(This, element);
1411 if (is_namespaces_enabled(This->saxreader))
1415 for (i = 0; i < nb_namespaces && saxreader_has_handler(This, SAXContentHandler); i++)
1417 if (This->vbInterface)
1418 hr = IVBSAXContentHandler_startPrefixMapping(
1420 &element->ns[i].prefix,
1421 &element->ns[i].uri);
1423 hr = ISAXContentHandler_startPrefixMapping(
1425 element->ns[i].prefix,
1426 SysStringLen(element->ns[i].prefix),
1428 SysStringLen(element->ns[i].uri));
1430 if (sax_callback_failed(This, hr))
1432 format_error_message_from_id(This, hr);
1438 uri = find_element_uri(This, URI);
1439 hr = SAXAttributes_populate(This, nb_namespaces, namespaces, nb_attributes, attributes);
1440 if (hr == S_OK && saxreader_has_handler(This, SAXContentHandler))
1444 if (is_namespaces_enabled(This->saxreader))
1445 local = element->local;
1449 if (This->vbInterface)
1450 hr = IVBSAXContentHandler_startElement(handler->vbhandler,
1451 &uri, &local, &element->qname, &This->IVBSAXAttributes_iface);
1453 hr = ISAXContentHandler_startElement(handler->handler,
1454 uri, SysStringLen(uri),
1455 local, SysStringLen(local),
1456 element->qname, SysStringLen(element->qname),
1457 &This->ISAXAttributes_iface);
1459 if (sax_callback_failed(This, hr))
1460 format_error_message_from_id(This, hr);
1464 static void libxmlEndElementNS(
1466 const xmlChar *localname,
1467 const xmlChar *prefix,
1470 saxlocator *This = ctx;
1471 struct saxcontenthandler_iface *handler = saxreader_get_contenthandler(This->saxreader);
1472 element_entry *element;
1477 update_position(This, FALSE);
1478 p = This->pParserCtxt->input->cur;
1480 if (This->saxreader->version >= MSXML4)
1483 while(p>This->pParserCtxt->input->base && *p!='>')
1485 if(*p=='\n' || (*p=='\r' && *(p+1)!='\n'))
1490 else if(*(p-1)!='>' || *(p-2)!='/')
1493 while(p-2>=This->pParserCtxt->input->base
1494 && *(p-2)!='<' && *(p-1)!='/')
1496 if(*p=='\n' || (*p=='\r' && *(p+1)!='\n'))
1502 for(; p>=This->pParserCtxt->input->base && *p!='\n' && *p!='\r'; p--)
1505 uri = find_element_uri(This, URI);
1506 element = pop_element_ns(This);
1508 if (!saxreader_has_handler(This, SAXContentHandler))
1510 This->nb_attributes = 0;
1511 free_element_entry(element);
1515 if (is_namespaces_enabled(This->saxreader))
1516 local = element->local;
1520 if (This->vbInterface)
1521 hr = IVBSAXContentHandler_endElement(
1523 &uri, &local, &element->qname);
1525 hr = ISAXContentHandler_endElement(
1527 uri, SysStringLen(uri),
1528 local, SysStringLen(local),
1529 element->qname, SysStringLen(element->qname));
1531 This->nb_attributes = 0;
1533 if (sax_callback_failed(This, hr))
1535 format_error_message_from_id(This, hr);
1536 free_element_entry(element);
1540 if (is_namespaces_enabled(This->saxreader))
1543 while (iterate_endprefix_index(This, element, &i) && saxreader_has_handler(This, SAXContentHandler))
1545 if (This->vbInterface)
1546 hr = IVBSAXContentHandler_endPrefixMapping(
1547 handler->vbhandler, &element->ns[i].prefix);
1549 hr = ISAXContentHandler_endPrefixMapping(
1550 handler->handler, element->ns[i].prefix, SysStringLen(element->ns[i].prefix));
1552 if (sax_callback_failed(This, hr)) break;
1555 if (sax_callback_failed(This, hr))
1556 format_error_message_from_id(This, hr);
1559 free_element_entry(element);
1562 static void libxmlCharacters(
1567 saxlocator *This = ctx;
1568 struct saxcontenthandler_iface *handler = saxreader_get_contenthandler(This->saxreader);
1572 BOOL lastEvent = FALSE;
1574 if (!saxreader_has_handler(This, SAXContentHandler)) return;
1576 update_position(This, FALSE);
1577 cur = (xmlChar*)This->pParserCtxt->input->cur;
1578 while(cur>=This->pParserCtxt->input->base && *cur!='>')
1580 if(*cur=='\n' || (*cur=='\r' && *(cur+1)!='\n'))
1585 for(; cur>=This->pParserCtxt->input->base && *cur!='\n' && *cur!='\r'; cur--)
1589 if(*(ch-1)=='\r') cur--;
1594 while(end-ch<len && *end!='\r') end++;
1605 if (This->saxreader->version >= MSXML4)
1609 for(p=cur; p!=end; p++)
1626 Chars = pooled_bstr_from_xmlCharN(&This->saxreader->pool, cur, end-cur);
1627 if(This->vbInterface)
1628 hr = IVBSAXContentHandler_characters(handler->vbhandler, &Chars);
1630 hr = ISAXContentHandler_characters(handler->handler, Chars, SysStringLen(Chars));
1632 if (sax_callback_failed(This, hr))
1634 format_error_message_from_id(This, hr);
1638 if (This->saxreader->version < MSXML4)
1639 This->column += end-cur;
1652 if(end-ch == len) break;
1656 static void libxmlSetDocumentLocator(
1658 xmlSAXLocatorPtr loc)
1660 saxlocator *This = ctx;
1661 struct saxcontenthandler_iface *handler = saxreader_get_contenthandler(This->saxreader);
1664 if (saxreader_has_handler(This, SAXContentHandler))
1666 if(This->vbInterface)
1667 hr = IVBSAXContentHandler_putref_documentLocator(handler->vbhandler,
1668 &This->IVBSAXLocator_iface);
1670 hr = ISAXContentHandler_putDocumentLocator(handler->handler, &This->ISAXLocator_iface);
1674 format_error_message_from_id(This, hr);
1677 static void libxmlComment(void *ctx, const xmlChar *value)
1679 saxlocator *This = ctx;
1680 struct saxlexicalhandler_iface *handler = saxreader_get_lexicalhandler(This->saxreader);
1683 const xmlChar *p = This->pParserCtxt->input->cur;
1685 update_position(This, FALSE);
1686 while(p-4>=This->pParserCtxt->input->base
1687 && memcmp(p-4, "<!--", sizeof(char[4])))
1689 if(*p=='\n' || (*p=='\r' && *(p+1)!='\n'))
1695 for(; p>=This->pParserCtxt->input->base && *p!='\n' && *p!='\r'; p--)
1698 if (!saxreader_has_handler(This, SAXLexicalHandler)) return;
1700 bValue = pooled_bstr_from_xmlChar(&This->saxreader->pool, value);
1702 if (This->vbInterface)
1703 hr = IVBSAXLexicalHandler_comment(handler->vbhandler, &bValue);
1705 hr = ISAXLexicalHandler_comment(handler->handler, bValue, SysStringLen(bValue));
1708 format_error_message_from_id(This, hr);
1711 static void libxmlFatalError(void *ctx, const char *msg, ...)
1713 saxlocator *This = ctx;
1714 struct saxerrorhandler_iface *handler = saxreader_get_errorhandler(This->saxreader);
1720 if(This->ret != S_OK) {
1721 xmlStopParser(This->pParserCtxt);
1725 va_start(args, msg);
1726 vsprintf(message, msg, args);
1729 len = MultiByteToWideChar(CP_UNIXCP, 0, message, -1, NULL, 0);
1730 error = heap_alloc(sizeof(WCHAR)*len);
1733 MultiByteToWideChar(CP_UNIXCP, 0, message, -1, error, len);
1734 TRACE("fatal error for %p: %s\n", This, debugstr_w(error));
1737 if (!saxreader_has_handler(This, SAXErrorHandler))
1739 xmlStopParser(This->pParserCtxt);
1745 FIXME("Error handling is not compatible.\n");
1747 if(This->vbInterface)
1749 BSTR bstrError = SysAllocString(error);
1750 IVBSAXErrorHandler_fatalError(handler->vbhandler, &This->IVBSAXLocator_iface,
1751 &bstrError, E_FAIL);
1752 SysFreeString(bstrError);
1755 ISAXErrorHandler_fatalError(handler->handler, &This->ISAXLocator_iface, error, E_FAIL);
1759 xmlStopParser(This->pParserCtxt);
1763 static void libxmlCDataBlock(void *ctx, const xmlChar *value, int len)
1765 saxlocator *This = ctx;
1766 struct saxcontenthandler_iface *content = saxreader_get_contenthandler(This->saxreader);
1767 struct saxlexicalhandler_iface *lexical = saxreader_get_lexicalhandler(This->saxreader);
1769 xmlChar *beg = (xmlChar*)This->pParserCtxt->input->cur-len;
1773 BOOL lastEvent = FALSE, change;
1775 update_position(This, FALSE);
1776 while(beg-9>=This->pParserCtxt->input->base
1777 && memcmp(beg-9, "<![CDATA[", sizeof(char[9])))
1779 if(*beg=='\n' || (*beg=='\r' && *(beg+1)!='\n'))
1784 for(; beg>=This->pParserCtxt->input->base && *beg!='\n' && *beg!='\r'; beg--)
1787 if (saxreader_has_handler(This, SAXLexicalHandler))
1789 if (This->vbInterface)
1790 hr = IVBSAXLexicalHandler_startCDATA(lexical->vbhandler);
1792 hr = ISAXLexicalHandler_startCDATA(lexical->handler);
1797 format_error_message_from_id(This, hr);
1801 realLen = This->pParserCtxt->input->cur-beg-3;
1807 while(end-beg<realLen && *end!='\r') end++;
1808 if(end-beg==realLen)
1813 else if(end-beg==realLen-1 && *end=='\r' && *(end+1)=='\n')
1816 if(*end == '\r') change = TRUE;
1817 else change = FALSE;
1819 if(change) *end = '\n';
1821 if (saxreader_has_handler(This, SAXContentHandler))
1823 Chars = pooled_bstr_from_xmlCharN(&This->saxreader->pool, cur, end-cur+1);
1824 if (This->vbInterface)
1825 hr = IVBSAXContentHandler_characters(content->vbhandler, &Chars);
1827 hr = ISAXContentHandler_characters(content->handler, Chars, SysStringLen(Chars));
1830 if(change) *end = '\r';
1835 This->column += end-cur+2;
1840 if (saxreader_has_handler(This, SAXLexicalHandler))
1842 if (This->vbInterface)
1843 hr = IVBSAXLexicalHandler_endCDATA(lexical->vbhandler);
1845 hr = ISAXLexicalHandler_endCDATA(lexical->handler);
1849 format_error_message_from_id(This, hr);
1851 This->column += 4+end-cur;
1854 static xmlParserInputPtr libxmlresolveentity(void *ctx, const xmlChar *publicid, const xmlChar *systemid)
1856 FIXME("entity resolving not implemented, %s, %s\n", publicid, systemid);
1857 return xmlSAX2ResolveEntity(ctx, publicid, systemid);
1860 /*** IVBSAXLocator interface ***/
1861 /*** IUnknown methods ***/
1862 static HRESULT WINAPI ivbsaxlocator_QueryInterface(IVBSAXLocator* iface, REFIID riid, void **ppvObject)
1864 saxlocator *This = impl_from_IVBSAXLocator( iface );
1866 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject);
1870 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
1871 IsEqualGUID( riid, &IID_IDispatch) ||
1872 IsEqualGUID( riid, &IID_IVBSAXLocator ))
1876 else if ( IsEqualGUID( riid, &IID_IVBSAXAttributes ))
1878 *ppvObject = &This->IVBSAXAttributes_iface;
1882 FIXME("interface %s not implemented\n", debugstr_guid(riid));
1883 return E_NOINTERFACE;
1886 IVBSAXLocator_AddRef( iface );
1891 static ULONG WINAPI ivbsaxlocator_AddRef(IVBSAXLocator* iface)
1893 saxlocator *This = impl_from_IVBSAXLocator( iface );
1894 TRACE("%p\n", This );
1895 return InterlockedIncrement( &This->ref );
1898 static ULONG WINAPI ivbsaxlocator_Release(
1899 IVBSAXLocator* iface)
1901 saxlocator *This = impl_from_IVBSAXLocator( iface );
1902 return ISAXLocator_Release((ISAXLocator*)&This->IVBSAXLocator_iface);
1905 /*** IDispatch methods ***/
1906 static HRESULT WINAPI ivbsaxlocator_GetTypeInfoCount( IVBSAXLocator *iface, UINT* pctinfo )
1908 saxlocator *This = impl_from_IVBSAXLocator( iface );
1910 TRACE("(%p)->(%p)\n", This, pctinfo);
1917 static HRESULT WINAPI ivbsaxlocator_GetTypeInfo(
1918 IVBSAXLocator *iface,
1919 UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
1921 saxlocator *This = impl_from_IVBSAXLocator( iface );
1924 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
1926 hr = get_typeinfo(IVBSAXLocator_tid, ppTInfo);
1931 static HRESULT WINAPI ivbsaxlocator_GetIDsOfNames(
1932 IVBSAXLocator *iface,
1934 LPOLESTR* rgszNames,
1939 saxlocator *This = impl_from_IVBSAXLocator( iface );
1940 ITypeInfo *typeinfo;
1943 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
1946 if(!rgszNames || cNames == 0 || !rgDispId)
1947 return E_INVALIDARG;
1949 hr = get_typeinfo(IVBSAXLocator_tid, &typeinfo);
1952 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
1953 ITypeInfo_Release(typeinfo);
1959 static HRESULT WINAPI ivbsaxlocator_Invoke(
1960 IVBSAXLocator *iface,
1961 DISPID dispIdMember,
1965 DISPPARAMS* pDispParams,
1966 VARIANT* pVarResult,
1967 EXCEPINFO* pExcepInfo,
1970 saxlocator *This = impl_from_IVBSAXLocator( iface );
1971 ITypeInfo *typeinfo;
1974 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1975 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1977 hr = get_typeinfo(IVBSAXLocator_tid, &typeinfo);
1980 hr = ITypeInfo_Invoke(typeinfo, &This->IVBSAXLocator_iface, dispIdMember, wFlags,
1981 pDispParams, pVarResult, pExcepInfo, puArgErr);
1982 ITypeInfo_Release(typeinfo);
1988 /*** IVBSAXLocator methods ***/
1989 static HRESULT WINAPI ivbsaxlocator_get_columnNumber(
1990 IVBSAXLocator* iface,
1993 saxlocator *This = impl_from_IVBSAXLocator( iface );
1994 return ISAXLocator_getColumnNumber((ISAXLocator*)&This->IVBSAXLocator_iface, pnColumn);
1997 static HRESULT WINAPI ivbsaxlocator_get_lineNumber(
1998 IVBSAXLocator* iface,
2001 saxlocator *This = impl_from_IVBSAXLocator( iface );
2002 return ISAXLocator_getLineNumber((ISAXLocator*)&This->IVBSAXLocator_iface, pnLine);
2005 static HRESULT WINAPI ivbsaxlocator_get_publicId(
2006 IVBSAXLocator* iface,
2009 saxlocator *This = impl_from_IVBSAXLocator( iface );
2010 return ISAXLocator_getPublicId((ISAXLocator*)&This->IVBSAXLocator_iface,
2011 (const WCHAR**)publicId);
2014 static HRESULT WINAPI ivbsaxlocator_get_systemId(
2015 IVBSAXLocator* iface,
2018 saxlocator *This = impl_from_IVBSAXLocator( iface );
2019 return ISAXLocator_getSystemId((ISAXLocator*)&This->IVBSAXLocator_iface,
2020 (const WCHAR**)systemId);
2023 static const struct IVBSAXLocatorVtbl VBSAXLocatorVtbl =
2025 ivbsaxlocator_QueryInterface,
2026 ivbsaxlocator_AddRef,
2027 ivbsaxlocator_Release,
2028 ivbsaxlocator_GetTypeInfoCount,
2029 ivbsaxlocator_GetTypeInfo,
2030 ivbsaxlocator_GetIDsOfNames,
2031 ivbsaxlocator_Invoke,
2032 ivbsaxlocator_get_columnNumber,
2033 ivbsaxlocator_get_lineNumber,
2034 ivbsaxlocator_get_publicId,
2035 ivbsaxlocator_get_systemId
2038 /*** ISAXLocator interface ***/
2039 /*** IUnknown methods ***/
2040 static HRESULT WINAPI isaxlocator_QueryInterface(ISAXLocator* iface, REFIID riid, void **ppvObject)
2042 saxlocator *This = impl_from_ISAXLocator( iface );
2044 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
2048 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
2049 IsEqualGUID( riid, &IID_ISAXLocator ))
2053 else if ( IsEqualGUID( riid, &IID_ISAXAttributes ))
2055 *ppvObject = &This->ISAXAttributes_iface;
2059 WARN("interface %s not implemented\n", debugstr_guid(riid));
2060 return E_NOINTERFACE;
2063 ISAXLocator_AddRef( iface );
2068 static ULONG WINAPI isaxlocator_AddRef(ISAXLocator* iface)
2070 saxlocator *This = impl_from_ISAXLocator( iface );
2071 ULONG ref = InterlockedIncrement( &This->ref );
2072 TRACE("(%p)->(%d)\n", This, ref);
2076 static ULONG WINAPI isaxlocator_Release(
2079 saxlocator *This = impl_from_ISAXLocator( iface );
2080 LONG ref = InterlockedDecrement( &This->ref );
2082 TRACE("(%p)->(%d)\n", This, ref );
2086 element_entry *element, *element2;
2089 SysFreeString(This->publicId);
2090 SysFreeString(This->systemId);
2091 SysFreeString(This->namespaceUri);
2093 for(index=0; index<This->nb_attributes; index++)
2095 SysFreeString(This->attributes[index].szLocalname);
2096 SysFreeString(This->attributes[index].szValue);
2097 SysFreeString(This->attributes[index].szQName);
2099 heap_free(This->attributes);
2102 LIST_FOR_EACH_ENTRY_SAFE(element, element2, &This->elements, element_entry, entry)
2104 list_remove(&element->entry);
2105 free_element_entry(element);
2108 ISAXXMLReader_Release(&This->saxreader->ISAXXMLReader_iface);
2115 /*** ISAXLocator methods ***/
2116 static HRESULT WINAPI isaxlocator_getColumnNumber(
2120 saxlocator *This = impl_from_ISAXLocator( iface );
2122 *pnColumn = This->column;
2126 static HRESULT WINAPI isaxlocator_getLineNumber(
2130 saxlocator *This = impl_from_ISAXLocator( iface );
2132 *pnLine = This->line;
2136 static HRESULT WINAPI isaxlocator_getPublicId(
2138 const WCHAR ** ppwchPublicId)
2141 saxlocator *This = impl_from_ISAXLocator( iface );
2143 SysFreeString(This->publicId);
2145 publicId = bstr_from_xmlChar(xmlSAX2GetPublicId(This->pParserCtxt));
2146 if(SysStringLen(publicId))
2147 This->publicId = publicId;
2150 SysFreeString(publicId);
2151 This->publicId = NULL;
2154 *ppwchPublicId = This->publicId;
2158 static HRESULT WINAPI isaxlocator_getSystemId(
2160 const WCHAR ** ppwchSystemId)
2163 saxlocator *This = impl_from_ISAXLocator( iface );
2165 SysFreeString(This->systemId);
2167 systemId = bstr_from_xmlChar(xmlSAX2GetSystemId(This->pParserCtxt));
2168 if(SysStringLen(systemId))
2169 This->systemId = systemId;
2172 SysFreeString(systemId);
2173 This->systemId = NULL;
2176 *ppwchSystemId = This->systemId;
2180 static const struct ISAXLocatorVtbl SAXLocatorVtbl =
2182 isaxlocator_QueryInterface,
2184 isaxlocator_Release,
2185 isaxlocator_getColumnNumber,
2186 isaxlocator_getLineNumber,
2187 isaxlocator_getPublicId,
2188 isaxlocator_getSystemId
2191 static HRESULT SAXLocator_create(saxreader *reader, saxlocator **ppsaxlocator, BOOL vbInterface)
2193 static const WCHAR w3xmlns[] = { 'h','t','t','p',':','/','/', 'w','w','w','.','w','3','.',
2194 'o','r','g','/','2','0','0','0','/','x','m','l','n','s','/',0 };
2196 saxlocator *locator;
2198 locator = heap_alloc( sizeof (*locator) );
2200 return E_OUTOFMEMORY;
2202 locator->IVBSAXLocator_iface.lpVtbl = &VBSAXLocatorVtbl;
2203 locator->ISAXLocator_iface.lpVtbl = &SAXLocatorVtbl;
2204 locator->IVBSAXAttributes_iface.lpVtbl = &ivbsaxattributes_vtbl;
2205 locator->ISAXAttributes_iface.lpVtbl = &isaxattributes_vtbl;
2207 locator->vbInterface = vbInterface;
2209 locator->saxreader = reader;
2210 ISAXXMLReader_AddRef(&reader->ISAXXMLReader_iface);
2212 locator->pParserCtxt = NULL;
2213 locator->publicId = NULL;
2214 locator->systemId = NULL;
2215 locator->line = reader->version < MSXML4 ? 0 : 1;
2216 locator->column = 0;
2217 locator->ret = S_OK;
2218 if (locator->saxreader->version >= MSXML6)
2219 locator->namespaceUri = SysAllocString(w3xmlns);
2221 locator->namespaceUri = SysAllocStringLen(NULL, 0);
2222 if(!locator->namespaceUri)
2224 ISAXXMLReader_Release(&reader->ISAXXMLReader_iface);
2226 return E_OUTOFMEMORY;
2229 locator->attributesSize = 8;
2230 locator->nb_attributes = 0;
2231 locator->attributes = heap_alloc(sizeof(struct _attributes)*locator->attributesSize);
2232 if(!locator->attributes)
2234 ISAXXMLReader_Release(&reader->ISAXXMLReader_iface);
2235 SysFreeString(locator->namespaceUri);
2237 return E_OUTOFMEMORY;
2240 list_init(&locator->elements);
2242 *ppsaxlocator = locator;
2244 TRACE("returning %p\n", *ppsaxlocator);
2249 /*** SAXXMLReader internal functions ***/
2250 static HRESULT internal_parseBuffer(saxreader *This, const char *buffer, int size, BOOL vbInterface)
2252 xmlCharEncoding encoding = XML_CHAR_ENCODING_NONE;
2253 xmlChar *enc_name = NULL;
2254 saxlocator *locator;
2257 TRACE("(%p)->(%p %d)\n", This, buffer, size);
2259 hr = SAXLocator_create(This, &locator, vbInterface);
2265 const unsigned char *buff = (unsigned char*)buffer;
2267 encoding = xmlDetectCharEncoding((xmlChar*)buffer, 4);
2268 enc_name = (xmlChar*)xmlGetCharEncodingName(encoding);
2269 TRACE("detected encoding: %s\n", enc_name);
2270 /* skip BOM, parser won't switch encodings and so won't skip it on its own */
2271 if ((encoding == XML_CHAR_ENCODING_UTF8) &&
2272 buff[0] == 0xEF && buff[1] == 0xBB && buff[2] == 0xBF)
2279 /* if libxml2 detection failed try to guess */
2280 if (encoding == XML_CHAR_ENCODING_NONE)
2282 const WCHAR *ptr = (WCHAR*)buffer;
2283 /* xml declaration with possibly specfied encoding will be still handled by parser */
2284 if ((size >= 2) && *ptr == '<' && ptr[1] != '?')
2286 enc_name = (xmlChar*)xmlGetCharEncodingName(XML_CHAR_ENCODING_UTF16LE);
2287 encoding = XML_CHAR_ENCODING_UTF16LE;
2290 else if (encoding == XML_CHAR_ENCODING_UTF8)
2291 enc_name = (xmlChar*)xmlGetCharEncodingName(encoding);
2295 locator->pParserCtxt = xmlCreateMemoryParserCtxt(buffer, size);
2296 if (!locator->pParserCtxt)
2298 ISAXLocator_Release(&locator->ISAXLocator_iface);
2304 locator->pParserCtxt->encoding = xmlStrdup(enc_name);
2305 if (encoding == XML_CHAR_ENCODING_UTF16LE) {
2306 TRACE("switching to %s\n", enc_name);
2307 xmlSwitchEncoding(locator->pParserCtxt, encoding);
2311 xmlFree(locator->pParserCtxt->sax);
2312 locator->pParserCtxt->sax = &locator->saxreader->sax;
2313 locator->pParserCtxt->userData = locator;
2315 This->isParsing = TRUE;
2316 if(xmlParseDocument(locator->pParserCtxt) == -1 && locator->ret == S_OK)
2320 This->isParsing = FALSE;
2322 if(locator->pParserCtxt)
2324 locator->pParserCtxt->sax = NULL;
2325 xmlFreeParserCtxt(locator->pParserCtxt);
2326 locator->pParserCtxt = NULL;
2329 ISAXLocator_Release(&locator->ISAXLocator_iface);
2333 static HRESULT internal_parseStream(saxreader *This, ISequentialStream *stream, BOOL vbInterface)
2335 saxlocator *locator;
2342 hr = ISequentialStream_Read(stream, data, sizeof(data), &dataRead);
2343 if(FAILED(hr)) return hr;
2345 hr = SAXLocator_create(This, &locator, vbInterface);
2346 if(FAILED(hr)) return hr;
2348 locator->pParserCtxt = xmlCreatePushParserCtxt(
2349 &locator->saxreader->sax, locator,
2350 data, dataRead, NULL);
2351 if(!locator->pParserCtxt)
2353 ISAXLocator_Release(&locator->ISAXLocator_iface);
2357 This->isParsing = TRUE;
2359 if(dataRead != sizeof(data))
2361 ret = xmlParseChunk(locator->pParserCtxt, data, 0, 1);
2362 hr = ret!=XML_ERR_OK && locator->ret==S_OK ? E_FAIL : locator->ret;
2369 hr = ISequentialStream_Read(stream, data, sizeof(data), &dataRead);
2370 if (FAILED(hr)) break;
2372 ret = xmlParseChunk(locator->pParserCtxt, data, dataRead, 0);
2373 hr = ret!=XML_ERR_OK && locator->ret==S_OK ? E_FAIL : locator->ret;
2375 if (hr != S_OK) break;
2377 if (dataRead != sizeof(data))
2379 ret = xmlParseChunk(locator->pParserCtxt, data, 0, 1);
2380 hr = ret!=XML_ERR_OK && locator->ret==S_OK ? E_FAIL : locator->ret;
2386 This->isParsing = FALSE;
2388 xmlFreeParserCtxt(locator->pParserCtxt);
2389 locator->pParserCtxt = NULL;
2390 ISAXLocator_Release(&locator->ISAXLocator_iface);
2394 static HRESULT internal_parse(
2401 TRACE("(%p)->(%s)\n", This, debugstr_variant(&varInput));
2403 /* Dispose of the BSTRs in the pool from a prior run, if any. */
2404 free_bstr_pool(&This->pool);
2406 switch(V_VT(&varInput))
2409 hr = internal_parseBuffer(This, (const char*)V_BSTR(&varInput),
2410 strlenW(V_BSTR(&varInput))*sizeof(WCHAR), vbInterface);
2412 case VT_ARRAY|VT_UI1: {
2414 LONG lBound, uBound;
2417 hr = SafeArrayGetLBound(V_ARRAY(&varInput), 1, &lBound);
2418 if(hr != S_OK) break;
2419 hr = SafeArrayGetUBound(V_ARRAY(&varInput), 1, &uBound);
2420 if(hr != S_OK) break;
2421 dataRead = (uBound-lBound)*SafeArrayGetElemsize(V_ARRAY(&varInput));
2422 hr = SafeArrayAccessData(V_ARRAY(&varInput), &pSAData);
2423 if(hr != S_OK) break;
2424 hr = internal_parseBuffer(This, pSAData, dataRead, vbInterface);
2425 SafeArrayUnaccessData(V_ARRAY(&varInput));
2430 IPersistStream *persistStream;
2431 ISequentialStream *stream = NULL;
2432 IXMLDOMDocument *xmlDoc;
2434 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput),
2435 &IID_IXMLDOMDocument, (void**)&xmlDoc) == S_OK)
2439 IXMLDOMDocument_get_xml(xmlDoc, &bstrData);
2440 hr = internal_parseBuffer(This, (const char*)bstrData,
2441 SysStringByteLen(bstrData), vbInterface);
2442 IXMLDOMDocument_Release(xmlDoc);
2443 SysFreeString(bstrData);
2447 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput),
2448 &IID_IPersistStream, (void**)&persistStream) == S_OK)
2450 IStream *stream_copy;
2452 hr = CreateStreamOnHGlobal(NULL, TRUE, &stream_copy);
2455 IPersistStream_Release(persistStream);
2459 hr = IPersistStream_Save(persistStream, stream_copy, TRUE);
2460 IPersistStream_Release(persistStream);
2462 IStream_QueryInterface(stream_copy, &IID_ISequentialStream, (void**)&stream);
2464 IStream_Release(stream_copy);
2467 /* try base interface first */
2470 IUnknown_QueryInterface(V_UNKNOWN(&varInput), &IID_ISequentialStream, (void**)&stream);
2472 /* this should never happen if IStream is implemented properly, but just in case */
2473 IUnknown_QueryInterface(V_UNKNOWN(&varInput), &IID_IStream, (void**)&stream);
2478 hr = internal_parseStream(This, stream, vbInterface);
2479 ISequentialStream_Release(stream);
2483 WARN("IUnknown* input doesn't support any of expected interfaces\n");
2490 WARN("vt %d not implemented\n", V_VT(&varInput));
2497 static HRESULT internal_vbonDataAvailable(void *obj, char *ptr, DWORD len)
2499 saxreader *This = obj;
2501 return internal_parseBuffer(This, ptr, len, TRUE);
2504 static HRESULT internal_onDataAvailable(void *obj, char *ptr, DWORD len)
2506 saxreader *This = obj;
2508 return internal_parseBuffer(This, ptr, len, FALSE);
2511 static HRESULT internal_parseURL(
2520 TRACE("(%p)->(%s)\n", This, debugstr_w(url));
2522 hr = create_moniker_from_url(url, &mon);
2526 if(vbInterface) hr = bind_url(mon, internal_vbonDataAvailable, This, &bsc);
2527 else hr = bind_url(mon, internal_onDataAvailable, This, &bsc);
2528 IMoniker_Release(mon);
2533 return detach_bsc(bsc);
2536 static HRESULT internal_putProperty(
2542 TRACE("(%p)->(%s %s)\n", This, debugstr_w(prop), debugstr_variant(&value));
2544 if(!memcmp(prop, PropertyDeclHandlerW, sizeof(PropertyDeclHandlerW)))
2546 if(This->isParsing) return E_FAIL;
2548 switch (V_VT(&value))
2551 saxreader_put_handler(This, SAXDeclHandler, NULL, vbInterface);
2555 IUnknown *handler = NULL;
2557 if (V_UNKNOWN(&value))
2562 hr = IUnknown_QueryInterface(V_UNKNOWN(&value), &IID_IVBSAXDeclHandler, (void**)&handler);
2564 hr = IUnknown_QueryInterface(V_UNKNOWN(&value), &IID_ISAXDeclHandler, (void**)&handler);
2565 if (FAILED(hr)) return hr;
2568 saxreader_put_handler(This, SAXDeclHandler, handler, vbInterface);
2569 if (handler) IUnknown_Release(handler);
2573 return E_INVALIDARG;
2579 if(!memcmp(prop, PropertyLexicalHandlerW, sizeof(PropertyLexicalHandlerW)))
2581 if(This->isParsing) return E_FAIL;
2583 switch (V_VT(&value))
2586 saxreader_put_handler(This, SAXLexicalHandler, NULL, vbInterface);
2590 IUnknown *handler = NULL;
2592 if (V_UNKNOWN(&value))
2597 hr = IUnknown_QueryInterface(V_UNKNOWN(&value), &IID_IVBSAXLexicalHandler, (void**)&handler);
2599 hr = IUnknown_QueryInterface(V_UNKNOWN(&value), &IID_ISAXLexicalHandler, (void**)&handler);
2600 if (FAILED(hr)) return hr;
2603 saxreader_put_handler(This, SAXLexicalHandler, handler, vbInterface);
2604 if (handler) IUnknown_Release(handler);
2608 return E_INVALIDARG;
2614 if(!memcmp(prop, PropertyMaxXMLSizeW, sizeof(PropertyMaxXMLSizeW)))
2616 if (V_VT(&value) == VT_I4 && V_I4(&value) == 0) return S_OK;
2617 FIXME("(%p)->(%s): max-xml-size unsupported\n", This, debugstr_variant(&value));
2621 if(!memcmp(prop, PropertyMaxElementDepthW, sizeof(PropertyMaxElementDepthW)))
2623 if (V_VT(&value) == VT_I4 && V_I4(&value) == 0) return S_OK;
2624 FIXME("(%p)->(%s): max-element-depth unsupported\n", This, debugstr_variant(&value));
2628 FIXME("(%p)->(%s:%s): unsupported property\n", This, debugstr_w(prop), debugstr_variant(&value));
2630 if(!memcmp(prop, PropertyCharsetW, sizeof(PropertyCharsetW)))
2633 if(!memcmp(prop, PropertyDomNodeW, sizeof(PropertyDomNodeW)))
2636 if(!memcmp(prop, PropertyInputSourceW, sizeof(PropertyInputSourceW)))
2639 if(!memcmp(prop, PropertySchemaDeclHandlerW, sizeof(PropertySchemaDeclHandlerW)))
2642 if(!memcmp(prop, PropertyXMLDeclEncodingW, sizeof(PropertyXMLDeclEncodingW)))
2645 if(!memcmp(prop, PropertyXMLDeclStandaloneW, sizeof(PropertyXMLDeclStandaloneW)))
2648 if(!memcmp(prop, PropertyXMLDeclVersionW, sizeof(PropertyXMLDeclVersionW)))
2651 return E_INVALIDARG;
2654 static HRESULT internal_getProperty(const saxreader* This, const WCHAR *prop, VARIANT *value, BOOL vb)
2656 TRACE("(%p)->(%s)\n", This, debugstr_w(prop));
2658 if (!value) return E_POINTER;
2660 if (!memcmp(PropertyLexicalHandlerW, prop, sizeof(PropertyLexicalHandlerW)))
2662 V_VT(value) = VT_UNKNOWN;
2663 saxreader_get_handler(This, SAXLexicalHandler, vb, (void**)&V_UNKNOWN(value));
2667 if (!memcmp(PropertyDeclHandlerW, prop, sizeof(PropertyDeclHandlerW)))
2669 V_VT(value) = VT_UNKNOWN;
2670 saxreader_get_handler(This, SAXDeclHandler, vb, (void**)&V_UNKNOWN(value));
2674 if (!memcmp(PropertyXmlDeclVersionW, prop, sizeof(PropertyXmlDeclVersionW)))
2676 V_VT(value) = VT_BSTR;
2677 V_BSTR(value) = SysAllocString(This->xmldecl_version);
2681 FIXME("(%p)->(%s) unsupported property\n", This, debugstr_w(prop));
2686 /*** IVBSAXXMLReader interface ***/
2687 /*** IUnknown methods ***/
2688 static HRESULT WINAPI saxxmlreader_QueryInterface(IVBSAXXMLReader* iface, REFIID riid, void **ppvObject)
2690 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2692 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
2696 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
2697 IsEqualGUID( riid, &IID_IDispatch ) ||
2698 IsEqualGUID( riid, &IID_IVBSAXXMLReader ))
2702 else if( IsEqualGUID( riid, &IID_ISAXXMLReader ))
2704 *ppvObject = &This->ISAXXMLReader_iface;
2706 else if (dispex_query_interface(&This->dispex, riid, ppvObject))
2708 return *ppvObject ? S_OK : E_NOINTERFACE;
2712 FIXME("interface %s not implemented\n", debugstr_guid(riid));
2713 return E_NOINTERFACE;
2716 IVBSAXXMLReader_AddRef( iface );
2721 static ULONG WINAPI saxxmlreader_AddRef(IVBSAXXMLReader* iface)
2723 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2724 TRACE("%p\n", This );
2725 return InterlockedIncrement( &This->ref );
2728 static ULONG WINAPI saxxmlreader_Release(
2729 IVBSAXXMLReader* iface)
2731 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2734 TRACE("%p\n", This );
2736 ref = InterlockedDecrement( &This->ref );
2741 for (i = 0; i < SAXHandler_Last; i++)
2743 struct saxanyhandler_iface *iface = &This->saxhandlers[i].u.anyhandler;
2746 IUnknown_Release(iface->handler);
2748 if (iface->vbhandler)
2749 IUnknown_Release(iface->vbhandler);
2752 SysFreeString(This->xmldecl_version);
2753 free_bstr_pool(&This->pool);
2755 release_dispex(&This->dispex);
2762 static HRESULT WINAPI saxxmlreader_GetTypeInfoCount( IVBSAXXMLReader *iface, UINT* pctinfo )
2764 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2765 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2768 static HRESULT WINAPI saxxmlreader_GetTypeInfo(
2769 IVBSAXXMLReader *iface,
2770 UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
2772 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2773 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface,
2774 iTInfo, lcid, ppTInfo);
2777 static HRESULT WINAPI saxxmlreader_GetIDsOfNames(
2778 IVBSAXXMLReader *iface,
2780 LPOLESTR* rgszNames,
2785 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2786 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface,
2787 riid, rgszNames, cNames, lcid, rgDispId);
2790 static HRESULT WINAPI saxxmlreader_Invoke(
2791 IVBSAXXMLReader *iface,
2792 DISPID dispIdMember,
2796 DISPPARAMS* pDispParams,
2797 VARIANT* pVarResult,
2798 EXCEPINFO* pExcepInfo,
2801 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2802 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface,
2803 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2806 /*** IVBSAXXMLReader methods ***/
2807 static HRESULT WINAPI saxxmlreader_getFeature(
2808 IVBSAXXMLReader* iface,
2809 const WCHAR *feature_name,
2810 VARIANT_BOOL *value)
2812 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2813 saxreader_feature feature;
2815 TRACE("(%p)->(%s %p)\n", This, debugstr_w(feature_name), value);
2817 feature = get_saxreader_feature(feature_name);
2818 if (feature == Namespaces || feature == NamespacePrefixes)
2819 return get_feature_value(This, feature, value);
2821 FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(feature_name), value);
2825 static HRESULT WINAPI saxxmlreader_putFeature(
2826 IVBSAXXMLReader* iface,
2827 const WCHAR *feature_name,
2830 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2831 saxreader_feature feature;
2833 TRACE("(%p)->(%s %x)\n", This, debugstr_w(feature_name), value);
2835 feature = get_saxreader_feature(feature_name);
2837 /* accepted cases */
2838 if ((feature == ExternalGeneralEntities && value == VARIANT_FALSE) ||
2839 (feature == ExternalParameterEntities && value == VARIANT_FALSE) ||
2840 feature == Namespaces ||
2841 feature == NamespacePrefixes)
2843 return set_feature_value(This, feature, value);
2846 if (feature == LexicalHandlerParEntities || feature == ProhibitDTD)
2848 FIXME("(%p)->(%s %x) stub\n", This, debugstr_w(feature_name), value);
2849 return set_feature_value(This, feature, value);
2852 FIXME("(%p)->(%s %x) stub\n", This, debugstr_w(feature_name), value);
2856 static HRESULT WINAPI saxxmlreader_getProperty(
2857 IVBSAXXMLReader* iface,
2861 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2862 return internal_getProperty(This, prop, value, TRUE);
2865 static HRESULT WINAPI saxxmlreader_putProperty(
2866 IVBSAXXMLReader* iface,
2870 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2871 return internal_putProperty(This, pProp, value, TRUE);
2874 static HRESULT WINAPI saxxmlreader_get_entityResolver(
2875 IVBSAXXMLReader* iface,
2876 IVBSAXEntityResolver **resolver)
2878 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2879 return saxreader_get_handler(This, SAXEntityResolver, TRUE, (void**)resolver);
2882 static HRESULT WINAPI saxxmlreader_put_entityResolver(
2883 IVBSAXXMLReader* iface,
2884 IVBSAXEntityResolver *resolver)
2886 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2887 return saxreader_put_handler(This, SAXEntityResolver, resolver, TRUE);
2890 static HRESULT WINAPI saxxmlreader_get_contentHandler(
2891 IVBSAXXMLReader* iface,
2892 IVBSAXContentHandler **handler)
2894 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2895 return saxreader_get_handler(This, SAXContentHandler, TRUE, (void**)handler);
2898 static HRESULT WINAPI saxxmlreader_put_contentHandler(
2899 IVBSAXXMLReader* iface,
2900 IVBSAXContentHandler *handler)
2902 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2903 return saxreader_put_handler(This, SAXContentHandler, handler, TRUE);
2906 static HRESULT WINAPI saxxmlreader_get_dtdHandler(
2907 IVBSAXXMLReader* iface,
2908 IVBSAXDTDHandler **handler)
2910 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2911 return saxreader_get_handler(This, SAXDTDHandler, TRUE, (void**)handler);
2914 static HRESULT WINAPI saxxmlreader_put_dtdHandler(
2915 IVBSAXXMLReader* iface,
2916 IVBSAXDTDHandler *handler)
2918 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2919 return saxreader_put_handler(This, SAXDTDHandler, handler, TRUE);
2922 static HRESULT WINAPI saxxmlreader_get_errorHandler(
2923 IVBSAXXMLReader* iface,
2924 IVBSAXErrorHandler **handler)
2926 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2927 return saxreader_get_handler(This, SAXErrorHandler, TRUE, (void**)handler);
2930 static HRESULT WINAPI saxxmlreader_put_errorHandler(
2931 IVBSAXXMLReader* iface,
2932 IVBSAXErrorHandler *handler)
2934 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2935 return saxreader_put_handler(This, SAXErrorHandler, handler, TRUE);
2938 static HRESULT WINAPI saxxmlreader_get_baseURL(
2939 IVBSAXXMLReader* iface,
2940 const WCHAR **pBaseUrl)
2942 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2944 FIXME("(%p)->(%p) stub\n", This, pBaseUrl);
2948 static HRESULT WINAPI saxxmlreader_put_baseURL(
2949 IVBSAXXMLReader* iface,
2950 const WCHAR *pBaseUrl)
2952 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2954 FIXME("(%p)->(%s) stub\n", This, debugstr_w(pBaseUrl));
2958 static HRESULT WINAPI saxxmlreader_get_secureBaseURL(
2959 IVBSAXXMLReader* iface,
2960 const WCHAR **pSecureBaseUrl)
2962 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2964 FIXME("(%p)->(%p) stub\n", This, pSecureBaseUrl);
2969 static HRESULT WINAPI saxxmlreader_put_secureBaseURL(
2970 IVBSAXXMLReader* iface,
2971 const WCHAR *secureBaseUrl)
2973 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2975 FIXME("(%p)->(%s) stub\n", This, debugstr_w(secureBaseUrl));
2979 static HRESULT WINAPI saxxmlreader_parse(
2980 IVBSAXXMLReader* iface,
2983 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2984 return internal_parse(This, varInput, TRUE);
2987 static HRESULT WINAPI saxxmlreader_parseURL(
2988 IVBSAXXMLReader* iface,
2991 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2992 return internal_parseURL(This, url, TRUE);
2995 static const struct IVBSAXXMLReaderVtbl VBSAXXMLReaderVtbl =
2997 saxxmlreader_QueryInterface,
2998 saxxmlreader_AddRef,
2999 saxxmlreader_Release,
3000 saxxmlreader_GetTypeInfoCount,
3001 saxxmlreader_GetTypeInfo,
3002 saxxmlreader_GetIDsOfNames,
3003 saxxmlreader_Invoke,
3004 saxxmlreader_getFeature,
3005 saxxmlreader_putFeature,
3006 saxxmlreader_getProperty,
3007 saxxmlreader_putProperty,
3008 saxxmlreader_get_entityResolver,
3009 saxxmlreader_put_entityResolver,
3010 saxxmlreader_get_contentHandler,
3011 saxxmlreader_put_contentHandler,
3012 saxxmlreader_get_dtdHandler,
3013 saxxmlreader_put_dtdHandler,
3014 saxxmlreader_get_errorHandler,
3015 saxxmlreader_put_errorHandler,
3016 saxxmlreader_get_baseURL,
3017 saxxmlreader_put_baseURL,
3018 saxxmlreader_get_secureBaseURL,
3019 saxxmlreader_put_secureBaseURL,
3021 saxxmlreader_parseURL
3024 /*** ISAXXMLReader interface ***/
3025 /*** IUnknown methods ***/
3026 static HRESULT WINAPI isaxxmlreader_QueryInterface(ISAXXMLReader* iface, REFIID riid, void **ppvObject)
3028 saxreader *This = impl_from_ISAXXMLReader( iface );
3029 return saxxmlreader_QueryInterface(&This->IVBSAXXMLReader_iface, riid, ppvObject);
3032 static ULONG WINAPI isaxxmlreader_AddRef(ISAXXMLReader* iface)
3034 saxreader *This = impl_from_ISAXXMLReader( iface );
3035 return saxxmlreader_AddRef(&This->IVBSAXXMLReader_iface);
3038 static ULONG WINAPI isaxxmlreader_Release(ISAXXMLReader* iface)
3040 saxreader *This = impl_from_ISAXXMLReader( iface );
3041 return saxxmlreader_Release(&This->IVBSAXXMLReader_iface);
3044 /*** ISAXXMLReader methods ***/
3045 static HRESULT WINAPI isaxxmlreader_getFeature(
3046 ISAXXMLReader* iface,
3047 const WCHAR *pFeature,
3048 VARIANT_BOOL *pValue)
3050 saxreader *This = impl_from_ISAXXMLReader( iface );
3051 return IVBSAXXMLReader_getFeature(&This->IVBSAXXMLReader_iface, pFeature, pValue);
3054 static HRESULT WINAPI isaxxmlreader_putFeature(
3055 ISAXXMLReader* iface,
3056 const WCHAR *pFeature,
3057 VARIANT_BOOL vfValue)
3059 saxreader *This = impl_from_ISAXXMLReader( iface );
3060 return IVBSAXXMLReader_putFeature(&This->IVBSAXXMLReader_iface, pFeature, vfValue);
3063 static HRESULT WINAPI isaxxmlreader_getProperty(
3064 ISAXXMLReader* iface,
3068 saxreader *This = impl_from_ISAXXMLReader( iface );
3069 return internal_getProperty(This, prop, value, FALSE);
3072 static HRESULT WINAPI isaxxmlreader_putProperty(
3073 ISAXXMLReader* iface,
3077 saxreader *This = impl_from_ISAXXMLReader( iface );
3078 return internal_putProperty(This, pProp, value, FALSE);
3081 static HRESULT WINAPI isaxxmlreader_getEntityResolver(
3082 ISAXXMLReader* iface,
3083 ISAXEntityResolver **resolver)
3085 saxreader *This = impl_from_ISAXXMLReader( iface );
3086 return saxreader_get_handler(This, SAXEntityResolver, FALSE, (void**)resolver);
3089 static HRESULT WINAPI isaxxmlreader_putEntityResolver(
3090 ISAXXMLReader* iface,
3091 ISAXEntityResolver *resolver)
3093 saxreader *This = impl_from_ISAXXMLReader( iface );
3094 return saxreader_put_handler(This, SAXEntityResolver, resolver, FALSE);
3097 static HRESULT WINAPI isaxxmlreader_getContentHandler(
3098 ISAXXMLReader* iface,
3099 ISAXContentHandler **handler)
3101 saxreader *This = impl_from_ISAXXMLReader( iface );
3102 return saxreader_get_handler(This, SAXContentHandler, FALSE, (void**)handler);
3105 static HRESULT WINAPI isaxxmlreader_putContentHandler(
3106 ISAXXMLReader* iface,
3107 ISAXContentHandler *handler)
3109 saxreader *This = impl_from_ISAXXMLReader( iface );
3110 return saxreader_put_handler(This, SAXContentHandler, handler, FALSE);
3113 static HRESULT WINAPI isaxxmlreader_getDTDHandler(
3114 ISAXXMLReader* iface,
3115 ISAXDTDHandler **handler)
3117 saxreader *This = impl_from_ISAXXMLReader( iface );
3118 return saxreader_get_handler(This, SAXDTDHandler, FALSE, (void**)handler);
3121 static HRESULT WINAPI isaxxmlreader_putDTDHandler(
3122 ISAXXMLReader* iface,
3123 ISAXDTDHandler *handler)
3125 saxreader *This = impl_from_ISAXXMLReader( iface );
3126 return saxreader_put_handler(This, SAXDTDHandler, handler, FALSE);
3129 static HRESULT WINAPI isaxxmlreader_getErrorHandler(
3130 ISAXXMLReader* iface,
3131 ISAXErrorHandler **handler)
3133 saxreader *This = impl_from_ISAXXMLReader( iface );
3134 return saxreader_get_handler(This, SAXErrorHandler, FALSE, (void**)handler);
3137 static HRESULT WINAPI isaxxmlreader_putErrorHandler(ISAXXMLReader* iface, ISAXErrorHandler *handler)
3139 saxreader *This = impl_from_ISAXXMLReader( iface );
3140 return saxreader_put_handler(This, SAXErrorHandler, handler, FALSE);
3143 static HRESULT WINAPI isaxxmlreader_getBaseURL(
3144 ISAXXMLReader* iface,
3145 const WCHAR **pBaseUrl)
3147 saxreader *This = impl_from_ISAXXMLReader( iface );
3148 return IVBSAXXMLReader_get_baseURL(&This->IVBSAXXMLReader_iface, pBaseUrl);
3151 static HRESULT WINAPI isaxxmlreader_putBaseURL(
3152 ISAXXMLReader* iface,
3153 const WCHAR *pBaseUrl)
3155 saxreader *This = impl_from_ISAXXMLReader( iface );
3156 return IVBSAXXMLReader_put_baseURL(&This->IVBSAXXMLReader_iface, pBaseUrl);
3159 static HRESULT WINAPI isaxxmlreader_getSecureBaseURL(
3160 ISAXXMLReader* iface,
3161 const WCHAR **pSecureBaseUrl)
3163 saxreader *This = impl_from_ISAXXMLReader( iface );
3164 return IVBSAXXMLReader_get_secureBaseURL(&This->IVBSAXXMLReader_iface, pSecureBaseUrl);
3167 static HRESULT WINAPI isaxxmlreader_putSecureBaseURL(
3168 ISAXXMLReader* iface,
3169 const WCHAR *secureBaseUrl)
3171 saxreader *This = impl_from_ISAXXMLReader( iface );
3172 return IVBSAXXMLReader_put_secureBaseURL(&This->IVBSAXXMLReader_iface, secureBaseUrl);
3175 static HRESULT WINAPI isaxxmlreader_parse(
3176 ISAXXMLReader* iface,
3179 saxreader *This = impl_from_ISAXXMLReader( iface );
3180 return internal_parse(This, varInput, FALSE);
3183 static HRESULT WINAPI isaxxmlreader_parseURL(
3184 ISAXXMLReader* iface,
3187 saxreader *This = impl_from_ISAXXMLReader( iface );
3188 return internal_parseURL(This, url, FALSE);
3191 static const struct ISAXXMLReaderVtbl SAXXMLReaderVtbl =
3193 isaxxmlreader_QueryInterface,
3194 isaxxmlreader_AddRef,
3195 isaxxmlreader_Release,
3196 isaxxmlreader_getFeature,
3197 isaxxmlreader_putFeature,
3198 isaxxmlreader_getProperty,
3199 isaxxmlreader_putProperty,
3200 isaxxmlreader_getEntityResolver,
3201 isaxxmlreader_putEntityResolver,
3202 isaxxmlreader_getContentHandler,
3203 isaxxmlreader_putContentHandler,
3204 isaxxmlreader_getDTDHandler,
3205 isaxxmlreader_putDTDHandler,
3206 isaxxmlreader_getErrorHandler,
3207 isaxxmlreader_putErrorHandler,
3208 isaxxmlreader_getBaseURL,
3209 isaxxmlreader_putBaseURL,
3210 isaxxmlreader_getSecureBaseURL,
3211 isaxxmlreader_putSecureBaseURL,
3212 isaxxmlreader_parse,
3213 isaxxmlreader_parseURL
3216 static const tid_t saxreader_iface_tids[] = {
3217 IVBSAXXMLReader_tid,
3220 static dispex_static_data_t saxreader_dispex = {
3222 IVBSAXXMLReader_tid,
3224 saxreader_iface_tids
3227 HRESULT SAXXMLReader_create(MSXML_VERSION version, IUnknown *outer, LPVOID *ppObj)
3231 TRACE("(%p, %p)\n", outer, ppObj);
3233 reader = heap_alloc( sizeof (*reader) );
3235 return E_OUTOFMEMORY;
3237 reader->IVBSAXXMLReader_iface.lpVtbl = &VBSAXXMLReaderVtbl;
3238 reader->ISAXXMLReader_iface.lpVtbl = &SAXXMLReaderVtbl;
3240 memset(reader->saxhandlers, 0, sizeof(reader->saxhandlers));
3241 reader->isParsing = FALSE;
3242 reader->xmldecl_version = NULL;
3243 reader->pool.pool = NULL;
3244 reader->pool.index = 0;
3245 reader->pool.len = 0;
3246 reader->features = Namespaces | NamespacePrefixes;
3247 reader->version = version;
3249 init_dispex(&reader->dispex, (IUnknown*)&reader->IVBSAXXMLReader_iface, &saxreader_dispex);
3251 memset(&reader->sax, 0, sizeof(xmlSAXHandler));
3252 reader->sax.initialized = XML_SAX2_MAGIC;
3253 reader->sax.startDocument = libxmlStartDocument;
3254 reader->sax.endDocument = libxmlEndDocument;
3255 reader->sax.startElementNs = libxmlStartElementNS;
3256 reader->sax.endElementNs = libxmlEndElementNS;
3257 reader->sax.characters = libxmlCharacters;
3258 reader->sax.setDocumentLocator = libxmlSetDocumentLocator;
3259 reader->sax.comment = libxmlComment;
3260 reader->sax.error = libxmlFatalError;
3261 reader->sax.fatalError = libxmlFatalError;
3262 reader->sax.cdataBlock = libxmlCDataBlock;
3263 reader->sax.resolveEntity = libxmlresolveentity;
3265 *ppObj = &reader->IVBSAXXMLReader_iface;
3267 TRACE("returning iface %p\n", *ppObj);
3274 HRESULT SAXXMLReader_create(MSXML_VERSION version, IUnknown *pUnkOuter, LPVOID *ppObj)
3276 MESSAGE("This program tried to use a SAX XML Reader object, but\n"
3277 "libxml2 support was not present at compile time.\n");