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"
46 #include "msxml_private.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
54 ExhaustiveErrors
= 1 << 1,
55 ExternalGeneralEntities
= 1 << 2,
56 ExternalParameterEntities
= 1 << 3,
57 ForcedResync
= 1 << 4,
58 NamespacePrefixes
= 1 << 5,
60 ParameterEntities
= 1 << 7,
61 PreserveSystemIndentifiers
= 1 << 8,
63 SchemaValidation
= 1 << 10,
64 ServerHttpRequest
= 1 << 11,
65 SuppressValidationfatalError
= 1 << 12,
66 UseInlineSchema
= 1 << 13,
67 UseSchemaLocation
= 1 << 14,
68 LexicalHandlerParEntities
= 1 << 15
78 typedef struct _saxreader
80 IVBSAXXMLReader IVBSAXXMLReader_iface
;
81 ISAXXMLReader ISAXXMLReader_iface
;
83 struct ISAXContentHandler
*contentHandler
;
84 struct IVBSAXContentHandler
*vbcontentHandler
;
85 struct ISAXErrorHandler
*errorHandler
;
86 struct IVBSAXErrorHandler
*vberrorHandler
;
87 struct ISAXLexicalHandler
*lexicalHandler
;
88 struct IVBSAXLexicalHandler
*vblexicalHandler
;
89 struct ISAXDeclHandler
*declHandler
;
90 struct IVBSAXDeclHandler
*vbdeclHandler
;
94 enum ReaderFeatures features
;
97 typedef struct _saxlocator
99 IVBSAXLocator IVBSAXLocator_iface
;
100 ISAXLocator ISAXLocator_iface
;
102 saxreader
*saxreader
;
104 xmlParserCtxtPtr pParserCtxt
;
118 typedef struct _saxattributes
120 IVBSAXAttributes IVBSAXAttributes_iface
;
121 ISAXAttributes ISAXAttributes_iface
;
130 static inline saxreader
*impl_from_IVBSAXXMLReader( IVBSAXXMLReader
*iface
)
132 return CONTAINING_RECORD(iface
, saxreader
, IVBSAXXMLReader_iface
);
135 static inline saxreader
*impl_from_ISAXXMLReader( ISAXXMLReader
*iface
)
137 return CONTAINING_RECORD(iface
, saxreader
, ISAXXMLReader_iface
);
140 static inline saxlocator
*impl_from_IVBSAXLocator( IVBSAXLocator
*iface
)
142 return CONTAINING_RECORD(iface
, saxlocator
, IVBSAXLocator_iface
);
145 static inline saxlocator
*impl_from_ISAXLocator( ISAXLocator
*iface
)
147 return CONTAINING_RECORD(iface
, saxlocator
, ISAXLocator_iface
);
150 static inline saxattributes
*impl_from_IVBSAXAttributes( IVBSAXAttributes
*iface
)
152 return CONTAINING_RECORD(iface
, saxattributes
, IVBSAXAttributes_iface
);
155 static inline saxattributes
*impl_from_ISAXAttributes( ISAXAttributes
*iface
)
157 return CONTAINING_RECORD(iface
, saxattributes
, ISAXAttributes_iface
);
161 static const WCHAR PropertyCharsetW
[] = {
162 'c','h','a','r','s','e','t',0
164 static const WCHAR PropertyDeclHandlerW
[] = {
165 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
166 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
167 'd','e','c','l','a','r','a','t','i','o','n',
168 '-','h','a','n','d','l','e','r',0
170 static const WCHAR PropertyDomNodeW
[] = {
171 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
172 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
173 'd','o','m','-','n','o','d','e',0
175 static const WCHAR PropertyInputSourceW
[] = {
176 'i','n','p','u','t','-','s','o','u','r','c','e',0
178 static const WCHAR PropertyLexicalHandlerW
[] = {
179 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
180 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
181 'l','e','x','i','c','a','l','-','h','a','n','d','l','e','r',0
183 static const WCHAR PropertyMaxElementDepthW
[] = {
184 'm','a','x','-','e','l','e','m','e','n','t','-','d','e','p','t','h',0
186 static const WCHAR PropertyMaxXMLSizeW
[] = {
187 'm','a','x','-','x','m','l','-','s','i','z','e',0
189 static const WCHAR PropertySchemaDeclHandlerW
[] = {
190 's','c','h','e','m','a','-','d','e','c','l','a','r','a','t','i','o','n','-',
191 'h','a','n','d','l','e','r',0
193 static const WCHAR PropertyXMLDeclEncodingW
[] = {
194 'x','m','l','d','e','c','l','-','e','n','c','o','d','i','n','g',0
196 static const WCHAR PropertyXMLDeclStandaloneW
[] = {
197 'x','m','l','d','e','c','l','-','s','t','a','n','d','a','l','o','n','e',0
199 static const WCHAR PropertyXMLDeclVersionW
[] = {
200 'x','m','l','d','e','c','l','-','v','e','r','s','i','o','n',0
204 static const WCHAR FeatureExternalGeneralEntitiesW
[] = {
205 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/',
206 'f','e','a','t','u','r','e','s','/','e','x','t','e','r','n','a','l','-','g','e','n','e','r','a','l',
207 '-','e','n','t','i','t','i','e','s',0
210 static const WCHAR FeatureExternalParameterEntitiesW
[] = {
211 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/','f','e','a','t','u','r','e','s',
212 '/','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
215 static const WCHAR FeatureLexicalHandlerParEntitiesW
[] = {
216 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/','f','e','a','t','u','r','e','s',
217 '/','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
220 static const WCHAR FeatureProhibitDTDW
[] = {
221 'p','r','o','h','i','b','i','t','-','d','t','d',0
224 static inline HRESULT
set_feature_value(saxreader
*reader
, enum ReaderFeatures feature
, VARIANT_BOOL value
)
226 if (value
== VARIANT_TRUE
)
227 reader
->features
|= feature
;
229 reader
->features
&= ~feature
;
234 static inline BOOL
has_content_handler(const saxlocator
*locator
)
236 return (locator
->vbInterface
&& locator
->saxreader
->vbcontentHandler
) ||
237 (!locator
->vbInterface
&& locator
->saxreader
->contentHandler
);
240 static inline BOOL
has_error_handler(const saxlocator
*locator
)
242 return (locator
->vbInterface
&& locator
->saxreader
->vberrorHandler
) ||
243 (!locator
->vbInterface
&& locator
->saxreader
->errorHandler
);
246 static HRESULT
namespacePush(saxlocator
*locator
, int ns
)
248 if(locator
->nsStackLast
>=locator
->nsStackSize
)
252 new_stack
= HeapReAlloc(GetProcessHeap(), 0,
253 locator
->nsStack
, sizeof(int)*locator
->nsStackSize
*2);
254 if(!new_stack
) return E_OUTOFMEMORY
;
255 locator
->nsStack
= new_stack
;
256 locator
->nsStackSize
*= 2;
258 locator
->nsStack
[locator
->nsStackLast
++] = ns
;
263 static int namespacePop(saxlocator
*locator
)
265 if(locator
->nsStackLast
== 0) return 0;
266 return locator
->nsStack
[--locator
->nsStackLast
];
269 static BOOL
bstr_pool_insert(struct bstrpool
*pool
, BSTR pool_entry
)
273 pool
->pool
= HeapAlloc(GetProcessHeap(), 0, 16 * sizeof(*pool
->pool
));
280 else if (pool
->index
== pool
->len
)
282 BSTR
*realloc
= HeapReAlloc(GetProcessHeap(), 0, pool
->pool
, pool
->len
* 2 * sizeof(*realloc
));
287 pool
->pool
= realloc
;
291 pool
->pool
[pool
->index
++] = pool_entry
;
295 static void free_bstr_pool(struct bstrpool
*pool
)
299 for (i
= 0; i
< pool
->index
; i
++)
300 SysFreeString(pool
->pool
[i
]);
302 HeapFree(GetProcessHeap(), 0, pool
->pool
);
305 pool
->index
= pool
->len
= 0;
308 static BSTR
bstr_from_xmlCharN(const xmlChar
*buf
, int len
)
316 dLen
= MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)buf
, len
, NULL
, 0);
317 if(len
!= -1) dLen
++;
318 bstr
= SysAllocStringLen(NULL
, dLen
-1);
321 MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)buf
, len
, bstr
, dLen
);
322 if(len
!= -1) bstr
[dLen
-1] = '\0';
327 static BSTR
QName_from_xmlChar(const xmlChar
*prefix
, const xmlChar
*name
)
332 if(!name
) return NULL
;
334 if(!prefix
|| !*prefix
)
335 return bstr_from_xmlChar(name
);
337 qname
= xmlBuildQName(name
, prefix
, NULL
, 0);
338 bstr
= bstr_from_xmlChar(qname
);
344 static BSTR
pooled_bstr_from_xmlChar(struct bstrpool
*pool
, const xmlChar
*buf
)
346 BSTR pool_entry
= bstr_from_xmlChar(buf
);
348 if (pool_entry
&& !bstr_pool_insert(pool
, pool_entry
))
350 SysFreeString(pool_entry
);
357 static BSTR
pooled_bstr_from_xmlCharN(struct bstrpool
*pool
, const xmlChar
*buf
, int len
)
359 BSTR pool_entry
= bstr_from_xmlCharN(buf
, len
);
361 if (pool_entry
&& !bstr_pool_insert(pool
, pool_entry
))
363 SysFreeString(pool_entry
);
370 static BSTR
pooled_QName_from_xmlChar(struct bstrpool
*pool
, const xmlChar
*prefix
, const xmlChar
*name
)
372 BSTR pool_entry
= QName_from_xmlChar(prefix
, name
);
374 if (pool_entry
&& !bstr_pool_insert(pool
, pool_entry
))
376 SysFreeString(pool_entry
);
383 static void format_error_message_from_id(saxlocator
*This
, HRESULT hr
)
385 xmlStopParser(This
->pParserCtxt
);
388 if(has_error_handler(This
))
391 if(!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
,
392 NULL
, hr
, 0, msg
, sizeof(msg
), NULL
))
394 FIXME("MSXML errors not yet supported.\n");
398 if(This
->vbInterface
)
400 BSTR bstrMsg
= SysAllocString(msg
);
401 IVBSAXErrorHandler_fatalError(This
->saxreader
->vberrorHandler
,
402 &This
->IVBSAXLocator_iface
, &bstrMsg
, hr
);
403 SysFreeString(bstrMsg
);
406 ISAXErrorHandler_fatalError(This
->saxreader
->errorHandler
,
407 &This
->ISAXLocator_iface
, msg
, hr
);
411 static void update_position(saxlocator
*This
, xmlChar
*end
)
413 if(This
->lastCur
== NULL
)
415 This
->lastCur
= (xmlChar
*)This
->pParserCtxt
->input
->base
;
417 This
->realColumn
= 1;
419 else if(This
->lastCur
< This
->pParserCtxt
->input
->base
)
421 This
->lastCur
= (xmlChar
*)This
->pParserCtxt
->input
->base
;
423 This
->realColumn
= 1;
426 if(This
->pParserCtxt
->input
->cur
<This
->lastCur
)
428 This
->lastCur
= (xmlChar
*)This
->pParserCtxt
->input
->base
;
430 This
->realColumn
= 1;
433 if(!end
) end
= (xmlChar
*)This
->pParserCtxt
->input
->cur
;
435 while(This
->lastCur
< end
)
437 if(*(This
->lastCur
) == '\n')
440 This
->realColumn
= 1;
442 else if(*(This
->lastCur
) == '\r' &&
443 (This
->lastCur
==This
->pParserCtxt
->input
->end
||
444 *(This
->lastCur
+1)!='\n'))
447 This
->realColumn
= 1;
449 else This
->realColumn
++;
453 /* Count multibyte UTF8 encoded characters once */
454 while((*(This
->lastCur
)&0xC0) == 0x80) This
->lastCur
++;
457 This
->line
= This
->realLine
;
458 This
->column
= This
->realColumn
;
461 /*** IVBSAXAttributes interface ***/
462 /*** IUnknown methods ***/
463 static HRESULT WINAPI
ivbsaxattributes_QueryInterface(
464 IVBSAXAttributes
* iface
,
468 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
470 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
474 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
475 IsEqualGUID(riid
, &IID_IDispatch
) ||
476 IsEqualGUID(riid
, &IID_IVBSAXAttributes
))
482 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
483 return E_NOINTERFACE
;
486 IVBSAXAttributes_AddRef(iface
);
491 static ULONG WINAPI
ivbsaxattributes_AddRef(IVBSAXAttributes
* iface
)
493 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
494 return ISAXAttributes_AddRef(&This
->ISAXAttributes_iface
);
497 static ULONG WINAPI
ivbsaxattributes_Release(IVBSAXAttributes
* iface
)
499 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
500 return ISAXAttributes_Release(&This
->ISAXAttributes_iface
);
503 /*** IDispatch methods ***/
504 static HRESULT WINAPI
ivbsaxattributes_GetTypeInfoCount( IVBSAXAttributes
*iface
, UINT
* pctinfo
)
506 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
508 TRACE("(%p)->(%p)\n", This
, pctinfo
);
515 static HRESULT WINAPI
ivbsaxattributes_GetTypeInfo(
516 IVBSAXAttributes
*iface
,
517 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
519 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
522 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
524 hr
= get_typeinfo(IVBSAXAttributes_tid
, ppTInfo
);
529 static HRESULT WINAPI
ivbsaxattributes_GetIDsOfNames(
530 IVBSAXAttributes
*iface
,
537 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
541 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
544 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
547 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
550 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
551 ITypeInfo_Release(typeinfo
);
557 static HRESULT WINAPI
ivbsaxattributes_Invoke(
558 IVBSAXAttributes
*iface
,
563 DISPPARAMS
* pDispParams
,
565 EXCEPINFO
* pExcepInfo
,
568 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
572 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
573 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
575 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
578 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IVBSAXAttributes_iface
, dispIdMember
, wFlags
,
579 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
580 ITypeInfo_Release(typeinfo
);
586 /*** IVBSAXAttributes methods ***/
587 static HRESULT WINAPI
ivbsaxattributes_get_length(
588 IVBSAXAttributes
* iface
,
591 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
592 return ISAXAttributes_getLength(&This
->ISAXAttributes_iface
, nLength
);
595 static HRESULT WINAPI
ivbsaxattributes_getURI(
596 IVBSAXAttributes
* iface
,
601 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
602 return ISAXAttributes_getURI(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)uri
, &len
);
605 static HRESULT WINAPI
ivbsaxattributes_getLocalName(
606 IVBSAXAttributes
* iface
,
611 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
612 return ISAXAttributes_getLocalName(&This
->ISAXAttributes_iface
, nIndex
,
613 (const WCHAR
**)localName
, &len
);
616 static HRESULT WINAPI
ivbsaxattributes_getQName(
617 IVBSAXAttributes
* iface
,
622 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
623 return ISAXAttributes_getQName(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)QName
, &len
);
626 static HRESULT WINAPI
ivbsaxattributes_getIndexFromName(
627 IVBSAXAttributes
* iface
,
632 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
633 return ISAXAttributes_getIndexFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
634 localName
, SysStringLen(localName
), index
);
637 static HRESULT WINAPI
ivbsaxattributes_getIndexFromQName(
638 IVBSAXAttributes
* iface
,
642 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
643 return ISAXAttributes_getIndexFromQName(&This
->ISAXAttributes_iface
, QName
,
644 SysStringLen(QName
), index
);
647 static HRESULT WINAPI
ivbsaxattributes_getType(
648 IVBSAXAttributes
* iface
,
653 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
654 return ISAXAttributes_getType(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)type
, &len
);
657 static HRESULT WINAPI
ivbsaxattributes_getTypeFromName(
658 IVBSAXAttributes
* iface
,
664 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
665 return ISAXAttributes_getTypeFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
666 localName
, SysStringLen(localName
), (const WCHAR
**)type
, &len
);
669 static HRESULT WINAPI
ivbsaxattributes_getTypeFromQName(
670 IVBSAXAttributes
* iface
,
675 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
676 return ISAXAttributes_getTypeFromQName(&This
->ISAXAttributes_iface
, QName
, SysStringLen(QName
),
677 (const WCHAR
**)type
, &len
);
680 static HRESULT WINAPI
ivbsaxattributes_getValue(
681 IVBSAXAttributes
* iface
,
686 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
687 return ISAXAttributes_getValue(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)value
, &len
);
690 static HRESULT WINAPI
ivbsaxattributes_getValueFromName(
691 IVBSAXAttributes
* iface
,
697 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
698 return ISAXAttributes_getValueFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
699 localName
, SysStringLen(localName
), (const WCHAR
**)value
, &len
);
702 static HRESULT WINAPI
ivbsaxattributes_getValueFromQName(
703 IVBSAXAttributes
* iface
,
708 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
709 return ISAXAttributes_getValueFromQName(&This
->ISAXAttributes_iface
, QName
,
710 SysStringLen(QName
), (const WCHAR
**)value
, &len
);
713 static const struct IVBSAXAttributesVtbl ivbsaxattributes_vtbl
=
715 ivbsaxattributes_QueryInterface
,
716 ivbsaxattributes_AddRef
,
717 ivbsaxattributes_Release
,
718 ivbsaxattributes_GetTypeInfoCount
,
719 ivbsaxattributes_GetTypeInfo
,
720 ivbsaxattributes_GetIDsOfNames
,
721 ivbsaxattributes_Invoke
,
722 ivbsaxattributes_get_length
,
723 ivbsaxattributes_getURI
,
724 ivbsaxattributes_getLocalName
,
725 ivbsaxattributes_getQName
,
726 ivbsaxattributes_getIndexFromName
,
727 ivbsaxattributes_getIndexFromQName
,
728 ivbsaxattributes_getType
,
729 ivbsaxattributes_getTypeFromName
,
730 ivbsaxattributes_getTypeFromQName
,
731 ivbsaxattributes_getValue
,
732 ivbsaxattributes_getValueFromName
,
733 ivbsaxattributes_getValueFromQName
736 /*** ISAXAttributes interface ***/
737 /*** IUnknown methods ***/
738 static HRESULT WINAPI
isaxattributes_QueryInterface(
739 ISAXAttributes
* iface
,
743 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
745 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
749 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
750 IsEqualGUID(riid
, &IID_ISAXAttributes
))
756 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
757 return E_NOINTERFACE
;
760 ISAXAttributes_AddRef(iface
);
765 static ULONG WINAPI
isaxattributes_AddRef(ISAXAttributes
* iface
)
767 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
769 return InterlockedIncrement(&This
->ref
);
772 static ULONG WINAPI
isaxattributes_Release(ISAXAttributes
* iface
)
774 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
779 ref
= InterlockedDecrement(&This
->ref
);
783 for(index
=0; index
<This
->nb_attributes
; index
++)
785 SysFreeString(This
->szLocalname
[index
]);
786 SysFreeString(This
->szURI
[index
]);
787 SysFreeString(This
->szValue
[index
]);
788 SysFreeString(This
->szQName
[index
]);
791 heap_free(This
->szLocalname
);
792 heap_free(This
->szURI
);
793 heap_free(This
->szValue
);
794 heap_free(This
->szQName
);
802 /*** ISAXAttributes methods ***/
803 static HRESULT WINAPI
isaxattributes_getLength(
804 ISAXAttributes
* iface
,
807 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
809 *length
= This
->nb_attributes
;
810 TRACE("Length set to %d\n", *length
);
814 static HRESULT WINAPI
isaxattributes_getURI(
815 ISAXAttributes
* iface
,
820 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
821 TRACE("(%p)->(%d)\n", This
, nIndex
);
823 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
824 if(!pUrl
|| !pUriSize
) return E_POINTER
;
826 *pUriSize
= SysStringLen(This
->szURI
[nIndex
]);
827 *pUrl
= This
->szURI
[nIndex
];
832 static HRESULT WINAPI
isaxattributes_getLocalName(
833 ISAXAttributes
* iface
,
835 const WCHAR
**pLocalName
,
836 int *pLocalNameLength
)
838 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
839 TRACE("(%p)->(%d)\n", This
, nIndex
);
841 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
842 if(!pLocalName
|| !pLocalNameLength
) return E_POINTER
;
844 *pLocalNameLength
= SysStringLen(This
->szLocalname
[nIndex
]);
845 *pLocalName
= This
->szLocalname
[nIndex
];
850 static HRESULT WINAPI
isaxattributes_getQName(
851 ISAXAttributes
* iface
,
853 const WCHAR
**pQName
,
856 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
857 TRACE("(%p)->(%d)\n", This
, nIndex
);
859 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
860 if(!pQName
|| !pQNameLength
) return E_POINTER
;
862 *pQNameLength
= SysStringLen(This
->szQName
[nIndex
]);
863 *pQName
= This
->szQName
[nIndex
];
868 static HRESULT WINAPI
isaxattributes_getName(
869 ISAXAttributes
* iface
,
873 const WCHAR
**pLocalName
,
875 const WCHAR
**pQName
,
878 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
879 TRACE("(%p)->(%d)\n", This
, nIndex
);
881 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
882 if(!pUri
|| !pUriLength
|| !pLocalName
|| !pLocalNameSize
883 || !pQName
|| !pQNameLength
) return E_POINTER
;
885 *pUriLength
= SysStringLen(This
->szURI
[nIndex
]);
886 *pUri
= This
->szURI
[nIndex
];
887 *pLocalNameSize
= SysStringLen(This
->szLocalname
[nIndex
]);
888 *pLocalName
= This
->szLocalname
[nIndex
];
889 *pQNameLength
= SysStringLen(This
->szQName
[nIndex
]);
890 *pQName
= This
->szQName
[nIndex
];
895 static HRESULT WINAPI
isaxattributes_getIndexFromName(
896 ISAXAttributes
* iface
,
899 const WCHAR
*pLocalName
,
903 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
905 TRACE("(%p)->(%s, %d, %s, %d)\n", This
, debugstr_w(pUri
), cUriLength
,
906 debugstr_w(pLocalName
), cocalNameLength
);
908 if(!pUri
|| !pLocalName
|| !index
) return E_POINTER
;
910 for(i
=0; i
<This
->nb_attributes
; i
++)
912 if(cUriLength
!=SysStringLen(This
->szURI
[i
])
913 || cocalNameLength
!=SysStringLen(This
->szLocalname
[i
]))
915 if(cUriLength
&& memcmp(pUri
, This
->szURI
[i
],
916 sizeof(WCHAR
)*cUriLength
))
918 if(cocalNameLength
&& memcmp(pLocalName
, This
->szLocalname
[i
],
919 sizeof(WCHAR
)*cocalNameLength
))
929 static HRESULT WINAPI
isaxattributes_getIndexFromQName(
930 ISAXAttributes
* iface
,
935 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
937 TRACE("(%p)->(%s, %d)\n", This
, debugstr_w(pQName
), nQNameLength
);
939 if(!pQName
|| !index
) return E_POINTER
;
940 if(!nQNameLength
) return E_INVALIDARG
;
942 for(i
=0; i
<This
->nb_attributes
; i
++)
944 if(nQNameLength
!=SysStringLen(This
->szQName
[i
])) continue;
945 if(memcmp(pQName
, This
->szQName
, sizeof(WCHAR
)*nQNameLength
)) continue;
954 static HRESULT WINAPI
isaxattributes_getType(
955 ISAXAttributes
* iface
,
960 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
962 FIXME("(%p)->(%d) stub\n", This
, nIndex
);
966 static HRESULT WINAPI
isaxattributes_getTypeFromName(
967 ISAXAttributes
* iface
,
970 const WCHAR
*pLocalName
,
975 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
977 FIXME("(%p)->(%s, %d, %s, %d) stub\n", This
, debugstr_w(pUri
), nUri
,
978 debugstr_w(pLocalName
), nLocalName
);
982 static HRESULT WINAPI
isaxattributes_getTypeFromQName(
983 ISAXAttributes
* iface
,
989 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
991 FIXME("(%p)->(%s, %d) stub\n", This
, debugstr_w(pQName
), nQName
);
995 static HRESULT WINAPI
isaxattributes_getValue(
996 ISAXAttributes
* iface
,
998 const WCHAR
**pValue
,
1001 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
1002 TRACE("(%p)->(%d)\n", This
, nIndex
);
1004 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
1005 if(!pValue
|| !nValue
) return E_POINTER
;
1007 *nValue
= SysStringLen(This
->szValue
[nIndex
]);
1008 *pValue
= This
->szValue
[nIndex
];
1013 static HRESULT WINAPI
isaxattributes_getValueFromName(
1014 ISAXAttributes
* iface
,
1017 const WCHAR
*pLocalName
,
1019 const WCHAR
**pValue
,
1024 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
1025 TRACE("(%p)->(%s, %d, %s, %d)\n", This
, debugstr_w(pUri
), nUri
,
1026 debugstr_w(pLocalName
), nLocalName
);
1028 hr
= ISAXAttributes_getIndexFromName(iface
,
1029 pUri
, nUri
, pLocalName
, nLocalName
, &index
);
1030 if(hr
==S_OK
) hr
= ISAXAttributes_getValue(iface
, index
, pValue
, nValue
);
1035 static HRESULT WINAPI
isaxattributes_getValueFromQName(
1036 ISAXAttributes
* iface
,
1037 const WCHAR
*pQName
,
1039 const WCHAR
**pValue
,
1044 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
1045 TRACE("(%p)->(%s, %d)\n", This
, debugstr_w(pQName
), nQName
);
1047 hr
= ISAXAttributes_getIndexFromQName(iface
, pQName
, nQName
, &index
);
1048 if(hr
==S_OK
) hr
= ISAXAttributes_getValue(iface
, index
, pValue
, nValue
);
1053 static const struct ISAXAttributesVtbl isaxattributes_vtbl
=
1055 isaxattributes_QueryInterface
,
1056 isaxattributes_AddRef
,
1057 isaxattributes_Release
,
1058 isaxattributes_getLength
,
1059 isaxattributes_getURI
,
1060 isaxattributes_getLocalName
,
1061 isaxattributes_getQName
,
1062 isaxattributes_getName
,
1063 isaxattributes_getIndexFromName
,
1064 isaxattributes_getIndexFromQName
,
1065 isaxattributes_getType
,
1066 isaxattributes_getTypeFromName
,
1067 isaxattributes_getTypeFromQName
,
1068 isaxattributes_getValue
,
1069 isaxattributes_getValueFromName
,
1070 isaxattributes_getValueFromQName
1073 static HRESULT
SAXAttributes_create(saxattributes
**attr
,
1074 int nb_namespaces
, const xmlChar
**xmlNamespaces
,
1075 int nb_attributes
, const xmlChar
**xmlAttributes
)
1077 saxattributes
*attributes
;
1079 static const xmlChar xmlns
[] = "xmlns";
1081 attributes
= heap_alloc(sizeof(*attributes
));
1083 return E_OUTOFMEMORY
;
1085 attributes
->IVBSAXAttributes_iface
.lpVtbl
= &ivbsaxattributes_vtbl
;
1086 attributes
->ISAXAttributes_iface
.lpVtbl
= &isaxattributes_vtbl
;
1087 attributes
->ref
= 1;
1089 attributes
->nb_attributes
= nb_namespaces
+nb_attributes
;
1091 attributes
->szLocalname
= heap_alloc(sizeof(BSTR
)*attributes
->nb_attributes
);
1092 attributes
->szURI
= heap_alloc(sizeof(BSTR
)*attributes
->nb_attributes
);
1093 attributes
->szValue
= heap_alloc(sizeof(BSTR
)*attributes
->nb_attributes
);
1094 attributes
->szQName
= heap_alloc(sizeof(BSTR
)*attributes
->nb_attributes
);
1096 if(!attributes
->szLocalname
|| !attributes
->szURI
1097 || !attributes
->szValue
|| !attributes
->szQName
)
1099 heap_free(attributes
->szLocalname
);
1100 heap_free(attributes
->szURI
);
1101 heap_free(attributes
->szValue
);
1102 heap_free(attributes
->szQName
);
1103 heap_free(attributes
);
1107 for(index
=0; index
<nb_namespaces
; index
++)
1109 attributes
->szLocalname
[index
] = SysAllocStringLen(NULL
, 0);
1110 attributes
->szURI
[index
] = SysAllocStringLen(NULL
, 0);
1111 attributes
->szValue
[index
] = bstr_from_xmlChar(xmlNamespaces
[2*index
+1]);
1112 attributes
->szQName
[index
] = QName_from_xmlChar(xmlns
, xmlNamespaces
[2*index
]);
1115 for(index
=0; index
<nb_attributes
; index
++)
1117 attributes
->szLocalname
[nb_namespaces
+index
] =
1118 bstr_from_xmlChar(xmlAttributes
[index
*5]);
1119 attributes
->szURI
[nb_namespaces
+index
] =
1120 bstr_from_xmlChar(xmlAttributes
[index
*5+2]);
1121 attributes
->szValue
[nb_namespaces
+index
] =
1122 bstr_from_xmlCharN(xmlAttributes
[index
*5+3],
1123 xmlAttributes
[index
*5+4]-xmlAttributes
[index
*5+3]);
1124 attributes
->szQName
[nb_namespaces
+index
] =
1125 QName_from_xmlChar(xmlAttributes
[index
*5+1], xmlAttributes
[index
*5]);
1130 TRACE("returning %p\n", *attr
);
1135 /*** LibXML callbacks ***/
1136 static void libxmlStartDocument(void *ctx
)
1138 saxlocator
*This
= ctx
;
1141 if(has_content_handler(This
))
1143 if(This
->vbInterface
)
1144 hr
= IVBSAXContentHandler_startDocument(This
->saxreader
->vbcontentHandler
);
1146 hr
= ISAXContentHandler_startDocument(This
->saxreader
->contentHandler
);
1149 format_error_message_from_id(This
, hr
);
1152 update_position(This
, NULL
);
1155 static void libxmlEndDocument(void *ctx
)
1157 saxlocator
*This
= ctx
;
1163 if(This
->ret
!= S_OK
) return;
1165 if(has_content_handler(This
))
1167 if(This
->vbInterface
)
1168 hr
= IVBSAXContentHandler_endDocument(This
->saxreader
->vbcontentHandler
);
1170 hr
= ISAXContentHandler_endDocument(This
->saxreader
->contentHandler
);
1173 format_error_message_from_id(This
, hr
);
1177 static void libxmlStartElementNS(
1179 const xmlChar
*localname
,
1180 const xmlChar
*prefix
,
1183 const xmlChar
**namespaces
,
1186 const xmlChar
**attributes
)
1188 BSTR NamespaceUri
, LocalName
, QName
, Prefix
, Uri
;
1189 saxlocator
*This
= ctx
;
1191 saxattributes
*attr
;
1194 if(*(This
->pParserCtxt
->input
->cur
) == '/')
1195 update_position(This
, (xmlChar
*)This
->pParserCtxt
->input
->cur
+2);
1197 update_position(This
, (xmlChar
*)This
->pParserCtxt
->input
->cur
+1);
1199 hr
= namespacePush(This
, nb_namespaces
);
1200 if(hr
==S_OK
&& has_content_handler(This
))
1202 for(index
=0; index
<nb_namespaces
; index
++)
1204 Prefix
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, namespaces
[2*index
]);
1205 Uri
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, namespaces
[2*index
+1]);
1207 if(This
->vbInterface
)
1208 hr
= IVBSAXContentHandler_startPrefixMapping(
1209 This
->saxreader
->vbcontentHandler
,
1212 hr
= ISAXContentHandler_startPrefixMapping(
1213 This
->saxreader
->contentHandler
,
1214 Prefix
, SysStringLen(Prefix
),
1215 Uri
, SysStringLen(Uri
));
1219 format_error_message_from_id(This
, hr
);
1224 NamespaceUri
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, URI
);
1225 LocalName
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, localname
);
1226 QName
= pooled_QName_from_xmlChar(&This
->saxreader
->pool
, prefix
, localname
);
1228 hr
= SAXAttributes_create(&attr
, nb_namespaces
, namespaces
, nb_attributes
, attributes
);
1231 if(This
->vbInterface
)
1232 hr
= IVBSAXContentHandler_startElement(This
->saxreader
->vbcontentHandler
,
1233 &NamespaceUri
, &LocalName
, &QName
, &attr
->IVBSAXAttributes_iface
);
1235 hr
= ISAXContentHandler_startElement(This
->saxreader
->contentHandler
, NamespaceUri
,
1236 SysStringLen(NamespaceUri
), LocalName
, SysStringLen(LocalName
), QName
,
1237 SysStringLen(QName
), &attr
->ISAXAttributes_iface
);
1239 ISAXAttributes_Release(&attr
->ISAXAttributes_iface
);
1244 format_error_message_from_id(This
, hr
);
1247 static void libxmlEndElementNS(
1249 const xmlChar
*localname
,
1250 const xmlChar
*prefix
,
1253 BSTR NamespaceUri
, LocalName
, QName
, Prefix
;
1254 saxlocator
*This
= ctx
;
1259 end
= (xmlChar
*)This
->pParserCtxt
->input
->cur
;
1260 if(*(end
-1) != '>' || *(end
-2) != '/')
1261 while(end
-2>=This
->pParserCtxt
->input
->base
1262 && *(end
-2)!='<' && *(end
-1)!='/') end
--;
1264 update_position(This
, end
);
1266 nsNr
= namespacePop(This
);
1268 if(has_content_handler(This
))
1270 NamespaceUri
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, URI
);
1271 LocalName
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, localname
);
1272 QName
= pooled_QName_from_xmlChar(&This
->saxreader
->pool
, prefix
, localname
);
1274 if(This
->vbInterface
)
1275 hr
= IVBSAXContentHandler_endElement(
1276 This
->saxreader
->vbcontentHandler
,
1277 &NamespaceUri
, &LocalName
, &QName
);
1279 hr
= ISAXContentHandler_endElement(
1280 This
->saxreader
->contentHandler
,
1281 NamespaceUri
, SysStringLen(NamespaceUri
),
1282 LocalName
, SysStringLen(LocalName
),
1283 QName
, SysStringLen(QName
));
1287 format_error_message_from_id(This
, hr
);
1291 for(index
=This
->pParserCtxt
->nsNr
-2;
1292 index
>=This
->pParserCtxt
->nsNr
-nsNr
*2; index
-=2)
1294 Prefix
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, This
->pParserCtxt
->nsTab
[index
]);
1296 if(This
->vbInterface
)
1297 hr
= IVBSAXContentHandler_endPrefixMapping(
1298 This
->saxreader
->vbcontentHandler
, &Prefix
);
1300 hr
= ISAXContentHandler_endPrefixMapping(
1301 This
->saxreader
->contentHandler
,
1302 Prefix
, SysStringLen(Prefix
));
1306 format_error_message_from_id(This
, hr
);
1313 update_position(This
, NULL
);
1316 static void libxmlCharacters(
1321 saxlocator
*This
= ctx
;
1326 BOOL lastEvent
= FALSE
;
1328 if(!(has_content_handler(This
))) return;
1331 if(*(ch
-1)=='\r') cur
--;
1334 if(ch
<This
->pParserCtxt
->input
->base
|| ch
>This
->pParserCtxt
->input
->end
)
1339 while(end
-ch
<len
&& *end
!='\r') end
++;
1346 if(!lastEvent
) *end
= '\n';
1348 Chars
= pooled_bstr_from_xmlCharN(&This
->saxreader
->pool
, cur
, end
-cur
+1);
1349 if(This
->vbInterface
)
1350 hr
= IVBSAXContentHandler_characters(
1351 This
->saxreader
->vbcontentHandler
, &Chars
);
1353 hr
= ISAXContentHandler_characters(
1354 This
->saxreader
->contentHandler
,
1355 Chars
, SysStringLen(Chars
));
1359 format_error_message_from_id(This
, hr
);
1363 This
->column
+= end
-cur
+1;
1377 if(end
-ch
== len
) break;
1380 if(ch
<This
->pParserCtxt
->input
->base
|| ch
>This
->pParserCtxt
->input
->end
)
1381 This
->column
= This
->realColumn
1382 +This
->pParserCtxt
->input
->cur
-This
->lastCur
;
1385 static void libxmlSetDocumentLocator(
1387 xmlSAXLocatorPtr loc
)
1389 saxlocator
*This
= ctx
;
1392 if(has_content_handler(This
))
1394 if(This
->vbInterface
)
1395 hr
= IVBSAXContentHandler_putref_documentLocator(This
->saxreader
->vbcontentHandler
,
1396 &This
->IVBSAXLocator_iface
);
1398 hr
= ISAXContentHandler_putDocumentLocator(This
->saxreader
->contentHandler
,
1399 &This
->ISAXLocator_iface
);
1403 format_error_message_from_id(This
, hr
);
1406 static void libxmlComment(void *ctx
, const xmlChar
*value
)
1408 saxlocator
*This
= ctx
;
1411 xmlChar
*beg
= (xmlChar
*)This
->pParserCtxt
->input
->cur
;
1413 while(beg
-4>=This
->pParserCtxt
->input
->base
1414 && memcmp(beg
-4, "<!--", sizeof(char[4]))) beg
--;
1415 update_position(This
, beg
);
1417 if(!This
->vbInterface
&& !This
->saxreader
->lexicalHandler
) return;
1418 if(This
->vbInterface
&& !This
->saxreader
->vblexicalHandler
) return;
1420 bValue
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, value
);
1422 if(This
->vbInterface
)
1423 hr
= IVBSAXLexicalHandler_comment(
1424 This
->saxreader
->vblexicalHandler
, &bValue
);
1426 hr
= ISAXLexicalHandler_comment(
1427 This
->saxreader
->lexicalHandler
,
1428 bValue
, SysStringLen(bValue
));
1431 format_error_message_from_id(This
, hr
);
1433 update_position(This
, NULL
);
1436 static void libxmlFatalError(void *ctx
, const char *msg
, ...)
1438 saxlocator
*This
= ctx
;
1444 va_start(args
, msg
);
1445 vsprintf(message
, msg
, args
);
1448 len
= MultiByteToWideChar(CP_UNIXCP
, 0, message
, -1, NULL
, 0);
1449 error
= heap_alloc(sizeof(WCHAR
)*len
);
1452 MultiByteToWideChar(CP_UNIXCP
, 0, message
, -1, error
, len
);
1453 TRACE("fatal error for %p: %s\n", This
, debugstr_w(error
));
1456 if(!has_error_handler(This
))
1458 xmlStopParser(This
->pParserCtxt
);
1464 FIXME("Error handling is not compatible.\n");
1466 if(This
->vbInterface
)
1468 BSTR bstrError
= SysAllocString(error
);
1469 IVBSAXErrorHandler_fatalError(This
->saxreader
->vberrorHandler
, &This
->IVBSAXLocator_iface
,
1470 &bstrError
, E_FAIL
);
1471 SysFreeString(bstrError
);
1474 ISAXErrorHandler_fatalError(This
->saxreader
->errorHandler
, &This
->ISAXLocator_iface
,
1479 xmlStopParser(This
->pParserCtxt
);
1483 static void libxmlCDataBlock(void *ctx
, const xmlChar
*value
, int len
)
1485 saxlocator
*This
= ctx
;
1487 xmlChar
*beg
= (xmlChar
*)This
->pParserCtxt
->input
->cur
-len
;
1491 BOOL lastEvent
= FALSE
, change
;
1493 while(beg
-9>=This
->pParserCtxt
->input
->base
1494 && memcmp(beg
-9, "<![CDATA[", sizeof(char[9]))) beg
--;
1495 update_position(This
, beg
);
1497 if(This
->vbInterface
&& This
->saxreader
->vblexicalHandler
)
1498 hr
= IVBSAXLexicalHandler_startCDATA(This
->saxreader
->vblexicalHandler
);
1499 if(!This
->vbInterface
&& This
->saxreader
->lexicalHandler
)
1500 hr
= ISAXLexicalHandler_startCDATA(This
->saxreader
->lexicalHandler
);
1504 format_error_message_from_id(This
, hr
);
1508 realLen
= This
->pParserCtxt
->input
->cur
-beg
-3;
1514 while(end
-beg
<realLen
&& *end
!='\r') end
++;
1515 if(end
-beg
==realLen
)
1520 else if(end
-beg
==realLen
-1 && *end
=='\r' && *(end
+1)=='\n')
1523 if(*end
== '\r') change
= TRUE
;
1524 else change
= FALSE
;
1526 if(change
) *end
= '\n';
1528 if(has_content_handler(This
))
1530 Chars
= pooled_bstr_from_xmlCharN(&This
->saxreader
->pool
, cur
, end
-cur
+1);
1531 if(This
->vbInterface
)
1532 hr
= IVBSAXContentHandler_characters(
1533 This
->saxreader
->vbcontentHandler
, &Chars
);
1535 hr
= ISAXContentHandler_characters(
1536 This
->saxreader
->contentHandler
,
1537 Chars
, SysStringLen(Chars
));
1540 if(change
) *end
= '\r';
1545 This
->column
+= end
-cur
+2;
1550 if(This
->vbInterface
&& This
->saxreader
->vblexicalHandler
)
1551 hr
= IVBSAXLexicalHandler_endCDATA(This
->saxreader
->vblexicalHandler
);
1552 if(!This
->vbInterface
&& This
->saxreader
->lexicalHandler
)
1553 hr
= ISAXLexicalHandler_endCDATA(This
->saxreader
->lexicalHandler
);
1556 format_error_message_from_id(This
, hr
);
1558 This
->column
+= 4+end
-cur
;
1561 /*** IVBSAXLocator interface ***/
1562 /*** IUnknown methods ***/
1563 static HRESULT WINAPI
ivbsaxlocator_QueryInterface(IVBSAXLocator
* iface
, REFIID riid
, void **ppvObject
)
1565 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1567 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
1571 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
1572 IsEqualGUID( riid
, &IID_IDispatch
) ||
1573 IsEqualGUID( riid
, &IID_IVBSAXLocator
))
1579 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1580 return E_NOINTERFACE
;
1583 IVBSAXLocator_AddRef( iface
);
1588 static ULONG WINAPI
ivbsaxlocator_AddRef(IVBSAXLocator
* iface
)
1590 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1591 TRACE("%p\n", This
);
1592 return InterlockedIncrement( &This
->ref
);
1595 static ULONG WINAPI
ivbsaxlocator_Release(
1596 IVBSAXLocator
* iface
)
1598 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1599 return ISAXLocator_Release((ISAXLocator
*)&This
->IVBSAXLocator_iface
);
1602 /*** IDispatch methods ***/
1603 static HRESULT WINAPI
ivbsaxlocator_GetTypeInfoCount( IVBSAXLocator
*iface
, UINT
* pctinfo
)
1605 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1607 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1614 static HRESULT WINAPI
ivbsaxlocator_GetTypeInfo(
1615 IVBSAXLocator
*iface
,
1616 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
1618 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1621 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1623 hr
= get_typeinfo(IVBSAXLocator_tid
, ppTInfo
);
1628 static HRESULT WINAPI
ivbsaxlocator_GetIDsOfNames(
1629 IVBSAXLocator
*iface
,
1631 LPOLESTR
* rgszNames
,
1636 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1637 ITypeInfo
*typeinfo
;
1640 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1643 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
1644 return E_INVALIDARG
;
1646 hr
= get_typeinfo(IVBSAXLocator_tid
, &typeinfo
);
1649 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
1650 ITypeInfo_Release(typeinfo
);
1656 static HRESULT WINAPI
ivbsaxlocator_Invoke(
1657 IVBSAXLocator
*iface
,
1658 DISPID dispIdMember
,
1662 DISPPARAMS
* pDispParams
,
1663 VARIANT
* pVarResult
,
1664 EXCEPINFO
* pExcepInfo
,
1667 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1668 ITypeInfo
*typeinfo
;
1671 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1672 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1674 hr
= get_typeinfo(IVBSAXLocator_tid
, &typeinfo
);
1677 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IVBSAXLocator_iface
, dispIdMember
, wFlags
,
1678 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1679 ITypeInfo_Release(typeinfo
);
1685 /*** IVBSAXLocator methods ***/
1686 static HRESULT WINAPI
ivbsaxlocator_get_columnNumber(
1687 IVBSAXLocator
* iface
,
1690 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1691 return ISAXLocator_getColumnNumber((ISAXLocator
*)&This
->IVBSAXLocator_iface
, pnColumn
);
1694 static HRESULT WINAPI
ivbsaxlocator_get_lineNumber(
1695 IVBSAXLocator
* iface
,
1698 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1699 return ISAXLocator_getLineNumber((ISAXLocator
*)&This
->IVBSAXLocator_iface
, pnLine
);
1702 static HRESULT WINAPI
ivbsaxlocator_get_publicId(
1703 IVBSAXLocator
* iface
,
1706 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1707 return ISAXLocator_getPublicId((ISAXLocator
*)&This
->IVBSAXLocator_iface
,
1708 (const WCHAR
**)publicId
);
1711 static HRESULT WINAPI
ivbsaxlocator_get_systemId(
1712 IVBSAXLocator
* iface
,
1715 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1716 return ISAXLocator_getSystemId((ISAXLocator
*)&This
->IVBSAXLocator_iface
,
1717 (const WCHAR
**)systemId
);
1720 static const struct IVBSAXLocatorVtbl ivbsaxlocator_vtbl
=
1722 ivbsaxlocator_QueryInterface
,
1723 ivbsaxlocator_AddRef
,
1724 ivbsaxlocator_Release
,
1725 ivbsaxlocator_GetTypeInfoCount
,
1726 ivbsaxlocator_GetTypeInfo
,
1727 ivbsaxlocator_GetIDsOfNames
,
1728 ivbsaxlocator_Invoke
,
1729 ivbsaxlocator_get_columnNumber
,
1730 ivbsaxlocator_get_lineNumber
,
1731 ivbsaxlocator_get_publicId
,
1732 ivbsaxlocator_get_systemId
1735 /*** ISAXLocator interface ***/
1736 /*** IUnknown methods ***/
1737 static HRESULT WINAPI
isaxlocator_QueryInterface(ISAXLocator
* iface
, REFIID riid
, void **ppvObject
)
1739 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1741 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
1745 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
1746 IsEqualGUID( riid
, &IID_ISAXLocator
))
1752 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1753 return E_NOINTERFACE
;
1756 ISAXLocator_AddRef( iface
);
1761 static ULONG WINAPI
isaxlocator_AddRef(ISAXLocator
* iface
)
1763 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1764 TRACE("%p\n", This
);
1765 return InterlockedIncrement( &This
->ref
);
1768 static ULONG WINAPI
isaxlocator_Release(
1771 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1774 TRACE("%p\n", This
);
1776 ref
= InterlockedDecrement( &This
->ref
);
1779 SysFreeString(This
->publicId
);
1780 SysFreeString(This
->systemId
);
1781 heap_free(This
->nsStack
);
1783 ISAXXMLReader_Release(&This
->saxreader
->ISAXXMLReader_iface
);
1790 /*** ISAXLocator methods ***/
1791 static HRESULT WINAPI
isaxlocator_getColumnNumber(
1795 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1797 *pnColumn
= This
->column
;
1801 static HRESULT WINAPI
isaxlocator_getLineNumber(
1805 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1807 *pnLine
= This
->line
;
1811 static HRESULT WINAPI
isaxlocator_getPublicId(
1813 const WCHAR
** ppwchPublicId
)
1816 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1818 SysFreeString(This
->publicId
);
1820 publicId
= bstr_from_xmlChar(xmlSAX2GetPublicId(This
->pParserCtxt
));
1821 if(SysStringLen(publicId
))
1822 This
->publicId
= (WCHAR
*)&publicId
;
1825 SysFreeString(publicId
);
1826 This
->publicId
= NULL
;
1829 *ppwchPublicId
= This
->publicId
;
1833 static HRESULT WINAPI
isaxlocator_getSystemId(
1835 const WCHAR
** ppwchSystemId
)
1838 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1840 SysFreeString(This
->systemId
);
1842 systemId
= bstr_from_xmlChar(xmlSAX2GetSystemId(This
->pParserCtxt
));
1843 if(SysStringLen(systemId
))
1844 This
->systemId
= (WCHAR
*)&systemId
;
1847 SysFreeString(systemId
);
1848 This
->systemId
= NULL
;
1851 *ppwchSystemId
= This
->systemId
;
1855 static const struct ISAXLocatorVtbl isaxlocator_vtbl
=
1857 isaxlocator_QueryInterface
,
1859 isaxlocator_Release
,
1860 isaxlocator_getColumnNumber
,
1861 isaxlocator_getLineNumber
,
1862 isaxlocator_getPublicId
,
1863 isaxlocator_getSystemId
1866 static HRESULT
SAXLocator_create(saxreader
*reader
, saxlocator
**ppsaxlocator
, BOOL vbInterface
)
1868 saxlocator
*locator
;
1870 locator
= heap_alloc( sizeof (*locator
) );
1872 return E_OUTOFMEMORY
;
1874 locator
->IVBSAXLocator_iface
.lpVtbl
= &ivbsaxlocator_vtbl
;
1875 locator
->ISAXLocator_iface
.lpVtbl
= &isaxlocator_vtbl
;
1877 locator
->vbInterface
= vbInterface
;
1879 locator
->saxreader
= reader
;
1880 ISAXXMLReader_AddRef(&reader
->ISAXXMLReader_iface
);
1882 locator
->pParserCtxt
= NULL
;
1883 locator
->publicId
= NULL
;
1884 locator
->systemId
= NULL
;
1885 locator
->lastCur
= NULL
;
1887 locator
->column
= 0;
1888 locator
->ret
= S_OK
;
1889 locator
->nsStackSize
= 8;
1890 locator
->nsStackLast
= 0;
1891 locator
->nsStack
= heap_alloc(sizeof(int)*locator
->nsStackSize
);
1892 if(!locator
->nsStack
)
1894 ISAXXMLReader_Release(&reader
->ISAXXMLReader_iface
);
1896 return E_OUTOFMEMORY
;
1899 *ppsaxlocator
= locator
;
1901 TRACE("returning %p\n", *ppsaxlocator
);
1906 /*** SAXXMLReader internal functions ***/
1907 static HRESULT
internal_parseBuffer(saxreader
*This
, const char *buffer
, int size
, BOOL vbInterface
)
1909 xmlCharEncoding encoding
= XML_CHAR_ENCODING_NONE
;
1910 xmlChar
*enc_name
= NULL
;
1911 saxlocator
*locator
;
1914 hr
= SAXLocator_create(This
, &locator
, vbInterface
);
1920 const unsigned char *buff
= (unsigned char*)buffer
;
1922 encoding
= xmlDetectCharEncoding((xmlChar
*)buffer
, 4);
1923 enc_name
= (xmlChar
*)xmlGetCharEncodingName(encoding
);
1924 TRACE("detected encoding: %s\n", enc_name
);
1925 /* skip BOM, parser won't switch encodings and so won't skip it on its own */
1926 if ((encoding
== XML_CHAR_ENCODING_UTF8
) &&
1927 buff
[0] == 0xEF && buff
[1] == 0xBB && buff
[2] == 0xBF)
1934 locator
->pParserCtxt
= xmlCreateMemoryParserCtxt(buffer
, size
);
1935 if(!locator
->pParserCtxt
)
1937 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
1941 if (encoding
== XML_CHAR_ENCODING_UTF8
)
1942 locator
->pParserCtxt
->encoding
= xmlStrdup(enc_name
);
1944 xmlFree(locator
->pParserCtxt
->sax
);
1945 locator
->pParserCtxt
->sax
= &locator
->saxreader
->sax
;
1946 locator
->pParserCtxt
->userData
= locator
;
1948 This
->isParsing
= TRUE
;
1949 if(xmlParseDocument(locator
->pParserCtxt
) == -1) hr
= E_FAIL
;
1950 else hr
= locator
->ret
;
1951 This
->isParsing
= FALSE
;
1953 if(locator
->pParserCtxt
)
1955 locator
->pParserCtxt
->sax
= NULL
;
1956 xmlFreeParserCtxt(locator
->pParserCtxt
);
1957 locator
->pParserCtxt
= NULL
;
1960 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
1964 static HRESULT
internal_parseStream(saxreader
*This
, IStream
*stream
, BOOL vbInterface
)
1966 saxlocator
*locator
;
1973 hr
= IStream_Read(stream
, data
, sizeof(data
), &dataRead
);
1974 if(FAILED(hr
)) return hr
;
1976 hr
= SAXLocator_create(This
, &locator
, vbInterface
);
1977 if(FAILED(hr
)) return hr
;
1979 locator
->pParserCtxt
= xmlCreatePushParserCtxt(
1980 &locator
->saxreader
->sax
, locator
,
1981 data
, dataRead
, NULL
);
1982 if(!locator
->pParserCtxt
)
1984 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
1988 This
->isParsing
= TRUE
;
1990 if(dataRead
!= sizeof(data
))
1992 ret
= xmlParseChunk(locator
->pParserCtxt
, data
, 0, 1);
1993 hr
= ret
!= XML_ERR_OK
? E_FAIL
: locator
->ret
;
2000 hr
= IStream_Read(stream
, data
, sizeof(data
), &dataRead
);
2001 if (FAILED(hr
)) break;
2003 ret
= xmlParseChunk(locator
->pParserCtxt
, data
, dataRead
, 0);
2004 hr
= ret
!= XML_ERR_OK
? E_FAIL
: locator
->ret
;
2006 if (hr
!= S_OK
) break;
2008 if (dataRead
!= sizeof(data
))
2010 ret
= xmlParseChunk(locator
->pParserCtxt
, data
, 0, 1);
2011 hr
= ret
!= XML_ERR_OK
? E_FAIL
: locator
->ret
;
2017 This
->isParsing
= FALSE
;
2019 xmlFreeParserCtxt(locator
->pParserCtxt
);
2020 locator
->pParserCtxt
= NULL
;
2021 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
2025 static HRESULT
internal_getEntityResolver(
2027 void *pEntityResolver
,
2030 FIXME("(%p)->(%p) stub\n", This
, pEntityResolver
);
2034 static HRESULT
internal_putEntityResolver(
2036 void *pEntityResolver
,
2039 FIXME("(%p)->(%p) stub\n", This
, pEntityResolver
);
2043 static HRESULT
internal_getContentHandler(
2045 void *pContentHandler
,
2048 TRACE("(%p)->(%p)\n", This
, pContentHandler
);
2049 if(pContentHandler
== NULL
)
2051 if((vbInterface
&& This
->vbcontentHandler
)
2052 || (!vbInterface
&& This
->contentHandler
))
2055 IVBSAXContentHandler_AddRef(This
->vbcontentHandler
);
2057 ISAXContentHandler_AddRef(This
->contentHandler
);
2059 if(vbInterface
) *(IVBSAXContentHandler
**)pContentHandler
=
2060 This
->vbcontentHandler
;
2061 else *(ISAXContentHandler
**)pContentHandler
= This
->contentHandler
;
2066 static HRESULT
internal_putContentHandler(
2068 void *contentHandler
,
2071 TRACE("(%p)->(%p)\n", This
, contentHandler
);
2075 IVBSAXContentHandler_AddRef((IVBSAXContentHandler
*)contentHandler
);
2077 ISAXContentHandler_AddRef((ISAXContentHandler
*)contentHandler
);
2079 if((vbInterface
&& This
->vbcontentHandler
)
2080 || (!vbInterface
&& This
->contentHandler
))
2083 IVBSAXContentHandler_Release(This
->vbcontentHandler
);
2085 ISAXContentHandler_Release(This
->contentHandler
);
2088 This
->vbcontentHandler
= contentHandler
;
2090 This
->contentHandler
= contentHandler
;
2095 static HRESULT
internal_getDTDHandler(
2100 FIXME("(%p)->(%p) stub\n", This
, pDTDHandler
);
2104 static HRESULT
internal_putDTDHandler(
2109 FIXME("(%p)->(%p) stub\n", This
, pDTDHandler
);
2113 static HRESULT
internal_getErrorHandler(
2115 void *pErrorHandler
,
2118 TRACE("(%p)->(%p)\n", This
, pErrorHandler
);
2119 if(pErrorHandler
== NULL
)
2122 if(vbInterface
&& This
->vberrorHandler
)
2123 IVBSAXErrorHandler_AddRef(This
->vberrorHandler
);
2124 else if(!vbInterface
&& This
->errorHandler
)
2125 ISAXErrorHandler_AddRef(This
->errorHandler
);
2128 *(IVBSAXErrorHandler
**)pErrorHandler
= This
->vberrorHandler
;
2130 *(ISAXErrorHandler
**)pErrorHandler
= This
->errorHandler
;
2136 static HRESULT
internal_putErrorHandler(
2141 TRACE("(%p)->(%p)\n", This
, errorHandler
);
2145 IVBSAXErrorHandler_AddRef((IVBSAXErrorHandler
*)errorHandler
);
2147 ISAXErrorHandler_AddRef((ISAXErrorHandler
*)errorHandler
);
2150 if(vbInterface
&& This
->vberrorHandler
)
2151 IVBSAXErrorHandler_Release(This
->vberrorHandler
);
2152 else if(!vbInterface
&& This
->errorHandler
)
2153 ISAXErrorHandler_Release(This
->errorHandler
);
2156 This
->vberrorHandler
= errorHandler
;
2158 This
->errorHandler
= errorHandler
;
2164 static HRESULT
internal_parse(
2171 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&varInput
));
2173 /* Dispose of the BSTRs in the pool from a prior run, if any. */
2174 free_bstr_pool(&This
->pool
);
2176 switch(V_VT(&varInput
))
2179 hr
= internal_parseBuffer(This
, (const char*)V_BSTR(&varInput
),
2180 SysStringByteLen(V_BSTR(&varInput
)), vbInterface
);
2182 case VT_ARRAY
|VT_UI1
: {
2184 LONG lBound
, uBound
;
2187 hr
= SafeArrayGetLBound(V_ARRAY(&varInput
), 1, &lBound
);
2188 if(hr
!= S_OK
) break;
2189 hr
= SafeArrayGetUBound(V_ARRAY(&varInput
), 1, &uBound
);
2190 if(hr
!= S_OK
) break;
2191 dataRead
= (uBound
-lBound
)*SafeArrayGetElemsize(V_ARRAY(&varInput
));
2192 hr
= SafeArrayAccessData(V_ARRAY(&varInput
), &pSAData
);
2193 if(hr
!= S_OK
) break;
2194 hr
= internal_parseBuffer(This
, pSAData
, dataRead
, vbInterface
);
2195 SafeArrayUnaccessData(V_ARRAY(&varInput
));
2200 IPersistStream
*persistStream
;
2201 IStream
*stream
= NULL
;
2202 IXMLDOMDocument
*xmlDoc
;
2204 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
2205 &IID_IXMLDOMDocument
, (void**)&xmlDoc
) == S_OK
)
2209 IXMLDOMDocument_get_xml(xmlDoc
, &bstrData
);
2210 hr
= internal_parseBuffer(This
, (const char*)bstrData
,
2211 SysStringByteLen(bstrData
), vbInterface
);
2212 IXMLDOMDocument_Release(xmlDoc
);
2213 SysFreeString(bstrData
);
2217 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
2218 &IID_IPersistStream
, (void**)&persistStream
) == S_OK
)
2220 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
2223 IPersistStream_Release(persistStream
);
2227 hr
= IPersistStream_Save(persistStream
, stream
, TRUE
);
2228 IPersistStream_Release(persistStream
);
2231 IStream_Release(stream
);
2235 if(stream
|| IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
2236 &IID_IStream
, (void**)&stream
) == S_OK
)
2238 hr
= internal_parseStream(This
, stream
, vbInterface
);
2239 IStream_Release(stream
);
2244 WARN("vt %d not implemented\n", V_VT(&varInput
));
2251 static HRESULT
internal_vbonDataAvailable(void *obj
, char *ptr
, DWORD len
)
2253 saxreader
*This
= obj
;
2255 return internal_parseBuffer(This
, ptr
, len
, TRUE
);
2258 static HRESULT
internal_onDataAvailable(void *obj
, char *ptr
, DWORD len
)
2260 saxreader
*This
= obj
;
2262 return internal_parseBuffer(This
, ptr
, len
, FALSE
);
2265 static HRESULT
internal_parseURL(
2273 TRACE("(%p)->(%s)\n", This
, debugstr_w(url
));
2275 if(vbInterface
) hr
= bind_url(url
, internal_vbonDataAvailable
, This
, &bsc
);
2276 else hr
= bind_url(url
, internal_onDataAvailable
, This
, &bsc
);
2286 static HRESULT
internal_putProperty(
2292 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(prop
), debugstr_variant(&value
));
2294 if(!memcmp(prop
, PropertyDeclHandlerW
, sizeof(PropertyDeclHandlerW
)))
2296 if(This
->isParsing
) return E_FAIL
;
2298 switch (V_VT(&value
))
2303 if (This
->vbdeclHandler
)
2305 IVBSAXDeclHandler_Release(This
->vbdeclHandler
);
2306 This
->vbdeclHandler
= NULL
;
2310 if (This
->declHandler
)
2312 ISAXDeclHandler_Release(This
->declHandler
);
2313 This
->declHandler
= NULL
;
2317 if (V_UNKNOWN(&value
)) IUnknown_AddRef(V_UNKNOWN(&value
));
2319 if ((vbInterface
&& This
->vbdeclHandler
) ||
2320 (!vbInterface
&& This
->declHandler
))
2323 IVBSAXDeclHandler_Release(This
->vbdeclHandler
);
2325 ISAXDeclHandler_Release(This
->declHandler
);
2329 This
->vbdeclHandler
= (IVBSAXDeclHandler
*)V_UNKNOWN(&value
);
2331 This
->declHandler
= (ISAXDeclHandler
*)V_UNKNOWN(&value
);
2334 return E_INVALIDARG
;
2340 if(!memcmp(prop
, PropertyLexicalHandlerW
, sizeof(PropertyLexicalHandlerW
)))
2342 if(This
->isParsing
) return E_FAIL
;
2344 switch (V_VT(&value
))
2349 if (This
->vblexicalHandler
)
2351 IVBSAXLexicalHandler_Release(This
->vblexicalHandler
);
2352 This
->vblexicalHandler
= NULL
;
2356 if (This
->lexicalHandler
)
2358 ISAXLexicalHandler_Release(This
->lexicalHandler
);
2359 This
->lexicalHandler
= NULL
;
2363 if (V_UNKNOWN(&value
)) IUnknown_AddRef(V_UNKNOWN(&value
));
2365 if ((vbInterface
&& This
->vblexicalHandler
) ||
2366 (!vbInterface
&& This
->lexicalHandler
))
2369 IVBSAXLexicalHandler_Release(This
->vblexicalHandler
);
2371 ISAXLexicalHandler_Release(This
->lexicalHandler
);
2375 This
->vblexicalHandler
= (IVBSAXLexicalHandler
*)V_UNKNOWN(&value
);
2377 This
->lexicalHandler
= (ISAXLexicalHandler
*)V_UNKNOWN(&value
);
2380 return E_INVALIDARG
;
2386 if(!memcmp(prop
, PropertyMaxXMLSizeW
, sizeof(PropertyMaxXMLSizeW
)))
2388 if (V_VT(&value
) == VT_I4
&& V_I4(&value
) == 0) return S_OK
;
2389 FIXME("(%p)->(%s): max-xml-size unsupported\n", This
, debugstr_variant(&value
));
2393 if(!memcmp(prop
, PropertyMaxElementDepthW
, sizeof(PropertyMaxElementDepthW
)))
2395 if (V_VT(&value
) == VT_I4
&& V_I4(&value
) == 0) return S_OK
;
2396 FIXME("(%p)->(%s): max-element-depth unsupported\n", This
, debugstr_variant(&value
));
2400 FIXME("(%p)->(%s:%s): unsupported property\n", This
, debugstr_w(prop
), debugstr_variant(&value
));
2402 if(!memcmp(prop
, PropertyCharsetW
, sizeof(PropertyCharsetW
)))
2405 if(!memcmp(prop
, PropertyDomNodeW
, sizeof(PropertyDomNodeW
)))
2408 if(!memcmp(prop
, PropertyInputSourceW
, sizeof(PropertyInputSourceW
)))
2411 if(!memcmp(prop
, PropertySchemaDeclHandlerW
, sizeof(PropertySchemaDeclHandlerW
)))
2414 if(!memcmp(prop
, PropertyXMLDeclEncodingW
, sizeof(PropertyXMLDeclEncodingW
)))
2417 if(!memcmp(prop
, PropertyXMLDeclStandaloneW
, sizeof(PropertyXMLDeclStandaloneW
)))
2420 if(!memcmp(prop
, PropertyXMLDeclVersionW
, sizeof(PropertyXMLDeclVersionW
)))
2423 return E_INVALIDARG
;
2426 static HRESULT
internal_getProperty(const saxreader
* This
, const WCHAR
*prop
, VARIANT
*value
, BOOL vb
)
2428 TRACE("(%p)->(%s)\n", This
, debugstr_w(prop
));
2430 if (!value
) return E_POINTER
;
2432 if (!memcmp(PropertyLexicalHandlerW
, prop
, sizeof(PropertyLexicalHandlerW
)))
2434 V_VT(value
) = VT_UNKNOWN
;
2435 V_UNKNOWN(value
) = vb
? (IUnknown
*)This
->vblexicalHandler
: (IUnknown
*)This
->lexicalHandler
;
2436 if (V_UNKNOWN(value
)) IUnknown_AddRef(V_UNKNOWN(value
));
2440 if (!memcmp(PropertyDeclHandlerW
, prop
, sizeof(PropertyDeclHandlerW
)))
2442 V_VT(value
) = VT_UNKNOWN
;
2443 V_UNKNOWN(value
) = vb
? (IUnknown
*)This
->vbdeclHandler
: (IUnknown
*)This
->declHandler
;
2444 if (V_UNKNOWN(value
)) IUnknown_AddRef(V_UNKNOWN(value
));
2448 FIXME("(%p)->(%s) unsupported property\n", This
, debugstr_w(prop
));
2453 /*** IVBSAXXMLReader interface ***/
2454 /*** IUnknown methods ***/
2455 static HRESULT WINAPI
saxxmlreader_QueryInterface(IVBSAXXMLReader
* iface
, REFIID riid
, void **ppvObject
)
2457 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2459 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
2463 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
2464 IsEqualGUID( riid
, &IID_IDispatch
) ||
2465 IsEqualGUID( riid
, &IID_IVBSAXXMLReader
))
2469 else if( IsEqualGUID( riid
, &IID_ISAXXMLReader
))
2471 *ppvObject
= &This
->ISAXXMLReader_iface
;
2475 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
2476 return E_NOINTERFACE
;
2479 IVBSAXXMLReader_AddRef( iface
);
2484 static ULONG WINAPI
saxxmlreader_AddRef(IVBSAXXMLReader
* iface
)
2486 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2487 TRACE("%p\n", This
);
2488 return InterlockedIncrement( &This
->ref
);
2491 static ULONG WINAPI
saxxmlreader_Release(
2492 IVBSAXXMLReader
* iface
)
2494 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2497 TRACE("%p\n", This
);
2499 ref
= InterlockedDecrement( &This
->ref
);
2502 if(This
->contentHandler
)
2503 ISAXContentHandler_Release(This
->contentHandler
);
2505 if(This
->vbcontentHandler
)
2506 IVBSAXContentHandler_Release(This
->vbcontentHandler
);
2508 if(This
->errorHandler
)
2509 ISAXErrorHandler_Release(This
->errorHandler
);
2511 if(This
->vberrorHandler
)
2512 IVBSAXErrorHandler_Release(This
->vberrorHandler
);
2514 if(This
->lexicalHandler
)
2515 ISAXLexicalHandler_Release(This
->lexicalHandler
);
2517 if(This
->vblexicalHandler
)
2518 IVBSAXLexicalHandler_Release(This
->vblexicalHandler
);
2520 if(This
->declHandler
)
2521 ISAXDeclHandler_Release(This
->declHandler
);
2523 if(This
->vbdeclHandler
)
2524 IVBSAXDeclHandler_Release(This
->vbdeclHandler
);
2526 free_bstr_pool(&This
->pool
);
2534 static HRESULT WINAPI
saxxmlreader_GetTypeInfoCount( IVBSAXXMLReader
*iface
, UINT
* pctinfo
)
2536 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2538 TRACE("(%p)->(%p)\n", This
, pctinfo
);
2545 static HRESULT WINAPI
saxxmlreader_GetTypeInfo(
2546 IVBSAXXMLReader
*iface
,
2547 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2549 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2552 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
2554 hr
= get_typeinfo(IVBSAXXMLReader_tid
, ppTInfo
);
2559 static HRESULT WINAPI
saxxmlreader_GetIDsOfNames(
2560 IVBSAXXMLReader
*iface
,
2562 LPOLESTR
* rgszNames
,
2567 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2568 ITypeInfo
*typeinfo
;
2571 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
2574 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
2575 return E_INVALIDARG
;
2577 hr
= get_typeinfo(IVBSAXXMLReader_tid
, &typeinfo
);
2580 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
2581 ITypeInfo_Release(typeinfo
);
2587 static HRESULT WINAPI
saxxmlreader_Invoke(
2588 IVBSAXXMLReader
*iface
,
2589 DISPID dispIdMember
,
2593 DISPPARAMS
* pDispParams
,
2594 VARIANT
* pVarResult
,
2595 EXCEPINFO
* pExcepInfo
,
2598 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2599 ITypeInfo
*typeinfo
;
2602 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
2603 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2605 hr
= get_typeinfo(IVBSAXXMLReader_tid
, &typeinfo
);
2608 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IVBSAXXMLReader_iface
, dispIdMember
, wFlags
,
2609 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2610 ITypeInfo_Release(typeinfo
);
2616 /*** IVBSAXXMLReader methods ***/
2617 static HRESULT WINAPI
saxxmlreader_getFeature(
2618 IVBSAXXMLReader
* iface
,
2619 const WCHAR
*pFeature
,
2620 VARIANT_BOOL
*pValue
)
2622 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2624 FIXME("(%p)->(%s %p) stub\n", This
, debugstr_w(pFeature
), pValue
);
2628 static HRESULT WINAPI
saxxmlreader_putFeature(
2629 IVBSAXXMLReader
* iface
,
2630 const WCHAR
*feature
,
2633 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2635 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(feature
), value
);
2637 if (!strcmpW(FeatureExternalGeneralEntitiesW
, feature
) && value
== VARIANT_FALSE
)
2638 return set_feature_value(This
, ExternalGeneralEntities
, value
);
2640 if (!strcmpW(FeatureExternalParameterEntitiesW
, feature
) && value
== VARIANT_FALSE
)
2641 return set_feature_value(This
, ExternalParameterEntities
, value
);
2643 if (!strcmpW(FeatureLexicalHandlerParEntitiesW
, feature
))
2645 FIXME("(%p)->(%s %x) stub\n", This
, debugstr_w(feature
), value
);
2646 return set_feature_value(This
, LexicalHandlerParEntities
, value
);
2649 if (!strcmpW(FeatureProhibitDTDW
, feature
))
2651 FIXME("(%p)->(%s %x) stub\n", This
, debugstr_w(feature
), value
);
2652 return set_feature_value(This
, ProhibitDTD
, value
);
2655 FIXME("(%p)->(%s %x) stub\n", This
, debugstr_w(feature
), value
);
2659 static HRESULT WINAPI
saxxmlreader_getProperty(
2660 IVBSAXXMLReader
* iface
,
2664 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2665 return internal_getProperty(This
, prop
, value
, TRUE
);
2668 static HRESULT WINAPI
saxxmlreader_putProperty(
2669 IVBSAXXMLReader
* iface
,
2673 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2674 return internal_putProperty(This
, pProp
, value
, TRUE
);
2677 static HRESULT WINAPI
saxxmlreader_get_entityResolver(
2678 IVBSAXXMLReader
* iface
,
2679 IVBSAXEntityResolver
**pEntityResolver
)
2681 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2682 return internal_getEntityResolver(This
, pEntityResolver
, TRUE
);
2685 static HRESULT WINAPI
saxxmlreader_put_entityResolver(
2686 IVBSAXXMLReader
* iface
,
2687 IVBSAXEntityResolver
*pEntityResolver
)
2689 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2690 return internal_putEntityResolver(This
, pEntityResolver
, TRUE
);
2693 static HRESULT WINAPI
saxxmlreader_get_contentHandler(
2694 IVBSAXXMLReader
* iface
,
2695 IVBSAXContentHandler
**ppContentHandler
)
2697 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2698 return internal_getContentHandler(This
, ppContentHandler
, TRUE
);
2701 static HRESULT WINAPI
saxxmlreader_put_contentHandler(
2702 IVBSAXXMLReader
* iface
,
2703 IVBSAXContentHandler
*contentHandler
)
2705 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2706 return internal_putContentHandler(This
, contentHandler
, TRUE
);
2709 static HRESULT WINAPI
saxxmlreader_get_dtdHandler(
2710 IVBSAXXMLReader
* iface
,
2711 IVBSAXDTDHandler
**pDTDHandler
)
2713 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2714 return internal_getDTDHandler(This
, pDTDHandler
, TRUE
);
2717 static HRESULT WINAPI
saxxmlreader_put_dtdHandler(
2718 IVBSAXXMLReader
* iface
,
2719 IVBSAXDTDHandler
*pDTDHandler
)
2721 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2722 return internal_putDTDHandler(This
, pDTDHandler
, TRUE
);
2725 static HRESULT WINAPI
saxxmlreader_get_errorHandler(
2726 IVBSAXXMLReader
* iface
,
2727 IVBSAXErrorHandler
**pErrorHandler
)
2729 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2730 return internal_getErrorHandler(This
, pErrorHandler
, TRUE
);
2733 static HRESULT WINAPI
saxxmlreader_put_errorHandler(
2734 IVBSAXXMLReader
* iface
,
2735 IVBSAXErrorHandler
*errorHandler
)
2737 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2738 return internal_putErrorHandler(This
, errorHandler
, TRUE
);
2741 static HRESULT WINAPI
saxxmlreader_get_baseURL(
2742 IVBSAXXMLReader
* iface
,
2743 const WCHAR
**pBaseUrl
)
2745 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2747 FIXME("(%p)->(%p) stub\n", This
, pBaseUrl
);
2751 static HRESULT WINAPI
saxxmlreader_put_baseURL(
2752 IVBSAXXMLReader
* iface
,
2753 const WCHAR
*pBaseUrl
)
2755 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2757 FIXME("(%p)->(%s) stub\n", This
, debugstr_w(pBaseUrl
));
2761 static HRESULT WINAPI
saxxmlreader_get_secureBaseURL(
2762 IVBSAXXMLReader
* iface
,
2763 const WCHAR
**pSecureBaseUrl
)
2765 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2767 FIXME("(%p)->(%p) stub\n", This
, pSecureBaseUrl
);
2772 static HRESULT WINAPI
saxxmlreader_put_secureBaseURL(
2773 IVBSAXXMLReader
* iface
,
2774 const WCHAR
*secureBaseUrl
)
2776 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2778 FIXME("(%p)->(%s) stub\n", This
, debugstr_w(secureBaseUrl
));
2782 static HRESULT WINAPI
saxxmlreader_parse(
2783 IVBSAXXMLReader
* iface
,
2786 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2787 return internal_parse(This
, varInput
, TRUE
);
2790 static HRESULT WINAPI
saxxmlreader_parseURL(
2791 IVBSAXXMLReader
* iface
,
2794 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2795 return internal_parseURL(This
, url
, TRUE
);
2798 static const struct IVBSAXXMLReaderVtbl saxreader_vtbl
=
2800 saxxmlreader_QueryInterface
,
2801 saxxmlreader_AddRef
,
2802 saxxmlreader_Release
,
2803 saxxmlreader_GetTypeInfoCount
,
2804 saxxmlreader_GetTypeInfo
,
2805 saxxmlreader_GetIDsOfNames
,
2806 saxxmlreader_Invoke
,
2807 saxxmlreader_getFeature
,
2808 saxxmlreader_putFeature
,
2809 saxxmlreader_getProperty
,
2810 saxxmlreader_putProperty
,
2811 saxxmlreader_get_entityResolver
,
2812 saxxmlreader_put_entityResolver
,
2813 saxxmlreader_get_contentHandler
,
2814 saxxmlreader_put_contentHandler
,
2815 saxxmlreader_get_dtdHandler
,
2816 saxxmlreader_put_dtdHandler
,
2817 saxxmlreader_get_errorHandler
,
2818 saxxmlreader_put_errorHandler
,
2819 saxxmlreader_get_baseURL
,
2820 saxxmlreader_put_baseURL
,
2821 saxxmlreader_get_secureBaseURL
,
2822 saxxmlreader_put_secureBaseURL
,
2824 saxxmlreader_parseURL
2827 /*** ISAXXMLReader interface ***/
2828 /*** IUnknown methods ***/
2829 static HRESULT WINAPI
isaxxmlreader_QueryInterface(ISAXXMLReader
* iface
, REFIID riid
, void **ppvObject
)
2831 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2832 return saxxmlreader_QueryInterface(&This
->IVBSAXXMLReader_iface
, riid
, ppvObject
);
2835 static ULONG WINAPI
isaxxmlreader_AddRef(ISAXXMLReader
* iface
)
2837 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2838 return saxxmlreader_AddRef(&This
->IVBSAXXMLReader_iface
);
2841 static ULONG WINAPI
isaxxmlreader_Release(ISAXXMLReader
* iface
)
2843 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2844 return saxxmlreader_Release(&This
->IVBSAXXMLReader_iface
);
2847 /*** ISAXXMLReader methods ***/
2848 static HRESULT WINAPI
isaxxmlreader_getFeature(
2849 ISAXXMLReader
* iface
,
2850 const WCHAR
*pFeature
,
2851 VARIANT_BOOL
*pValue
)
2853 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2854 return IVBSAXXMLReader_getFeature(&This
->IVBSAXXMLReader_iface
, pFeature
, pValue
);
2857 static HRESULT WINAPI
isaxxmlreader_putFeature(
2858 ISAXXMLReader
* iface
,
2859 const WCHAR
*pFeature
,
2860 VARIANT_BOOL vfValue
)
2862 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2863 return IVBSAXXMLReader_putFeature(&This
->IVBSAXXMLReader_iface
, pFeature
, vfValue
);
2866 static HRESULT WINAPI
isaxxmlreader_getProperty(
2867 ISAXXMLReader
* iface
,
2871 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2872 return internal_getProperty(This
, prop
, value
, FALSE
);
2875 static HRESULT WINAPI
isaxxmlreader_putProperty(
2876 ISAXXMLReader
* iface
,
2880 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2881 return internal_putProperty(This
, pProp
, value
, FALSE
);
2884 static HRESULT WINAPI
isaxxmlreader_getEntityResolver(
2885 ISAXXMLReader
* iface
,
2886 ISAXEntityResolver
**ppEntityResolver
)
2888 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2889 return internal_getEntityResolver(This
, ppEntityResolver
, FALSE
);
2892 static HRESULT WINAPI
isaxxmlreader_putEntityResolver(
2893 ISAXXMLReader
* iface
,
2894 ISAXEntityResolver
*pEntityResolver
)
2896 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2897 return internal_putEntityResolver(This
, pEntityResolver
, FALSE
);
2900 static HRESULT WINAPI
isaxxmlreader_getContentHandler(
2901 ISAXXMLReader
* iface
,
2902 ISAXContentHandler
**pContentHandler
)
2904 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2905 return internal_getContentHandler(This
, pContentHandler
, FALSE
);
2908 static HRESULT WINAPI
isaxxmlreader_putContentHandler(
2909 ISAXXMLReader
* iface
,
2910 ISAXContentHandler
*contentHandler
)
2912 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2913 return internal_putContentHandler(This
, contentHandler
, FALSE
);
2916 static HRESULT WINAPI
isaxxmlreader_getDTDHandler(
2917 ISAXXMLReader
* iface
,
2918 ISAXDTDHandler
**pDTDHandler
)
2920 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2921 return internal_getDTDHandler(This
, pDTDHandler
, FALSE
);
2924 static HRESULT WINAPI
isaxxmlreader_putDTDHandler(
2925 ISAXXMLReader
* iface
,
2926 ISAXDTDHandler
*pDTDHandler
)
2928 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2929 return internal_putDTDHandler(This
, pDTDHandler
, FALSE
);
2932 static HRESULT WINAPI
isaxxmlreader_getErrorHandler(
2933 ISAXXMLReader
* iface
,
2934 ISAXErrorHandler
**pErrorHandler
)
2936 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2937 return internal_getErrorHandler(This
, pErrorHandler
, FALSE
);
2940 static HRESULT WINAPI
isaxxmlreader_putErrorHandler(
2941 ISAXXMLReader
* iface
,
2942 ISAXErrorHandler
*errorHandler
)
2944 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2945 return internal_putErrorHandler(This
, errorHandler
, FALSE
);
2948 static HRESULT WINAPI
isaxxmlreader_getBaseURL(
2949 ISAXXMLReader
* iface
,
2950 const WCHAR
**pBaseUrl
)
2952 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2953 return IVBSAXXMLReader_get_baseURL(&This
->IVBSAXXMLReader_iface
, pBaseUrl
);
2956 static HRESULT WINAPI
isaxxmlreader_putBaseURL(
2957 ISAXXMLReader
* iface
,
2958 const WCHAR
*pBaseUrl
)
2960 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2961 return IVBSAXXMLReader_put_baseURL(&This
->IVBSAXXMLReader_iface
, pBaseUrl
);
2964 static HRESULT WINAPI
isaxxmlreader_getSecureBaseURL(
2965 ISAXXMLReader
* iface
,
2966 const WCHAR
**pSecureBaseUrl
)
2968 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2969 return IVBSAXXMLReader_get_secureBaseURL(&This
->IVBSAXXMLReader_iface
, pSecureBaseUrl
);
2972 static HRESULT WINAPI
isaxxmlreader_putSecureBaseURL(
2973 ISAXXMLReader
* iface
,
2974 const WCHAR
*secureBaseUrl
)
2976 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2977 return IVBSAXXMLReader_put_secureBaseURL(&This
->IVBSAXXMLReader_iface
, secureBaseUrl
);
2980 static HRESULT WINAPI
isaxxmlreader_parse(
2981 ISAXXMLReader
* iface
,
2984 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2985 return internal_parse(This
, varInput
, FALSE
);
2988 static HRESULT WINAPI
isaxxmlreader_parseURL(
2989 ISAXXMLReader
* iface
,
2992 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2993 return internal_parseURL(This
, url
, FALSE
);
2996 static const struct ISAXXMLReaderVtbl isaxreader_vtbl
=
2998 isaxxmlreader_QueryInterface
,
2999 isaxxmlreader_AddRef
,
3000 isaxxmlreader_Release
,
3001 isaxxmlreader_getFeature
,
3002 isaxxmlreader_putFeature
,
3003 isaxxmlreader_getProperty
,
3004 isaxxmlreader_putProperty
,
3005 isaxxmlreader_getEntityResolver
,
3006 isaxxmlreader_putEntityResolver
,
3007 isaxxmlreader_getContentHandler
,
3008 isaxxmlreader_putContentHandler
,
3009 isaxxmlreader_getDTDHandler
,
3010 isaxxmlreader_putDTDHandler
,
3011 isaxxmlreader_getErrorHandler
,
3012 isaxxmlreader_putErrorHandler
,
3013 isaxxmlreader_getBaseURL
,
3014 isaxxmlreader_putBaseURL
,
3015 isaxxmlreader_getSecureBaseURL
,
3016 isaxxmlreader_putSecureBaseURL
,
3017 isaxxmlreader_parse
,
3018 isaxxmlreader_parseURL
3021 HRESULT
SAXXMLReader_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
3025 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
3027 reader
= heap_alloc( sizeof (*reader
) );
3029 return E_OUTOFMEMORY
;
3031 reader
->IVBSAXXMLReader_iface
.lpVtbl
= &saxreader_vtbl
;
3032 reader
->ISAXXMLReader_iface
.lpVtbl
= &isaxreader_vtbl
;
3034 reader
->contentHandler
= NULL
;
3035 reader
->vbcontentHandler
= NULL
;
3036 reader
->errorHandler
= NULL
;
3037 reader
->vberrorHandler
= NULL
;
3038 reader
->lexicalHandler
= NULL
;
3039 reader
->vblexicalHandler
= NULL
;
3040 reader
->declHandler
= NULL
;
3041 reader
->vbdeclHandler
= NULL
;
3042 reader
->isParsing
= FALSE
;
3043 reader
->pool
.pool
= NULL
;
3044 reader
->pool
.index
= 0;
3045 reader
->pool
.len
= 0;
3046 reader
->features
= 0;
3048 memset(&reader
->sax
, 0, sizeof(xmlSAXHandler
));
3049 reader
->sax
.initialized
= XML_SAX2_MAGIC
;
3050 reader
->sax
.startDocument
= libxmlStartDocument
;
3051 reader
->sax
.endDocument
= libxmlEndDocument
;
3052 reader
->sax
.startElementNs
= libxmlStartElementNS
;
3053 reader
->sax
.endElementNs
= libxmlEndElementNS
;
3054 reader
->sax
.characters
= libxmlCharacters
;
3055 reader
->sax
.setDocumentLocator
= libxmlSetDocumentLocator
;
3056 reader
->sax
.comment
= libxmlComment
;
3057 reader
->sax
.error
= libxmlFatalError
;
3058 reader
->sax
.fatalError
= libxmlFatalError
;
3059 reader
->sax
.cdataBlock
= libxmlCDataBlock
;
3061 *ppObj
= &reader
->IVBSAXXMLReader_iface
;
3063 TRACE("returning iface %p\n", *ppObj
);
3070 HRESULT
SAXXMLReader_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
3072 MESSAGE("This program tried to use a SAX XML Reader object, but\n"
3073 "libxml2 support was not present at compile time.\n");