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
);
55 ExhaustiveErrors
= 1 << 1,
56 ExternalGeneralEntities
= 1 << 2,
57 ExternalParameterEntities
= 1 << 3,
58 ForcedResync
= 1 << 4,
59 NamespacePrefixes
= 1 << 5,
61 ParameterEntities
= 1 << 7,
62 PreserveSystemIndentifiers
= 1 << 8,
64 SchemaValidation
= 1 << 10,
65 ServerHttpRequest
= 1 << 11,
66 SuppressValidationfatalError
= 1 << 12,
67 UseInlineSchema
= 1 << 13,
68 UseSchemaLocation
= 1 << 14,
69 LexicalHandlerParEntities
= 1 << 15
91 ns
*ns
; /* namespaces defined in this particular element */
98 IVBSAXXMLReader IVBSAXXMLReader_iface
;
99 ISAXXMLReader ISAXXMLReader_iface
;
101 ISAXContentHandler
*contentHandler
;
102 IVBSAXContentHandler
*vbcontentHandler
;
103 ISAXErrorHandler
*errorHandler
;
104 IVBSAXErrorHandler
*vberrorHandler
;
105 ISAXLexicalHandler
*lexicalHandler
;
106 IVBSAXLexicalHandler
*vblexicalHandler
;
107 ISAXDeclHandler
*declHandler
;
108 IVBSAXDeclHandler
*vbdeclHandler
;
111 struct bstrpool pool
;
112 saxreader_features features
;
113 MSXML_VERSION version
;
118 IVBSAXLocator IVBSAXLocator_iface
;
119 ISAXLocator ISAXLocator_iface
;
120 IVBSAXAttributes IVBSAXAttributes_iface
;
121 ISAXAttributes ISAXAttributes_iface
;
123 saxreader
*saxreader
;
125 xmlParserCtxtPtr pParserCtxt
;
131 struct list elements
;
145 static inline saxreader
*impl_from_IVBSAXXMLReader( IVBSAXXMLReader
*iface
)
147 return CONTAINING_RECORD(iface
, saxreader
, IVBSAXXMLReader_iface
);
150 static inline saxreader
*impl_from_ISAXXMLReader( ISAXXMLReader
*iface
)
152 return CONTAINING_RECORD(iface
, saxreader
, ISAXXMLReader_iface
);
155 static inline saxlocator
*impl_from_IVBSAXLocator( IVBSAXLocator
*iface
)
157 return CONTAINING_RECORD(iface
, saxlocator
, IVBSAXLocator_iface
);
160 static inline saxlocator
*impl_from_ISAXLocator( ISAXLocator
*iface
)
162 return CONTAINING_RECORD(iface
, saxlocator
, ISAXLocator_iface
);
165 static inline saxlocator
*impl_from_IVBSAXAttributes( IVBSAXAttributes
*iface
)
167 return CONTAINING_RECORD(iface
, saxlocator
, IVBSAXAttributes_iface
);
170 static inline saxlocator
*impl_from_ISAXAttributes( ISAXAttributes
*iface
)
172 return CONTAINING_RECORD(iface
, saxlocator
, ISAXAttributes_iface
);
176 static const WCHAR PropertyCharsetW
[] = {
177 'c','h','a','r','s','e','t',0
179 static const WCHAR PropertyDeclHandlerW
[] = {
180 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
181 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
182 'd','e','c','l','a','r','a','t','i','o','n',
183 '-','h','a','n','d','l','e','r',0
185 static const WCHAR PropertyDomNodeW
[] = {
186 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
187 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
188 'd','o','m','-','n','o','d','e',0
190 static const WCHAR PropertyInputSourceW
[] = {
191 'i','n','p','u','t','-','s','o','u','r','c','e',0
193 static const WCHAR PropertyLexicalHandlerW
[] = {
194 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
195 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
196 'l','e','x','i','c','a','l','-','h','a','n','d','l','e','r',0
198 static const WCHAR PropertyMaxElementDepthW
[] = {
199 'm','a','x','-','e','l','e','m','e','n','t','-','d','e','p','t','h',0
201 static const WCHAR PropertyMaxXMLSizeW
[] = {
202 'm','a','x','-','x','m','l','-','s','i','z','e',0
204 static const WCHAR PropertySchemaDeclHandlerW
[] = {
205 's','c','h','e','m','a','-','d','e','c','l','a','r','a','t','i','o','n','-',
206 'h','a','n','d','l','e','r',0
208 static const WCHAR PropertyXMLDeclEncodingW
[] = {
209 'x','m','l','d','e','c','l','-','e','n','c','o','d','i','n','g',0
211 static const WCHAR PropertyXMLDeclStandaloneW
[] = {
212 'x','m','l','d','e','c','l','-','s','t','a','n','d','a','l','o','n','e',0
214 static const WCHAR PropertyXMLDeclVersionW
[] = {
215 'x','m','l','d','e','c','l','-','v','e','r','s','i','o','n',0
219 static const WCHAR FeatureExternalGeneralEntitiesW
[] = {
220 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/',
221 'f','e','a','t','u','r','e','s','/','e','x','t','e','r','n','a','l','-','g','e','n','e','r','a','l',
222 '-','e','n','t','i','t','i','e','s',0
225 static const WCHAR FeatureExternalParameterEntitiesW
[] = {
226 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/','f','e','a','t','u','r','e','s',
227 '/','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
230 static const WCHAR FeatureLexicalHandlerParEntitiesW
[] = {
231 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/','f','e','a','t','u','r','e','s',
232 '/','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
235 static const WCHAR FeatureProhibitDTDW
[] = {
236 'p','r','o','h','i','b','i','t','-','d','t','d',0
239 static const WCHAR FeatureNamespacesW
[] = {
240 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/','f','e','a','t','u','r','e','s',
241 '/','n','a','m','e','s','p','a','c','e','s',0
244 static inline HRESULT
set_feature_value(saxreader
*reader
, saxreader_features feature
, VARIANT_BOOL value
)
246 if (value
== VARIANT_TRUE
)
247 reader
->features
|= feature
;
249 reader
->features
&= ~feature
;
254 static inline HRESULT
get_feature_value(const saxreader
*reader
, saxreader_features feature
, VARIANT_BOOL
*value
)
256 *value
= reader
->features
& feature
? VARIANT_TRUE
: VARIANT_FALSE
;
260 static inline BOOL
has_content_handler(const saxlocator
*locator
)
262 return (locator
->vbInterface
&& locator
->saxreader
->vbcontentHandler
) ||
263 (!locator
->vbInterface
&& locator
->saxreader
->contentHandler
);
266 static inline BOOL
has_error_handler(const saxlocator
*locator
)
268 return (locator
->vbInterface
&& locator
->saxreader
->vberrorHandler
) ||
269 (!locator
->vbInterface
&& locator
->saxreader
->errorHandler
);
272 static BSTR
build_qname(BSTR prefix
, BSTR local
)
274 if (prefix
&& *prefix
)
276 BSTR qname
= SysAllocStringLen(NULL
, SysStringLen(prefix
) + SysStringLen(local
) + 1);
280 strcpyW(ptr
, prefix
);
281 ptr
+= SysStringLen(prefix
);
287 return SysAllocString(local
);
290 static element_entry
* alloc_element_entry(const xmlChar
*local
, const xmlChar
*prefix
, int nb_ns
,
291 const xmlChar
**namespaces
)
296 ret
= heap_alloc(sizeof(*ret
));
297 if (!ret
) return ret
;
299 ret
->local
= bstr_from_xmlChar(local
);
300 ret
->prefix
= bstr_from_xmlChar(prefix
);
301 ret
->qname
= build_qname(ret
->prefix
, ret
->local
);
302 ret
->ns
= nb_ns
? heap_alloc(nb_ns
*sizeof(ns
)) : NULL
;
303 ret
->ns_count
= nb_ns
;
305 for (i
=0; i
< nb_ns
; i
++)
307 ret
->ns
[i
].prefix
= bstr_from_xmlChar(namespaces
[2*i
]);
308 ret
->ns
[i
].uri
= bstr_from_xmlChar(namespaces
[2*i
+1]);
314 static void free_element_entry(element_entry
*element
)
318 for (i
=0; i
<element
->ns_count
;i
++)
320 SysFreeString(element
->ns
[i
].prefix
);
321 SysFreeString(element
->ns
[i
].uri
);
324 SysFreeString(element
->prefix
);
325 SysFreeString(element
->local
);
327 heap_free(element
->ns
);
331 static void push_element_ns(saxlocator
*locator
, element_entry
*element
)
333 list_add_head(&locator
->elements
, &element
->entry
);
336 static element_entry
* pop_element_ns(saxlocator
*locator
)
338 element_entry
*element
= LIST_ENTRY(list_head(&locator
->elements
), element_entry
, entry
);
341 list_remove(&element
->entry
);
346 static BSTR
find_element_uri(saxlocator
*locator
, const xmlChar
*uri
)
348 element_entry
*element
;
352 if (!uri
) return NULL
;
354 uriW
= bstr_from_xmlChar(uri
);
356 LIST_FOR_EACH_ENTRY(element
, &locator
->elements
, element_entry
, entry
)
358 for (i
=0; i
< element
->ns_count
; i
++)
359 if (!strcmpW(uriW
, element
->ns
[i
].uri
))
362 return element
->ns
[i
].uri
;
367 ERR("namespace uri not found, %s\n", debugstr_a((char*)uri
));
371 /* used to localize version dependent error check behaviour */
372 static inline BOOL
sax_callback_failed(saxlocator
*This
, HRESULT hr
)
374 return This
->saxreader
->version
>= MSXML6
? FAILED(hr
) : hr
!= S_OK
;
377 /* index value -1 means it tries to loop for a first time */
378 static inline BOOL
iterate_endprefix_index(saxlocator
*This
, const element_entry
*element
, int *i
)
380 if (This
->saxreader
->version
>= MSXML6
)
382 if (*i
== -1) *i
= 0; else ++*i
;
383 return *i
< element
->ns_count
;
387 if (*i
== -1) *i
= element
->ns_count
-1; else --*i
;
392 static BOOL
bstr_pool_insert(struct bstrpool
*pool
, BSTR pool_entry
)
396 pool
->pool
= HeapAlloc(GetProcessHeap(), 0, 16 * sizeof(*pool
->pool
));
403 else if (pool
->index
== pool
->len
)
405 BSTR
*realloc
= HeapReAlloc(GetProcessHeap(), 0, pool
->pool
, pool
->len
* 2 * sizeof(*realloc
));
410 pool
->pool
= realloc
;
414 pool
->pool
[pool
->index
++] = pool_entry
;
418 static void free_bstr_pool(struct bstrpool
*pool
)
422 for (i
= 0; i
< pool
->index
; i
++)
423 SysFreeString(pool
->pool
[i
]);
425 HeapFree(GetProcessHeap(), 0, pool
->pool
);
428 pool
->index
= pool
->len
= 0;
431 static BSTR
bstr_from_xmlCharN(const xmlChar
*buf
, int len
)
439 dLen
= MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)buf
, len
, NULL
, 0);
440 if(len
!= -1) dLen
++;
441 bstr
= SysAllocStringLen(NULL
, dLen
-1);
444 MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)buf
, len
, bstr
, dLen
);
445 if(len
!= -1) bstr
[dLen
-1] = '\0';
450 static BSTR
QName_from_xmlChar(const xmlChar
*prefix
, const xmlChar
*name
)
455 if(!name
) return NULL
;
457 if(!prefix
|| !*prefix
)
458 return bstr_from_xmlChar(name
);
460 qname
= xmlBuildQName(name
, prefix
, NULL
, 0);
461 bstr
= bstr_from_xmlChar(qname
);
467 static BSTR
pooled_bstr_from_xmlChar(struct bstrpool
*pool
, const xmlChar
*buf
)
469 BSTR pool_entry
= bstr_from_xmlChar(buf
);
471 if (pool_entry
&& !bstr_pool_insert(pool
, pool_entry
))
473 SysFreeString(pool_entry
);
480 static BSTR
pooled_bstr_from_xmlCharN(struct bstrpool
*pool
, const xmlChar
*buf
, int len
)
482 BSTR pool_entry
= bstr_from_xmlCharN(buf
, len
);
484 if (pool_entry
&& !bstr_pool_insert(pool
, pool_entry
))
486 SysFreeString(pool_entry
);
493 static void format_error_message_from_id(saxlocator
*This
, HRESULT hr
)
495 xmlStopParser(This
->pParserCtxt
);
498 if(has_error_handler(This
))
501 if(!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
,
502 NULL
, hr
, 0, msg
, sizeof(msg
), NULL
))
504 FIXME("MSXML errors not yet supported.\n");
508 if(This
->vbInterface
)
510 BSTR bstrMsg
= SysAllocString(msg
);
511 IVBSAXErrorHandler_fatalError(This
->saxreader
->vberrorHandler
,
512 &This
->IVBSAXLocator_iface
, &bstrMsg
, hr
);
513 SysFreeString(bstrMsg
);
516 ISAXErrorHandler_fatalError(This
->saxreader
->errorHandler
,
517 &This
->ISAXLocator_iface
, msg
, hr
);
521 static void update_position(saxlocator
*This
, BOOL fix_column
)
523 const xmlChar
*p
= This
->pParserCtxt
->input
->cur
-1;
525 This
->line
= xmlSAX2GetLineNumber(This
->pParserCtxt
);
529 for(; *p
!='\n' && *p
!='\r' && p
>=This
->pParserCtxt
->input
->base
; p
--)
534 This
->column
= xmlSAX2GetColumnNumber(This
->pParserCtxt
);
538 /*** IVBSAXAttributes interface ***/
539 /*** IUnknown methods ***/
540 static HRESULT WINAPI
ivbsaxattributes_QueryInterface(
541 IVBSAXAttributes
* iface
,
545 saxlocator
*This
= impl_from_IVBSAXAttributes(iface
);
546 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
547 return IVBSAXLocator_QueryInterface(&This
->IVBSAXLocator_iface
, riid
, ppvObject
);
550 static ULONG WINAPI
ivbsaxattributes_AddRef(IVBSAXAttributes
* iface
)
552 saxlocator
*This
= impl_from_IVBSAXAttributes(iface
);
553 return ISAXLocator_AddRef(&This
->ISAXLocator_iface
);
556 static ULONG WINAPI
ivbsaxattributes_Release(IVBSAXAttributes
* iface
)
558 saxlocator
*This
= impl_from_IVBSAXAttributes(iface
);
559 return ISAXLocator_Release(&This
->ISAXLocator_iface
);
562 /*** IDispatch methods ***/
563 static HRESULT WINAPI
ivbsaxattributes_GetTypeInfoCount( IVBSAXAttributes
*iface
, UINT
* pctinfo
)
565 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
567 TRACE("(%p)->(%p)\n", This
, pctinfo
);
574 static HRESULT WINAPI
ivbsaxattributes_GetTypeInfo(
575 IVBSAXAttributes
*iface
,
576 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
578 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
581 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
583 hr
= get_typeinfo(IVBSAXAttributes_tid
, ppTInfo
);
588 static HRESULT WINAPI
ivbsaxattributes_GetIDsOfNames(
589 IVBSAXAttributes
*iface
,
596 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
600 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
603 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
606 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
609 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
610 ITypeInfo_Release(typeinfo
);
616 static HRESULT WINAPI
ivbsaxattributes_Invoke(
617 IVBSAXAttributes
*iface
,
622 DISPPARAMS
* pDispParams
,
624 EXCEPINFO
* pExcepInfo
,
627 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
631 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
632 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
634 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
637 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IVBSAXAttributes_iface
, dispIdMember
, wFlags
,
638 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
639 ITypeInfo_Release(typeinfo
);
645 /*** IVBSAXAttributes methods ***/
646 static HRESULT WINAPI
ivbsaxattributes_get_length(
647 IVBSAXAttributes
* iface
,
650 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
651 return ISAXAttributes_getLength(&This
->ISAXAttributes_iface
, nLength
);
654 static HRESULT WINAPI
ivbsaxattributes_getURI(
655 IVBSAXAttributes
* iface
,
660 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
661 return ISAXAttributes_getURI(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)uri
, &len
);
664 static HRESULT WINAPI
ivbsaxattributes_getLocalName(
665 IVBSAXAttributes
* iface
,
670 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
671 return ISAXAttributes_getLocalName(&This
->ISAXAttributes_iface
, nIndex
,
672 (const WCHAR
**)localName
, &len
);
675 static HRESULT WINAPI
ivbsaxattributes_getQName(
676 IVBSAXAttributes
* iface
,
681 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
682 return ISAXAttributes_getQName(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)QName
, &len
);
685 static HRESULT WINAPI
ivbsaxattributes_getIndexFromName(
686 IVBSAXAttributes
* iface
,
691 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
692 return ISAXAttributes_getIndexFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
693 localName
, SysStringLen(localName
), index
);
696 static HRESULT WINAPI
ivbsaxattributes_getIndexFromQName(
697 IVBSAXAttributes
* iface
,
701 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
702 return ISAXAttributes_getIndexFromQName(&This
->ISAXAttributes_iface
, QName
,
703 SysStringLen(QName
), index
);
706 static HRESULT WINAPI
ivbsaxattributes_getType(
707 IVBSAXAttributes
* iface
,
712 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
713 return ISAXAttributes_getType(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)type
, &len
);
716 static HRESULT WINAPI
ivbsaxattributes_getTypeFromName(
717 IVBSAXAttributes
* iface
,
723 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
724 return ISAXAttributes_getTypeFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
725 localName
, SysStringLen(localName
), (const WCHAR
**)type
, &len
);
728 static HRESULT WINAPI
ivbsaxattributes_getTypeFromQName(
729 IVBSAXAttributes
* iface
,
734 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
735 return ISAXAttributes_getTypeFromQName(&This
->ISAXAttributes_iface
, QName
, SysStringLen(QName
),
736 (const WCHAR
**)type
, &len
);
739 static HRESULT WINAPI
ivbsaxattributes_getValue(
740 IVBSAXAttributes
* iface
,
745 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
746 return ISAXAttributes_getValue(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)value
, &len
);
749 static HRESULT WINAPI
ivbsaxattributes_getValueFromName(
750 IVBSAXAttributes
* iface
,
756 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
757 return ISAXAttributes_getValueFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
758 localName
, SysStringLen(localName
), (const WCHAR
**)value
, &len
);
761 static HRESULT WINAPI
ivbsaxattributes_getValueFromQName(
762 IVBSAXAttributes
* iface
,
767 saxlocator
*This
= impl_from_IVBSAXAttributes( iface
);
768 return ISAXAttributes_getValueFromQName(&This
->ISAXAttributes_iface
, QName
,
769 SysStringLen(QName
), (const WCHAR
**)value
, &len
);
772 static const struct IVBSAXAttributesVtbl ivbsaxattributes_vtbl
=
774 ivbsaxattributes_QueryInterface
,
775 ivbsaxattributes_AddRef
,
776 ivbsaxattributes_Release
,
777 ivbsaxattributes_GetTypeInfoCount
,
778 ivbsaxattributes_GetTypeInfo
,
779 ivbsaxattributes_GetIDsOfNames
,
780 ivbsaxattributes_Invoke
,
781 ivbsaxattributes_get_length
,
782 ivbsaxattributes_getURI
,
783 ivbsaxattributes_getLocalName
,
784 ivbsaxattributes_getQName
,
785 ivbsaxattributes_getIndexFromName
,
786 ivbsaxattributes_getIndexFromQName
,
787 ivbsaxattributes_getType
,
788 ivbsaxattributes_getTypeFromName
,
789 ivbsaxattributes_getTypeFromQName
,
790 ivbsaxattributes_getValue
,
791 ivbsaxattributes_getValueFromName
,
792 ivbsaxattributes_getValueFromQName
795 /*** ISAXAttributes interface ***/
796 /*** IUnknown methods ***/
797 static HRESULT WINAPI
isaxattributes_QueryInterface(
798 ISAXAttributes
* iface
,
802 saxlocator
*This
= impl_from_ISAXAttributes(iface
);
803 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
804 return ISAXLocator_QueryInterface(&This
->ISAXLocator_iface
, riid
, ppvObject
);
807 static ULONG WINAPI
isaxattributes_AddRef(ISAXAttributes
* iface
)
809 saxlocator
*This
= impl_from_ISAXAttributes(iface
);
811 return ISAXLocator_AddRef(&This
->ISAXLocator_iface
);
814 static ULONG WINAPI
isaxattributes_Release(ISAXAttributes
* iface
)
816 saxlocator
*This
= impl_from_ISAXAttributes(iface
);
819 return ISAXLocator_Release(&This
->ISAXLocator_iface
);
822 /*** ISAXAttributes methods ***/
823 static HRESULT WINAPI
isaxattributes_getLength(
824 ISAXAttributes
* iface
,
827 saxlocator
*This
= impl_from_ISAXAttributes( iface
);
829 *length
= This
->nb_attributes
;
830 TRACE("Length set to %d\n", *length
);
834 static HRESULT WINAPI
isaxattributes_getURI(
835 ISAXAttributes
* iface
,
840 saxlocator
*This
= impl_from_ISAXAttributes( iface
);
841 TRACE("(%p)->(%d)\n", This
, index
);
843 if(index
>= This
->nb_attributes
|| index
< 0) return E_INVALIDARG
;
844 if(!url
|| !size
) return E_POINTER
;
846 *size
= SysStringLen(This
->attributes
[index
].szURI
);
847 *url
= This
->attributes
[index
].szURI
;
849 TRACE("(%s:%d)\n", debugstr_w(This
->attributes
[index
].szURI
), *size
);
854 static HRESULT WINAPI
isaxattributes_getLocalName(
855 ISAXAttributes
* iface
,
857 const WCHAR
**pLocalName
,
858 int *pLocalNameLength
)
860 saxlocator
*This
= impl_from_ISAXAttributes( iface
);
861 TRACE("(%p)->(%d)\n", This
, nIndex
);
863 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
864 if(!pLocalName
|| !pLocalNameLength
) return E_POINTER
;
866 *pLocalNameLength
= SysStringLen(This
->attributes
[nIndex
].szLocalname
);
867 *pLocalName
= This
->attributes
[nIndex
].szLocalname
;
872 static HRESULT WINAPI
isaxattributes_getQName(
873 ISAXAttributes
* iface
,
875 const WCHAR
**pQName
,
878 saxlocator
*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(!pQName
|| !pQNameLength
) return E_POINTER
;
884 *pQNameLength
= SysStringLen(This
->attributes
[nIndex
].szQName
);
885 *pQName
= This
->attributes
[nIndex
].szQName
;
890 static HRESULT WINAPI
isaxattributes_getName(
891 ISAXAttributes
* iface
,
895 const WCHAR
**localName
,
900 saxlocator
*This
= impl_from_ISAXAttributes( iface
);
901 TRACE("(%p)->(%d)\n", This
, index
);
903 if(index
>=This
->nb_attributes
|| index
<0) return E_INVALIDARG
;
904 if(!uri
|| !pUriLength
|| !localName
|| !pLocalNameSize
905 || !QName
|| !pQNameLength
) return E_POINTER
;
907 *pUriLength
= SysStringLen(This
->attributes
[index
].szURI
);
908 *uri
= This
->attributes
[index
].szURI
;
909 *pLocalNameSize
= SysStringLen(This
->attributes
[index
].szLocalname
);
910 *localName
= This
->attributes
[index
].szLocalname
;
911 *pQNameLength
= SysStringLen(This
->attributes
[index
].szQName
);
912 *QName
= This
->attributes
[index
].szQName
;
914 TRACE("(%s, %s, %s)\n", debugstr_w(*uri
), debugstr_w(*localName
), debugstr_w(*QName
));
919 static HRESULT WINAPI
isaxattributes_getIndexFromName(
920 ISAXAttributes
* iface
,
923 const WCHAR
*pLocalName
,
927 saxlocator
*This
= impl_from_ISAXAttributes( iface
);
929 TRACE("(%p)->(%s, %d, %s, %d)\n", This
, debugstr_w(pUri
), cUriLength
,
930 debugstr_w(pLocalName
), cocalNameLength
);
932 if(!pUri
|| !pLocalName
|| !index
) return E_POINTER
;
934 for(i
=0; i
<This
->nb_attributes
; i
++)
936 if(cUriLength
!=SysStringLen(This
->attributes
[i
].szURI
)
937 || cocalNameLength
!=SysStringLen(This
->attributes
[i
].szLocalname
))
939 if(cUriLength
&& memcmp(pUri
, This
->attributes
[i
].szURI
,
940 sizeof(WCHAR
)*cUriLength
))
942 if(cocalNameLength
&& memcmp(pLocalName
, This
->attributes
[i
].szLocalname
,
943 sizeof(WCHAR
)*cocalNameLength
))
953 static HRESULT WINAPI
isaxattributes_getIndexFromQName(
954 ISAXAttributes
* iface
,
959 saxlocator
*This
= impl_from_ISAXAttributes( iface
);
961 TRACE("(%p)->(%s, %d)\n", This
, debugstr_w(pQName
), nQNameLength
);
963 if(!pQName
|| !index
) return E_POINTER
;
964 if(!nQNameLength
) return E_INVALIDARG
;
966 for(i
=0; i
<This
->nb_attributes
; i
++)
968 if(nQNameLength
!=SysStringLen(This
->attributes
[i
].szQName
)) continue;
969 if(memcmp(pQName
, This
->attributes
[i
].szQName
, sizeof(WCHAR
)*nQNameLength
)) continue;
978 static HRESULT WINAPI
isaxattributes_getType(
979 ISAXAttributes
* iface
,
984 saxlocator
*This
= impl_from_ISAXAttributes( iface
);
986 FIXME("(%p)->(%d) stub\n", This
, nIndex
);
990 static HRESULT WINAPI
isaxattributes_getTypeFromName(
991 ISAXAttributes
* iface
,
994 const WCHAR
*pLocalName
,
999 saxlocator
*This
= impl_from_ISAXAttributes( iface
);
1001 FIXME("(%p)->(%s, %d, %s, %d) stub\n", This
, debugstr_w(pUri
), nUri
,
1002 debugstr_w(pLocalName
), nLocalName
);
1006 static HRESULT WINAPI
isaxattributes_getTypeFromQName(
1007 ISAXAttributes
* iface
,
1008 const WCHAR
*pQName
,
1010 const WCHAR
**pType
,
1013 saxlocator
*This
= impl_from_ISAXAttributes( iface
);
1015 FIXME("(%p)->(%s, %d) stub\n", This
, debugstr_w(pQName
), nQName
);
1019 static HRESULT WINAPI
isaxattributes_getValue(
1020 ISAXAttributes
* iface
,
1022 const WCHAR
**value
,
1025 saxlocator
*This
= impl_from_ISAXAttributes( iface
);
1026 TRACE("(%p)->(%d)\n", This
, index
);
1028 if(index
>=This
->nb_attributes
|| index
<0) return E_INVALIDARG
;
1029 if(!value
|| !nValue
) return E_POINTER
;
1031 *nValue
= SysStringLen(This
->attributes
[index
].szValue
);
1032 *value
= This
->attributes
[index
].szValue
;
1034 TRACE("(%s:%d)\n", debugstr_w(*value
), *nValue
);
1039 static HRESULT WINAPI
isaxattributes_getValueFromName(
1040 ISAXAttributes
* iface
,
1043 const WCHAR
*pLocalName
,
1045 const WCHAR
**pValue
,
1050 saxlocator
*This
= impl_from_ISAXAttributes( iface
);
1051 TRACE("(%p)->(%s, %d, %s, %d)\n", This
, debugstr_w(pUri
), nUri
,
1052 debugstr_w(pLocalName
), nLocalName
);
1054 hr
= ISAXAttributes_getIndexFromName(iface
,
1055 pUri
, nUri
, pLocalName
, nLocalName
, &index
);
1056 if(hr
==S_OK
) hr
= ISAXAttributes_getValue(iface
, index
, pValue
, nValue
);
1061 static HRESULT WINAPI
isaxattributes_getValueFromQName(
1062 ISAXAttributes
* iface
,
1063 const WCHAR
*pQName
,
1065 const WCHAR
**pValue
,
1070 saxlocator
*This
= impl_from_ISAXAttributes( iface
);
1071 TRACE("(%p)->(%s, %d)\n", This
, debugstr_w(pQName
), nQName
);
1073 hr
= ISAXAttributes_getIndexFromQName(iface
, pQName
, nQName
, &index
);
1074 if(hr
==S_OK
) hr
= ISAXAttributes_getValue(iface
, index
, pValue
, nValue
);
1079 static const struct ISAXAttributesVtbl isaxattributes_vtbl
=
1081 isaxattributes_QueryInterface
,
1082 isaxattributes_AddRef
,
1083 isaxattributes_Release
,
1084 isaxattributes_getLength
,
1085 isaxattributes_getURI
,
1086 isaxattributes_getLocalName
,
1087 isaxattributes_getQName
,
1088 isaxattributes_getName
,
1089 isaxattributes_getIndexFromName
,
1090 isaxattributes_getIndexFromQName
,
1091 isaxattributes_getType
,
1092 isaxattributes_getTypeFromName
,
1093 isaxattributes_getTypeFromQName
,
1094 isaxattributes_getValue
,
1095 isaxattributes_getValueFromName
,
1096 isaxattributes_getValueFromQName
1099 static HRESULT
SAXAttributes_populate(saxlocator
*locator
,
1100 int nb_namespaces
, const xmlChar
**xmlNamespaces
,
1101 int nb_attributes
, const xmlChar
**xmlAttributes
)
1103 static const xmlChar xmlns
[] = "xmlns";
1104 static const WCHAR xmlnsW
[] = { 'x','m','l','n','s',0 };
1106 struct _attributes
*attrs
;
1109 locator
->nb_attributes
= nb_namespaces
+nb_attributes
;
1110 if(locator
->nb_attributes
> locator
->attributesSize
)
1112 attrs
= heap_realloc(locator
->attributes
, sizeof(struct _attributes
)*locator
->nb_attributes
*2);
1115 locator
->nb_attributes
= 0;
1116 return E_OUTOFMEMORY
;
1118 locator
->attributes
= attrs
;
1122 attrs
= locator
->attributes
;
1125 for(index
=0; index
<nb_namespaces
; index
++)
1127 attrs
[nb_attributes
+index
].szLocalname
= SysAllocStringLen(NULL
, 0);
1128 attrs
[nb_attributes
+index
].szURI
= locator
->namespaceUri
;
1129 attrs
[nb_attributes
+index
].szValue
= bstr_from_xmlChar(xmlNamespaces
[2*index
+1]);
1130 if(!xmlNamespaces
[2*index
])
1131 attrs
[nb_attributes
+index
].szQName
= SysAllocString(xmlnsW
);
1133 attrs
[nb_attributes
+index
].szQName
= QName_from_xmlChar(xmlns
, xmlNamespaces
[2*index
]);
1136 for(index
=0; index
<nb_attributes
; index
++)
1138 attrs
[index
].szLocalname
= bstr_from_xmlChar(xmlAttributes
[index
*5]);
1139 attrs
[index
].szURI
= find_element_uri(locator
, xmlAttributes
[index
*5+2]);
1140 attrs
[index
].szValue
= bstr_from_xmlCharN(xmlAttributes
[index
*5+3],
1141 xmlAttributes
[index
*5+4]-xmlAttributes
[index
*5+3]);
1142 attrs
[index
].szQName
= QName_from_xmlChar(xmlAttributes
[index
*5+1],
1143 xmlAttributes
[index
*5]);
1149 /*** LibXML callbacks ***/
1150 static void libxmlStartDocument(void *ctx
)
1152 saxlocator
*This
= ctx
;
1155 if(This
->saxreader
->version
>= MSXML6
)
1157 const xmlChar
*p
= This
->pParserCtxt
->input
->cur
-1;
1158 update_position(This
, FALSE
);
1159 while(p
>This
->pParserCtxt
->input
->base
&& *p
!='>')
1161 if(*p
=='\n' || (*p
=='\r' && *(p
+1)!='\n'))
1166 for(; p
>=This
->pParserCtxt
->input
->base
&& *p
!='\n' && *p
!='\r'; p
--)
1170 if(has_content_handler(This
))
1172 if(This
->vbInterface
)
1173 hr
= IVBSAXContentHandler_startDocument(This
->saxreader
->vbcontentHandler
);
1175 hr
= ISAXContentHandler_startDocument(This
->saxreader
->contentHandler
);
1177 if (sax_callback_failed(This
, hr
))
1178 format_error_message_from_id(This
, hr
);
1182 static void libxmlEndDocument(void *ctx
)
1184 saxlocator
*This
= ctx
;
1187 if(This
->saxreader
->version
>= MSXML6
) {
1188 update_position(This
, FALSE
);
1189 if(This
->column
> 1)
1197 if(This
->ret
!= S_OK
) return;
1199 if(has_content_handler(This
))
1201 if(This
->vbInterface
)
1202 hr
= IVBSAXContentHandler_endDocument(This
->saxreader
->vbcontentHandler
);
1204 hr
= ISAXContentHandler_endDocument(This
->saxreader
->contentHandler
);
1206 if (sax_callback_failed(This
, hr
))
1207 format_error_message_from_id(This
, hr
);
1211 static void libxmlStartElementNS(
1213 const xmlChar
*localname
,
1214 const xmlChar
*prefix
,
1217 const xmlChar
**namespaces
,
1220 const xmlChar
**attributes
)
1222 saxlocator
*This
= ctx
;
1223 element_entry
*element
;
1226 update_position(This
, TRUE
);
1227 if(*(This
->pParserCtxt
->input
->cur
) == '/')
1229 if(This
->saxreader
->version
< MSXML6
)
1232 element
= alloc_element_entry(localname
, prefix
, nb_namespaces
, namespaces
);
1233 push_element_ns(This
, element
);
1235 if (has_content_handler(This
))
1240 for (i
= 0; i
< nb_namespaces
; i
++)
1242 if(This
->vbInterface
)
1243 hr
= IVBSAXContentHandler_startPrefixMapping(
1244 This
->saxreader
->vbcontentHandler
,
1245 &element
->ns
[i
].prefix
,
1246 &element
->ns
[i
].uri
);
1248 hr
= ISAXContentHandler_startPrefixMapping(
1249 This
->saxreader
->contentHandler
,
1250 element
->ns
[i
].prefix
,
1251 SysStringLen(element
->ns
[i
].prefix
),
1253 SysStringLen(element
->ns
[i
].uri
));
1255 if (sax_callback_failed(This
, hr
))
1257 format_error_message_from_id(This
, hr
);
1262 uri
= find_element_uri(This
, URI
);
1264 hr
= SAXAttributes_populate(This
, nb_namespaces
, namespaces
, nb_attributes
, attributes
);
1267 if(This
->vbInterface
)
1268 hr
= IVBSAXContentHandler_startElement(This
->saxreader
->vbcontentHandler
,
1269 &uri
, &element
->local
, &element
->qname
, &This
->IVBSAXAttributes_iface
);
1271 hr
= ISAXContentHandler_startElement(This
->saxreader
->contentHandler
,
1272 uri
, SysStringLen(uri
),
1273 element
->local
, SysStringLen(element
->local
),
1274 element
->qname
, SysStringLen(element
->qname
),
1275 &This
->ISAXAttributes_iface
);
1279 if (sax_callback_failed(This
, hr
))
1280 format_error_message_from_id(This
, hr
);
1283 static void libxmlEndElementNS(
1285 const xmlChar
*localname
,
1286 const xmlChar
*prefix
,
1289 saxlocator
*This
= ctx
;
1290 element_entry
*element
;
1296 update_position(This
, FALSE
);
1297 p
= This
->pParserCtxt
->input
->cur
;
1298 if(This
->saxreader
->version
>= MSXML6
)
1301 while(p
>This
->pParserCtxt
->input
->base
&& *p
!='>')
1303 if(*p
=='\n' || (*p
=='\r' && *(p
+1)!='\n'))
1308 else if(*(p
-1)!='>' || *(p
-2)!='/')
1311 while(p
-2>=This
->pParserCtxt
->input
->base
1312 && *(p
-2)!='<' && *(p
-1)!='/')
1314 if(*p
=='\n' || (*p
=='\r' && *(p
+1)!='\n'))
1320 for(; p
>=This
->pParserCtxt
->input
->base
&& *p
!='\n' && *p
!='\r'; p
--)
1323 uri
= find_element_uri(This
, URI
);
1324 element
= pop_element_ns(This
);
1326 if (!has_content_handler(This
))
1328 This
->nb_attributes
= 0;
1329 free_element_entry(element
);
1333 if(This
->vbInterface
)
1334 hr
= IVBSAXContentHandler_endElement(
1335 This
->saxreader
->vbcontentHandler
,
1336 &uri
, &element
->local
, &element
->qname
);
1338 hr
= ISAXContentHandler_endElement(
1339 This
->saxreader
->contentHandler
,
1340 uri
, SysStringLen(uri
),
1341 element
->local
, SysStringLen(element
->local
),
1342 element
->qname
, SysStringLen(element
->qname
));
1344 This
->nb_attributes
= 0;
1346 if (sax_callback_failed(This
, hr
))
1348 format_error_message_from_id(This
, hr
);
1353 while (iterate_endprefix_index(This
, element
, &i
))
1355 if(This
->vbInterface
)
1356 hr
= IVBSAXContentHandler_endPrefixMapping(
1357 This
->saxreader
->vbcontentHandler
, &element
->ns
[i
].prefix
);
1359 hr
= ISAXContentHandler_endPrefixMapping(
1360 This
->saxreader
->contentHandler
,
1361 element
->ns
[i
].prefix
, SysStringLen(element
->ns
[i
].prefix
));
1363 if (sax_callback_failed(This
, hr
)) break;
1366 if (sax_callback_failed(This
, hr
))
1367 format_error_message_from_id(This
, hr
);
1369 free_element_entry(element
);
1372 static void libxmlCharacters(
1377 saxlocator
*This
= ctx
;
1381 BOOL lastEvent
= FALSE
;
1383 if(!(has_content_handler(This
))) return;
1385 update_position(This
, FALSE
);
1386 cur
= (xmlChar
*)This
->pParserCtxt
->input
->cur
;
1387 while(cur
>=This
->pParserCtxt
->input
->base
&& *cur
!='>')
1389 if(*cur
=='\n' || (*cur
=='\r' && *(cur
+1)!='\n'))
1394 for(; cur
>=This
->pParserCtxt
->input
->base
&& *cur
!='\n' && *cur
!='\r'; cur
--)
1398 if(*(ch
-1)=='\r') cur
--;
1403 while(end
-ch
<len
&& *end
!='\r') end
++;
1414 if(This
->saxreader
->version
>= MSXML6
)
1418 for(p
=cur
; p
!=end
; p
++)
1435 Chars
= pooled_bstr_from_xmlCharN(&This
->saxreader
->pool
, cur
, end
-cur
);
1436 if(This
->vbInterface
)
1437 hr
= IVBSAXContentHandler_characters(
1438 This
->saxreader
->vbcontentHandler
, &Chars
);
1440 hr
= ISAXContentHandler_characters(
1441 This
->saxreader
->contentHandler
,
1442 Chars
, SysStringLen(Chars
));
1444 if (sax_callback_failed(This
, hr
))
1446 format_error_message_from_id(This
, hr
);
1450 if(This
->saxreader
->version
< MSXML6
)
1451 This
->column
+= end
-cur
;
1464 if(end
-ch
== len
) break;
1468 static void libxmlSetDocumentLocator(
1470 xmlSAXLocatorPtr loc
)
1472 saxlocator
*This
= ctx
;
1475 if(has_content_handler(This
))
1477 if(This
->vbInterface
)
1478 hr
= IVBSAXContentHandler_putref_documentLocator(This
->saxreader
->vbcontentHandler
,
1479 &This
->IVBSAXLocator_iface
);
1481 hr
= ISAXContentHandler_putDocumentLocator(This
->saxreader
->contentHandler
,
1482 &This
->ISAXLocator_iface
);
1486 format_error_message_from_id(This
, hr
);
1489 static void libxmlComment(void *ctx
, const xmlChar
*value
)
1491 saxlocator
*This
= ctx
;
1494 const xmlChar
*p
= This
->pParserCtxt
->input
->cur
;
1496 update_position(This
, FALSE
);
1497 while(p
-4>=This
->pParserCtxt
->input
->base
1498 && memcmp(p
-4, "<!--", sizeof(char[4])))
1500 if(*p
=='\n' || (*p
=='\r' && *(p
+1)!='\n'))
1505 for(; p
>=This
->pParserCtxt
->input
->base
&& *p
!='\n' && *p
!='\r'; p
--)
1508 if(!This
->vbInterface
&& !This
->saxreader
->lexicalHandler
) return;
1509 if(This
->vbInterface
&& !This
->saxreader
->vblexicalHandler
) return;
1511 bValue
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, value
);
1513 if(This
->vbInterface
)
1514 hr
= IVBSAXLexicalHandler_comment(
1515 This
->saxreader
->vblexicalHandler
, &bValue
);
1517 hr
= ISAXLexicalHandler_comment(
1518 This
->saxreader
->lexicalHandler
,
1519 bValue
, SysStringLen(bValue
));
1522 format_error_message_from_id(This
, hr
);
1525 static void libxmlFatalError(void *ctx
, const char *msg
, ...)
1527 saxlocator
*This
= ctx
;
1533 if(This
->ret
!= S_OK
) {
1534 xmlStopParser(This
->pParserCtxt
);
1538 va_start(args
, msg
);
1539 vsprintf(message
, msg
, args
);
1542 len
= MultiByteToWideChar(CP_UNIXCP
, 0, message
, -1, NULL
, 0);
1543 error
= heap_alloc(sizeof(WCHAR
)*len
);
1546 MultiByteToWideChar(CP_UNIXCP
, 0, message
, -1, error
, len
);
1547 TRACE("fatal error for %p: %s\n", This
, debugstr_w(error
));
1550 if(!has_error_handler(This
))
1552 xmlStopParser(This
->pParserCtxt
);
1558 FIXME("Error handling is not compatible.\n");
1560 if(This
->vbInterface
)
1562 BSTR bstrError
= SysAllocString(error
);
1563 IVBSAXErrorHandler_fatalError(This
->saxreader
->vberrorHandler
, &This
->IVBSAXLocator_iface
,
1564 &bstrError
, E_FAIL
);
1565 SysFreeString(bstrError
);
1568 ISAXErrorHandler_fatalError(This
->saxreader
->errorHandler
, &This
->ISAXLocator_iface
,
1573 xmlStopParser(This
->pParserCtxt
);
1577 static void libxmlCDataBlock(void *ctx
, const xmlChar
*value
, int len
)
1579 saxlocator
*This
= ctx
;
1581 xmlChar
*beg
= (xmlChar
*)This
->pParserCtxt
->input
->cur
-len
;
1585 BOOL lastEvent
= FALSE
, change
;
1587 update_position(This
, FALSE
);
1588 while(beg
-9>=This
->pParserCtxt
->input
->base
1589 && memcmp(beg
-9, "<![CDATA[", sizeof(char[9])))
1591 if(*beg
=='\n' || (*beg
=='\r' && *(beg
+1)!='\n'))
1596 for(; beg
>=This
->pParserCtxt
->input
->base
&& *beg
!='\n' && *beg
!='\r'; beg
--)
1599 if(This
->vbInterface
&& This
->saxreader
->vblexicalHandler
)
1600 hr
= IVBSAXLexicalHandler_startCDATA(This
->saxreader
->vblexicalHandler
);
1601 if(!This
->vbInterface
&& This
->saxreader
->lexicalHandler
)
1602 hr
= ISAXLexicalHandler_startCDATA(This
->saxreader
->lexicalHandler
);
1606 format_error_message_from_id(This
, hr
);
1610 realLen
= This
->pParserCtxt
->input
->cur
-beg
-3;
1616 while(end
-beg
<realLen
&& *end
!='\r') end
++;
1617 if(end
-beg
==realLen
)
1622 else if(end
-beg
==realLen
-1 && *end
=='\r' && *(end
+1)=='\n')
1625 if(*end
== '\r') change
= TRUE
;
1626 else change
= FALSE
;
1628 if(change
) *end
= '\n';
1630 if(has_content_handler(This
))
1632 Chars
= pooled_bstr_from_xmlCharN(&This
->saxreader
->pool
, cur
, end
-cur
+1);
1633 if(This
->vbInterface
)
1634 hr
= IVBSAXContentHandler_characters(
1635 This
->saxreader
->vbcontentHandler
, &Chars
);
1637 hr
= ISAXContentHandler_characters(
1638 This
->saxreader
->contentHandler
,
1639 Chars
, SysStringLen(Chars
));
1642 if(change
) *end
= '\r';
1647 This
->column
+= end
-cur
+2;
1652 if(This
->vbInterface
&& This
->saxreader
->vblexicalHandler
)
1653 hr
= IVBSAXLexicalHandler_endCDATA(This
->saxreader
->vblexicalHandler
);
1654 if(!This
->vbInterface
&& This
->saxreader
->lexicalHandler
)
1655 hr
= ISAXLexicalHandler_endCDATA(This
->saxreader
->lexicalHandler
);
1658 format_error_message_from_id(This
, hr
);
1660 This
->column
+= 4+end
-cur
;
1663 /*** IVBSAXLocator interface ***/
1664 /*** IUnknown methods ***/
1665 static HRESULT WINAPI
ivbsaxlocator_QueryInterface(IVBSAXLocator
* iface
, REFIID riid
, void **ppvObject
)
1667 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1669 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
1673 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
1674 IsEqualGUID( riid
, &IID_IDispatch
) ||
1675 IsEqualGUID( riid
, &IID_IVBSAXLocator
))
1679 else if ( IsEqualGUID( riid
, &IID_IVBSAXAttributes
))
1681 *ppvObject
= &This
->IVBSAXAttributes_iface
;
1685 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1686 return E_NOINTERFACE
;
1689 IVBSAXLocator_AddRef( iface
);
1694 static ULONG WINAPI
ivbsaxlocator_AddRef(IVBSAXLocator
* iface
)
1696 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1697 TRACE("%p\n", This
);
1698 return InterlockedIncrement( &This
->ref
);
1701 static ULONG WINAPI
ivbsaxlocator_Release(
1702 IVBSAXLocator
* iface
)
1704 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1705 return ISAXLocator_Release((ISAXLocator
*)&This
->IVBSAXLocator_iface
);
1708 /*** IDispatch methods ***/
1709 static HRESULT WINAPI
ivbsaxlocator_GetTypeInfoCount( IVBSAXLocator
*iface
, UINT
* pctinfo
)
1711 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1713 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1720 static HRESULT WINAPI
ivbsaxlocator_GetTypeInfo(
1721 IVBSAXLocator
*iface
,
1722 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
1724 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1727 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1729 hr
= get_typeinfo(IVBSAXLocator_tid
, ppTInfo
);
1734 static HRESULT WINAPI
ivbsaxlocator_GetIDsOfNames(
1735 IVBSAXLocator
*iface
,
1737 LPOLESTR
* rgszNames
,
1742 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1743 ITypeInfo
*typeinfo
;
1746 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1749 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
1750 return E_INVALIDARG
;
1752 hr
= get_typeinfo(IVBSAXLocator_tid
, &typeinfo
);
1755 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
1756 ITypeInfo_Release(typeinfo
);
1762 static HRESULT WINAPI
ivbsaxlocator_Invoke(
1763 IVBSAXLocator
*iface
,
1764 DISPID dispIdMember
,
1768 DISPPARAMS
* pDispParams
,
1769 VARIANT
* pVarResult
,
1770 EXCEPINFO
* pExcepInfo
,
1773 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1774 ITypeInfo
*typeinfo
;
1777 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1778 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1780 hr
= get_typeinfo(IVBSAXLocator_tid
, &typeinfo
);
1783 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IVBSAXLocator_iface
, dispIdMember
, wFlags
,
1784 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1785 ITypeInfo_Release(typeinfo
);
1791 /*** IVBSAXLocator methods ***/
1792 static HRESULT WINAPI
ivbsaxlocator_get_columnNumber(
1793 IVBSAXLocator
* iface
,
1796 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1797 return ISAXLocator_getColumnNumber((ISAXLocator
*)&This
->IVBSAXLocator_iface
, pnColumn
);
1800 static HRESULT WINAPI
ivbsaxlocator_get_lineNumber(
1801 IVBSAXLocator
* iface
,
1804 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1805 return ISAXLocator_getLineNumber((ISAXLocator
*)&This
->IVBSAXLocator_iface
, pnLine
);
1808 static HRESULT WINAPI
ivbsaxlocator_get_publicId(
1809 IVBSAXLocator
* iface
,
1812 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1813 return ISAXLocator_getPublicId((ISAXLocator
*)&This
->IVBSAXLocator_iface
,
1814 (const WCHAR
**)publicId
);
1817 static HRESULT WINAPI
ivbsaxlocator_get_systemId(
1818 IVBSAXLocator
* iface
,
1821 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1822 return ISAXLocator_getSystemId((ISAXLocator
*)&This
->IVBSAXLocator_iface
,
1823 (const WCHAR
**)systemId
);
1826 static const struct IVBSAXLocatorVtbl VBSAXLocatorVtbl
=
1828 ivbsaxlocator_QueryInterface
,
1829 ivbsaxlocator_AddRef
,
1830 ivbsaxlocator_Release
,
1831 ivbsaxlocator_GetTypeInfoCount
,
1832 ivbsaxlocator_GetTypeInfo
,
1833 ivbsaxlocator_GetIDsOfNames
,
1834 ivbsaxlocator_Invoke
,
1835 ivbsaxlocator_get_columnNumber
,
1836 ivbsaxlocator_get_lineNumber
,
1837 ivbsaxlocator_get_publicId
,
1838 ivbsaxlocator_get_systemId
1841 /*** ISAXLocator interface ***/
1842 /*** IUnknown methods ***/
1843 static HRESULT WINAPI
isaxlocator_QueryInterface(ISAXLocator
* iface
, REFIID riid
, void **ppvObject
)
1845 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1847 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
1851 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
1852 IsEqualGUID( riid
, &IID_ISAXLocator
))
1856 else if ( IsEqualGUID( riid
, &IID_ISAXAttributes
))
1858 *ppvObject
= &This
->ISAXAttributes_iface
;
1862 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1863 return E_NOINTERFACE
;
1866 ISAXLocator_AddRef( iface
);
1871 static ULONG WINAPI
isaxlocator_AddRef(ISAXLocator
* iface
)
1873 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1874 ULONG ref
= InterlockedIncrement( &This
->ref
);
1875 TRACE("(%p)->(%d)\n", This
, ref
);
1879 static ULONG WINAPI
isaxlocator_Release(
1882 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1883 LONG ref
= InterlockedDecrement( &This
->ref
);
1885 TRACE("(%p)->(%d)\n", This
, ref
);
1889 element_entry
*element
, *element2
;
1892 SysFreeString(This
->publicId
);
1893 SysFreeString(This
->systemId
);
1894 SysFreeString(This
->namespaceUri
);
1896 for(index
=0; index
<This
->nb_attributes
; index
++)
1898 SysFreeString(This
->attributes
[index
].szLocalname
);
1899 SysFreeString(This
->attributes
[index
].szValue
);
1900 SysFreeString(This
->attributes
[index
].szQName
);
1902 heap_free(This
->attributes
);
1905 LIST_FOR_EACH_ENTRY_SAFE(element
, element2
, &This
->elements
, element_entry
, entry
)
1907 list_remove(&element
->entry
);
1908 free_element_entry(element
);
1911 ISAXXMLReader_Release(&This
->saxreader
->ISAXXMLReader_iface
);
1918 /*** ISAXLocator methods ***/
1919 static HRESULT WINAPI
isaxlocator_getColumnNumber(
1923 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1925 *pnColumn
= This
->column
;
1929 static HRESULT WINAPI
isaxlocator_getLineNumber(
1933 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1935 *pnLine
= This
->line
;
1939 static HRESULT WINAPI
isaxlocator_getPublicId(
1941 const WCHAR
** ppwchPublicId
)
1944 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1946 SysFreeString(This
->publicId
);
1948 publicId
= bstr_from_xmlChar(xmlSAX2GetPublicId(This
->pParserCtxt
));
1949 if(SysStringLen(publicId
))
1950 This
->publicId
= (WCHAR
*)&publicId
;
1953 SysFreeString(publicId
);
1954 This
->publicId
= NULL
;
1957 *ppwchPublicId
= This
->publicId
;
1961 static HRESULT WINAPI
isaxlocator_getSystemId(
1963 const WCHAR
** ppwchSystemId
)
1966 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1968 SysFreeString(This
->systemId
);
1970 systemId
= bstr_from_xmlChar(xmlSAX2GetSystemId(This
->pParserCtxt
));
1971 if(SysStringLen(systemId
))
1972 This
->systemId
= (WCHAR
*)&systemId
;
1975 SysFreeString(systemId
);
1976 This
->systemId
= NULL
;
1979 *ppwchSystemId
= This
->systemId
;
1983 static const struct ISAXLocatorVtbl SAXLocatorVtbl
=
1985 isaxlocator_QueryInterface
,
1987 isaxlocator_Release
,
1988 isaxlocator_getColumnNumber
,
1989 isaxlocator_getLineNumber
,
1990 isaxlocator_getPublicId
,
1991 isaxlocator_getSystemId
1994 static HRESULT
SAXLocator_create(saxreader
*reader
, saxlocator
**ppsaxlocator
, BOOL vbInterface
)
1996 static const WCHAR w3xmlns
[] = { 'h','t','t','p',':','/','/', 'w','w','w','.','w','3','.',
1997 'o','r','g','/','2','0','0','0','/','x','m','l','n','s','/',0 };
1999 saxlocator
*locator
;
2001 locator
= heap_alloc( sizeof (*locator
) );
2003 return E_OUTOFMEMORY
;
2005 locator
->IVBSAXLocator_iface
.lpVtbl
= &VBSAXLocatorVtbl
;
2006 locator
->ISAXLocator_iface
.lpVtbl
= &SAXLocatorVtbl
;
2007 locator
->IVBSAXAttributes_iface
.lpVtbl
= &ivbsaxattributes_vtbl
;
2008 locator
->ISAXAttributes_iface
.lpVtbl
= &isaxattributes_vtbl
;
2010 locator
->vbInterface
= vbInterface
;
2012 locator
->saxreader
= reader
;
2013 ISAXXMLReader_AddRef(&reader
->ISAXXMLReader_iface
);
2015 locator
->pParserCtxt
= NULL
;
2016 locator
->publicId
= NULL
;
2017 locator
->systemId
= NULL
;
2018 locator
->line
= (reader
->version
>=MSXML6
? 1 : 0);
2019 locator
->column
= 0;
2020 locator
->ret
= S_OK
;
2021 if(locator
->saxreader
->version
>= MSXML6
)
2022 locator
->namespaceUri
= SysAllocString(w3xmlns
);
2024 locator
->namespaceUri
= SysAllocStringLen(NULL
, 0);
2025 if(!locator
->namespaceUri
)
2027 ISAXXMLReader_Release(&reader
->ISAXXMLReader_iface
);
2029 return E_OUTOFMEMORY
;
2032 locator
->attributesSize
= 8;
2033 locator
->nb_attributes
= 0;
2034 locator
->attributes
= heap_alloc(sizeof(struct _attributes
)*locator
->attributesSize
);
2035 if(!locator
->attributes
)
2037 ISAXXMLReader_Release(&reader
->ISAXXMLReader_iface
);
2038 SysFreeString(locator
->namespaceUri
);
2040 return E_OUTOFMEMORY
;
2043 list_init(&locator
->elements
);
2045 *ppsaxlocator
= locator
;
2047 TRACE("returning %p\n", *ppsaxlocator
);
2052 /*** SAXXMLReader internal functions ***/
2053 static HRESULT
internal_parseBuffer(saxreader
*This
, const char *buffer
, int size
, BOOL vbInterface
)
2055 xmlCharEncoding encoding
= XML_CHAR_ENCODING_NONE
;
2056 xmlChar
*enc_name
= NULL
;
2057 saxlocator
*locator
;
2060 hr
= SAXLocator_create(This
, &locator
, vbInterface
);
2066 const unsigned char *buff
= (unsigned char*)buffer
;
2068 encoding
= xmlDetectCharEncoding((xmlChar
*)buffer
, 4);
2069 enc_name
= (xmlChar
*)xmlGetCharEncodingName(encoding
);
2070 TRACE("detected encoding: %s\n", enc_name
);
2071 /* skip BOM, parser won't switch encodings and so won't skip it on its own */
2072 if ((encoding
== XML_CHAR_ENCODING_UTF8
) &&
2073 buff
[0] == 0xEF && buff
[1] == 0xBB && buff
[2] == 0xBF)
2080 locator
->pParserCtxt
= xmlCreateMemoryParserCtxt(buffer
, size
);
2081 if(!locator
->pParserCtxt
)
2083 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
2087 if (encoding
== XML_CHAR_ENCODING_UTF8
)
2088 locator
->pParserCtxt
->encoding
= xmlStrdup(enc_name
);
2090 xmlFree(locator
->pParserCtxt
->sax
);
2091 locator
->pParserCtxt
->sax
= &locator
->saxreader
->sax
;
2092 locator
->pParserCtxt
->userData
= locator
;
2094 This
->isParsing
= TRUE
;
2095 if(xmlParseDocument(locator
->pParserCtxt
)==-1 && locator
->ret
==S_OK
)
2099 This
->isParsing
= FALSE
;
2101 if(locator
->pParserCtxt
)
2103 locator
->pParserCtxt
->sax
= NULL
;
2104 xmlFreeParserCtxt(locator
->pParserCtxt
);
2105 locator
->pParserCtxt
= NULL
;
2108 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
2112 static HRESULT
internal_parseStream(saxreader
*This
, IStream
*stream
, BOOL vbInterface
)
2114 saxlocator
*locator
;
2121 hr
= IStream_Read(stream
, data
, sizeof(data
), &dataRead
);
2122 if(FAILED(hr
)) return hr
;
2124 hr
= SAXLocator_create(This
, &locator
, vbInterface
);
2125 if(FAILED(hr
)) return hr
;
2127 locator
->pParserCtxt
= xmlCreatePushParserCtxt(
2128 &locator
->saxreader
->sax
, locator
,
2129 data
, dataRead
, NULL
);
2130 if(!locator
->pParserCtxt
)
2132 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
2136 This
->isParsing
= TRUE
;
2138 if(dataRead
!= sizeof(data
))
2140 ret
= xmlParseChunk(locator
->pParserCtxt
, data
, 0, 1);
2141 hr
= ret
!=XML_ERR_OK
&& locator
->ret
==S_OK
? E_FAIL
: locator
->ret
;
2148 hr
= IStream_Read(stream
, data
, sizeof(data
), &dataRead
);
2149 if (FAILED(hr
)) break;
2151 ret
= xmlParseChunk(locator
->pParserCtxt
, data
, dataRead
, 0);
2152 hr
= ret
!=XML_ERR_OK
&& locator
->ret
==S_OK
? E_FAIL
: locator
->ret
;
2154 if (hr
!= S_OK
) break;
2156 if (dataRead
!= sizeof(data
))
2158 ret
= xmlParseChunk(locator
->pParserCtxt
, data
, 0, 1);
2159 hr
= ret
!=XML_ERR_OK
&& locator
->ret
==S_OK
? E_FAIL
: locator
->ret
;
2165 This
->isParsing
= FALSE
;
2167 xmlFreeParserCtxt(locator
->pParserCtxt
);
2168 locator
->pParserCtxt
= NULL
;
2169 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
2173 static HRESULT
internal_getEntityResolver(
2175 void *pEntityResolver
,
2178 FIXME("(%p)->(%p) stub\n", This
, pEntityResolver
);
2182 static HRESULT
internal_putEntityResolver(
2184 void *pEntityResolver
,
2187 FIXME("(%p)->(%p) stub\n", This
, pEntityResolver
);
2191 static HRESULT
internal_getContentHandler(
2193 void *pContentHandler
,
2196 TRACE("(%p)->(%p)\n", This
, pContentHandler
);
2197 if(pContentHandler
== NULL
)
2199 if((vbInterface
&& This
->vbcontentHandler
)
2200 || (!vbInterface
&& This
->contentHandler
))
2203 IVBSAXContentHandler_AddRef(This
->vbcontentHandler
);
2205 ISAXContentHandler_AddRef(This
->contentHandler
);
2207 if(vbInterface
) *(IVBSAXContentHandler
**)pContentHandler
=
2208 This
->vbcontentHandler
;
2209 else *(ISAXContentHandler
**)pContentHandler
= This
->contentHandler
;
2214 static HRESULT
internal_putContentHandler(
2216 void *contentHandler
,
2219 TRACE("(%p)->(%p)\n", This
, contentHandler
);
2223 IVBSAXContentHandler_AddRef((IVBSAXContentHandler
*)contentHandler
);
2225 ISAXContentHandler_AddRef((ISAXContentHandler
*)contentHandler
);
2227 if((vbInterface
&& This
->vbcontentHandler
)
2228 || (!vbInterface
&& This
->contentHandler
))
2231 IVBSAXContentHandler_Release(This
->vbcontentHandler
);
2233 ISAXContentHandler_Release(This
->contentHandler
);
2236 This
->vbcontentHandler
= contentHandler
;
2238 This
->contentHandler
= contentHandler
;
2243 static HRESULT
internal_getDTDHandler(
2248 FIXME("(%p)->(%p) stub\n", This
, pDTDHandler
);
2252 static HRESULT
internal_putDTDHandler(
2257 FIXME("(%p)->(%p) stub\n", This
, pDTDHandler
);
2261 static HRESULT
internal_getErrorHandler(
2263 void *pErrorHandler
,
2266 TRACE("(%p)->(%p)\n", This
, pErrorHandler
);
2267 if(pErrorHandler
== NULL
)
2270 if(vbInterface
&& This
->vberrorHandler
)
2271 IVBSAXErrorHandler_AddRef(This
->vberrorHandler
);
2272 else if(!vbInterface
&& This
->errorHandler
)
2273 ISAXErrorHandler_AddRef(This
->errorHandler
);
2276 *(IVBSAXErrorHandler
**)pErrorHandler
= This
->vberrorHandler
;
2278 *(ISAXErrorHandler
**)pErrorHandler
= This
->errorHandler
;
2284 static HRESULT
internal_putErrorHandler(
2289 TRACE("(%p)->(%p)\n", This
, errorHandler
);
2293 IVBSAXErrorHandler_AddRef((IVBSAXErrorHandler
*)errorHandler
);
2295 ISAXErrorHandler_AddRef((ISAXErrorHandler
*)errorHandler
);
2298 if(vbInterface
&& This
->vberrorHandler
)
2299 IVBSAXErrorHandler_Release(This
->vberrorHandler
);
2300 else if(!vbInterface
&& This
->errorHandler
)
2301 ISAXErrorHandler_Release(This
->errorHandler
);
2304 This
->vberrorHandler
= errorHandler
;
2306 This
->errorHandler
= errorHandler
;
2312 static HRESULT
internal_parse(
2319 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&varInput
));
2321 /* Dispose of the BSTRs in the pool from a prior run, if any. */
2322 free_bstr_pool(&This
->pool
);
2324 switch(V_VT(&varInput
))
2327 hr
= internal_parseBuffer(This
, (const char*)V_BSTR(&varInput
),
2328 SysStringByteLen(V_BSTR(&varInput
)), vbInterface
);
2330 case VT_ARRAY
|VT_UI1
: {
2332 LONG lBound
, uBound
;
2335 hr
= SafeArrayGetLBound(V_ARRAY(&varInput
), 1, &lBound
);
2336 if(hr
!= S_OK
) break;
2337 hr
= SafeArrayGetUBound(V_ARRAY(&varInput
), 1, &uBound
);
2338 if(hr
!= S_OK
) break;
2339 dataRead
= (uBound
-lBound
)*SafeArrayGetElemsize(V_ARRAY(&varInput
));
2340 hr
= SafeArrayAccessData(V_ARRAY(&varInput
), &pSAData
);
2341 if(hr
!= S_OK
) break;
2342 hr
= internal_parseBuffer(This
, pSAData
, dataRead
, vbInterface
);
2343 SafeArrayUnaccessData(V_ARRAY(&varInput
));
2348 IPersistStream
*persistStream
;
2349 IStream
*stream
= NULL
;
2350 IXMLDOMDocument
*xmlDoc
;
2352 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
2353 &IID_IXMLDOMDocument
, (void**)&xmlDoc
) == S_OK
)
2357 IXMLDOMDocument_get_xml(xmlDoc
, &bstrData
);
2358 hr
= internal_parseBuffer(This
, (const char*)bstrData
,
2359 SysStringByteLen(bstrData
), vbInterface
);
2360 IXMLDOMDocument_Release(xmlDoc
);
2361 SysFreeString(bstrData
);
2365 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
2366 &IID_IPersistStream
, (void**)&persistStream
) == S_OK
)
2368 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
2371 IPersistStream_Release(persistStream
);
2375 hr
= IPersistStream_Save(persistStream
, stream
, TRUE
);
2376 IPersistStream_Release(persistStream
);
2379 IStream_Release(stream
);
2383 if(stream
|| IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
2384 &IID_IStream
, (void**)&stream
) == S_OK
)
2386 hr
= internal_parseStream(This
, stream
, vbInterface
);
2387 IStream_Release(stream
);
2392 WARN("vt %d not implemented\n", V_VT(&varInput
));
2399 static HRESULT
internal_vbonDataAvailable(void *obj
, char *ptr
, DWORD len
)
2401 saxreader
*This
= obj
;
2403 return internal_parseBuffer(This
, ptr
, len
, TRUE
);
2406 static HRESULT
internal_onDataAvailable(void *obj
, char *ptr
, DWORD len
)
2408 saxreader
*This
= obj
;
2410 return internal_parseBuffer(This
, ptr
, len
, FALSE
);
2413 static HRESULT
internal_parseURL(
2421 TRACE("(%p)->(%s)\n", This
, debugstr_w(url
));
2423 if(vbInterface
) hr
= bind_url(url
, internal_vbonDataAvailable
, This
, &bsc
);
2424 else hr
= bind_url(url
, internal_onDataAvailable
, This
, &bsc
);
2429 return detach_bsc(bsc
);
2432 static HRESULT
internal_putProperty(
2438 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(prop
), debugstr_variant(&value
));
2440 if(!memcmp(prop
, PropertyDeclHandlerW
, sizeof(PropertyDeclHandlerW
)))
2442 if(This
->isParsing
) return E_FAIL
;
2444 switch (V_VT(&value
))
2449 if (This
->vbdeclHandler
)
2451 IVBSAXDeclHandler_Release(This
->vbdeclHandler
);
2452 This
->vbdeclHandler
= NULL
;
2456 if (This
->declHandler
)
2458 ISAXDeclHandler_Release(This
->declHandler
);
2459 This
->declHandler
= NULL
;
2463 if (V_UNKNOWN(&value
)) IUnknown_AddRef(V_UNKNOWN(&value
));
2465 if ((vbInterface
&& This
->vbdeclHandler
) ||
2466 (!vbInterface
&& This
->declHandler
))
2469 IVBSAXDeclHandler_Release(This
->vbdeclHandler
);
2471 ISAXDeclHandler_Release(This
->declHandler
);
2475 This
->vbdeclHandler
= (IVBSAXDeclHandler
*)V_UNKNOWN(&value
);
2477 This
->declHandler
= (ISAXDeclHandler
*)V_UNKNOWN(&value
);
2480 return E_INVALIDARG
;
2486 if(!memcmp(prop
, PropertyLexicalHandlerW
, sizeof(PropertyLexicalHandlerW
)))
2488 if(This
->isParsing
) return E_FAIL
;
2490 switch (V_VT(&value
))
2495 if (This
->vblexicalHandler
)
2497 IVBSAXLexicalHandler_Release(This
->vblexicalHandler
);
2498 This
->vblexicalHandler
= NULL
;
2502 if (This
->lexicalHandler
)
2504 ISAXLexicalHandler_Release(This
->lexicalHandler
);
2505 This
->lexicalHandler
= NULL
;
2509 if (V_UNKNOWN(&value
)) IUnknown_AddRef(V_UNKNOWN(&value
));
2511 if ((vbInterface
&& This
->vblexicalHandler
) ||
2512 (!vbInterface
&& This
->lexicalHandler
))
2515 IVBSAXLexicalHandler_Release(This
->vblexicalHandler
);
2517 ISAXLexicalHandler_Release(This
->lexicalHandler
);
2521 This
->vblexicalHandler
= (IVBSAXLexicalHandler
*)V_UNKNOWN(&value
);
2523 This
->lexicalHandler
= (ISAXLexicalHandler
*)V_UNKNOWN(&value
);
2526 return E_INVALIDARG
;
2532 if(!memcmp(prop
, PropertyMaxXMLSizeW
, sizeof(PropertyMaxXMLSizeW
)))
2534 if (V_VT(&value
) == VT_I4
&& V_I4(&value
) == 0) return S_OK
;
2535 FIXME("(%p)->(%s): max-xml-size unsupported\n", This
, debugstr_variant(&value
));
2539 if(!memcmp(prop
, PropertyMaxElementDepthW
, sizeof(PropertyMaxElementDepthW
)))
2541 if (V_VT(&value
) == VT_I4
&& V_I4(&value
) == 0) return S_OK
;
2542 FIXME("(%p)->(%s): max-element-depth unsupported\n", This
, debugstr_variant(&value
));
2546 FIXME("(%p)->(%s:%s): unsupported property\n", This
, debugstr_w(prop
), debugstr_variant(&value
));
2548 if(!memcmp(prop
, PropertyCharsetW
, sizeof(PropertyCharsetW
)))
2551 if(!memcmp(prop
, PropertyDomNodeW
, sizeof(PropertyDomNodeW
)))
2554 if(!memcmp(prop
, PropertyInputSourceW
, sizeof(PropertyInputSourceW
)))
2557 if(!memcmp(prop
, PropertySchemaDeclHandlerW
, sizeof(PropertySchemaDeclHandlerW
)))
2560 if(!memcmp(prop
, PropertyXMLDeclEncodingW
, sizeof(PropertyXMLDeclEncodingW
)))
2563 if(!memcmp(prop
, PropertyXMLDeclStandaloneW
, sizeof(PropertyXMLDeclStandaloneW
)))
2566 if(!memcmp(prop
, PropertyXMLDeclVersionW
, sizeof(PropertyXMLDeclVersionW
)))
2569 return E_INVALIDARG
;
2572 static HRESULT
internal_getProperty(const saxreader
* This
, const WCHAR
*prop
, VARIANT
*value
, BOOL vb
)
2574 TRACE("(%p)->(%s)\n", This
, debugstr_w(prop
));
2576 if (!value
) return E_POINTER
;
2578 if (!memcmp(PropertyLexicalHandlerW
, prop
, sizeof(PropertyLexicalHandlerW
)))
2580 V_VT(value
) = VT_UNKNOWN
;
2581 V_UNKNOWN(value
) = vb
? (IUnknown
*)This
->vblexicalHandler
: (IUnknown
*)This
->lexicalHandler
;
2582 if (V_UNKNOWN(value
)) IUnknown_AddRef(V_UNKNOWN(value
));
2586 if (!memcmp(PropertyDeclHandlerW
, prop
, sizeof(PropertyDeclHandlerW
)))
2588 V_VT(value
) = VT_UNKNOWN
;
2589 V_UNKNOWN(value
) = vb
? (IUnknown
*)This
->vbdeclHandler
: (IUnknown
*)This
->declHandler
;
2590 if (V_UNKNOWN(value
)) IUnknown_AddRef(V_UNKNOWN(value
));
2594 FIXME("(%p)->(%s) unsupported property\n", This
, debugstr_w(prop
));
2599 /*** IVBSAXXMLReader interface ***/
2600 /*** IUnknown methods ***/
2601 static HRESULT WINAPI
saxxmlreader_QueryInterface(IVBSAXXMLReader
* iface
, REFIID riid
, void **ppvObject
)
2603 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2605 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
2609 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
2610 IsEqualGUID( riid
, &IID_IDispatch
) ||
2611 IsEqualGUID( riid
, &IID_IVBSAXXMLReader
))
2615 else if( IsEqualGUID( riid
, &IID_ISAXXMLReader
))
2617 *ppvObject
= &This
->ISAXXMLReader_iface
;
2619 else if (dispex_query_interface(&This
->dispex
, riid
, ppvObject
))
2621 return *ppvObject
? S_OK
: E_NOINTERFACE
;
2625 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
2626 return E_NOINTERFACE
;
2629 IVBSAXXMLReader_AddRef( iface
);
2634 static ULONG WINAPI
saxxmlreader_AddRef(IVBSAXXMLReader
* iface
)
2636 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2637 TRACE("%p\n", This
);
2638 return InterlockedIncrement( &This
->ref
);
2641 static ULONG WINAPI
saxxmlreader_Release(
2642 IVBSAXXMLReader
* iface
)
2644 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2647 TRACE("%p\n", This
);
2649 ref
= InterlockedDecrement( &This
->ref
);
2652 if(This
->contentHandler
)
2653 ISAXContentHandler_Release(This
->contentHandler
);
2655 if(This
->vbcontentHandler
)
2656 IVBSAXContentHandler_Release(This
->vbcontentHandler
);
2658 if(This
->errorHandler
)
2659 ISAXErrorHandler_Release(This
->errorHandler
);
2661 if(This
->vberrorHandler
)
2662 IVBSAXErrorHandler_Release(This
->vberrorHandler
);
2664 if(This
->lexicalHandler
)
2665 ISAXLexicalHandler_Release(This
->lexicalHandler
);
2667 if(This
->vblexicalHandler
)
2668 IVBSAXLexicalHandler_Release(This
->vblexicalHandler
);
2670 if(This
->declHandler
)
2671 ISAXDeclHandler_Release(This
->declHandler
);
2673 if(This
->vbdeclHandler
)
2674 IVBSAXDeclHandler_Release(This
->vbdeclHandler
);
2676 free_bstr_pool(&This
->pool
);
2678 release_dispex(&This
->dispex
);
2685 static HRESULT WINAPI
saxxmlreader_GetTypeInfoCount( IVBSAXXMLReader
*iface
, UINT
* pctinfo
)
2687 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2688 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
2691 static HRESULT WINAPI
saxxmlreader_GetTypeInfo(
2692 IVBSAXXMLReader
*iface
,
2693 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2695 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2696 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
,
2697 iTInfo
, lcid
, ppTInfo
);
2700 static HRESULT WINAPI
saxxmlreader_GetIDsOfNames(
2701 IVBSAXXMLReader
*iface
,
2703 LPOLESTR
* rgszNames
,
2708 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2709 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
,
2710 riid
, rgszNames
, cNames
, lcid
, rgDispId
);
2713 static HRESULT WINAPI
saxxmlreader_Invoke(
2714 IVBSAXXMLReader
*iface
,
2715 DISPID dispIdMember
,
2719 DISPPARAMS
* pDispParams
,
2720 VARIANT
* pVarResult
,
2721 EXCEPINFO
* pExcepInfo
,
2724 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2725 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
,
2726 dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2729 /*** IVBSAXXMLReader methods ***/
2730 static HRESULT WINAPI
saxxmlreader_getFeature(
2731 IVBSAXXMLReader
* iface
,
2732 const WCHAR
*feature
,
2733 VARIANT_BOOL
*value
)
2735 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2737 if (!strcmpW(FeatureNamespacesW
, feature
))
2738 return get_feature_value(This
, Namespaces
, value
);
2740 FIXME("(%p)->(%s %p) stub\n", This
, debugstr_w(feature
), value
);
2744 static HRESULT WINAPI
saxxmlreader_putFeature(
2745 IVBSAXXMLReader
* iface
,
2746 const WCHAR
*feature
,
2749 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2751 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(feature
), value
);
2753 if (!strcmpW(FeatureExternalGeneralEntitiesW
, feature
) && value
== VARIANT_FALSE
)
2754 return set_feature_value(This
, ExternalGeneralEntities
, value
);
2756 if (!strcmpW(FeatureExternalParameterEntitiesW
, feature
) && value
== VARIANT_FALSE
)
2757 return set_feature_value(This
, ExternalParameterEntities
, value
);
2759 if (!strcmpW(FeatureLexicalHandlerParEntitiesW
, feature
))
2761 FIXME("(%p)->(%s %x) stub\n", This
, debugstr_w(feature
), value
);
2762 return set_feature_value(This
, LexicalHandlerParEntities
, value
);
2765 if (!strcmpW(FeatureProhibitDTDW
, feature
))
2767 FIXME("(%p)->(%s %x) stub\n", This
, debugstr_w(feature
), value
);
2768 return set_feature_value(This
, ProhibitDTD
, value
);
2771 if (!strcmpW(FeatureNamespacesW
, feature
) && value
== VARIANT_TRUE
)
2772 return set_feature_value(This
, Namespaces
, value
);
2774 FIXME("(%p)->(%s %x) stub\n", This
, debugstr_w(feature
), value
);
2778 static HRESULT WINAPI
saxxmlreader_getProperty(
2779 IVBSAXXMLReader
* iface
,
2783 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2784 return internal_getProperty(This
, prop
, value
, TRUE
);
2787 static HRESULT WINAPI
saxxmlreader_putProperty(
2788 IVBSAXXMLReader
* iface
,
2792 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2793 return internal_putProperty(This
, pProp
, value
, TRUE
);
2796 static HRESULT WINAPI
saxxmlreader_get_entityResolver(
2797 IVBSAXXMLReader
* iface
,
2798 IVBSAXEntityResolver
**pEntityResolver
)
2800 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2801 return internal_getEntityResolver(This
, pEntityResolver
, TRUE
);
2804 static HRESULT WINAPI
saxxmlreader_put_entityResolver(
2805 IVBSAXXMLReader
* iface
,
2806 IVBSAXEntityResolver
*pEntityResolver
)
2808 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2809 return internal_putEntityResolver(This
, pEntityResolver
, TRUE
);
2812 static HRESULT WINAPI
saxxmlreader_get_contentHandler(
2813 IVBSAXXMLReader
* iface
,
2814 IVBSAXContentHandler
**ppContentHandler
)
2816 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2817 return internal_getContentHandler(This
, ppContentHandler
, TRUE
);
2820 static HRESULT WINAPI
saxxmlreader_put_contentHandler(
2821 IVBSAXXMLReader
* iface
,
2822 IVBSAXContentHandler
*contentHandler
)
2824 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2825 return internal_putContentHandler(This
, contentHandler
, TRUE
);
2828 static HRESULT WINAPI
saxxmlreader_get_dtdHandler(
2829 IVBSAXXMLReader
* iface
,
2830 IVBSAXDTDHandler
**pDTDHandler
)
2832 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2833 return internal_getDTDHandler(This
, pDTDHandler
, TRUE
);
2836 static HRESULT WINAPI
saxxmlreader_put_dtdHandler(
2837 IVBSAXXMLReader
* iface
,
2838 IVBSAXDTDHandler
*pDTDHandler
)
2840 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2841 return internal_putDTDHandler(This
, pDTDHandler
, TRUE
);
2844 static HRESULT WINAPI
saxxmlreader_get_errorHandler(
2845 IVBSAXXMLReader
* iface
,
2846 IVBSAXErrorHandler
**pErrorHandler
)
2848 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2849 return internal_getErrorHandler(This
, pErrorHandler
, TRUE
);
2852 static HRESULT WINAPI
saxxmlreader_put_errorHandler(
2853 IVBSAXXMLReader
* iface
,
2854 IVBSAXErrorHandler
*errorHandler
)
2856 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2857 return internal_putErrorHandler(This
, errorHandler
, TRUE
);
2860 static HRESULT WINAPI
saxxmlreader_get_baseURL(
2861 IVBSAXXMLReader
* iface
,
2862 const WCHAR
**pBaseUrl
)
2864 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2866 FIXME("(%p)->(%p) stub\n", This
, pBaseUrl
);
2870 static HRESULT WINAPI
saxxmlreader_put_baseURL(
2871 IVBSAXXMLReader
* iface
,
2872 const WCHAR
*pBaseUrl
)
2874 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2876 FIXME("(%p)->(%s) stub\n", This
, debugstr_w(pBaseUrl
));
2880 static HRESULT WINAPI
saxxmlreader_get_secureBaseURL(
2881 IVBSAXXMLReader
* iface
,
2882 const WCHAR
**pSecureBaseUrl
)
2884 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2886 FIXME("(%p)->(%p) stub\n", This
, pSecureBaseUrl
);
2891 static HRESULT WINAPI
saxxmlreader_put_secureBaseURL(
2892 IVBSAXXMLReader
* iface
,
2893 const WCHAR
*secureBaseUrl
)
2895 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2897 FIXME("(%p)->(%s) stub\n", This
, debugstr_w(secureBaseUrl
));
2901 static HRESULT WINAPI
saxxmlreader_parse(
2902 IVBSAXXMLReader
* iface
,
2905 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2906 return internal_parse(This
, varInput
, TRUE
);
2909 static HRESULT WINAPI
saxxmlreader_parseURL(
2910 IVBSAXXMLReader
* iface
,
2913 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2914 return internal_parseURL(This
, url
, TRUE
);
2917 static const struct IVBSAXXMLReaderVtbl VBSAXXMLReaderVtbl
=
2919 saxxmlreader_QueryInterface
,
2920 saxxmlreader_AddRef
,
2921 saxxmlreader_Release
,
2922 saxxmlreader_GetTypeInfoCount
,
2923 saxxmlreader_GetTypeInfo
,
2924 saxxmlreader_GetIDsOfNames
,
2925 saxxmlreader_Invoke
,
2926 saxxmlreader_getFeature
,
2927 saxxmlreader_putFeature
,
2928 saxxmlreader_getProperty
,
2929 saxxmlreader_putProperty
,
2930 saxxmlreader_get_entityResolver
,
2931 saxxmlreader_put_entityResolver
,
2932 saxxmlreader_get_contentHandler
,
2933 saxxmlreader_put_contentHandler
,
2934 saxxmlreader_get_dtdHandler
,
2935 saxxmlreader_put_dtdHandler
,
2936 saxxmlreader_get_errorHandler
,
2937 saxxmlreader_put_errorHandler
,
2938 saxxmlreader_get_baseURL
,
2939 saxxmlreader_put_baseURL
,
2940 saxxmlreader_get_secureBaseURL
,
2941 saxxmlreader_put_secureBaseURL
,
2943 saxxmlreader_parseURL
2946 /*** ISAXXMLReader interface ***/
2947 /*** IUnknown methods ***/
2948 static HRESULT WINAPI
isaxxmlreader_QueryInterface(ISAXXMLReader
* iface
, REFIID riid
, void **ppvObject
)
2950 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2951 return saxxmlreader_QueryInterface(&This
->IVBSAXXMLReader_iface
, riid
, ppvObject
);
2954 static ULONG WINAPI
isaxxmlreader_AddRef(ISAXXMLReader
* iface
)
2956 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2957 return saxxmlreader_AddRef(&This
->IVBSAXXMLReader_iface
);
2960 static ULONG WINAPI
isaxxmlreader_Release(ISAXXMLReader
* iface
)
2962 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2963 return saxxmlreader_Release(&This
->IVBSAXXMLReader_iface
);
2966 /*** ISAXXMLReader methods ***/
2967 static HRESULT WINAPI
isaxxmlreader_getFeature(
2968 ISAXXMLReader
* iface
,
2969 const WCHAR
*pFeature
,
2970 VARIANT_BOOL
*pValue
)
2972 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2973 return IVBSAXXMLReader_getFeature(&This
->IVBSAXXMLReader_iface
, pFeature
, pValue
);
2976 static HRESULT WINAPI
isaxxmlreader_putFeature(
2977 ISAXXMLReader
* iface
,
2978 const WCHAR
*pFeature
,
2979 VARIANT_BOOL vfValue
)
2981 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2982 return IVBSAXXMLReader_putFeature(&This
->IVBSAXXMLReader_iface
, pFeature
, vfValue
);
2985 static HRESULT WINAPI
isaxxmlreader_getProperty(
2986 ISAXXMLReader
* iface
,
2990 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2991 return internal_getProperty(This
, prop
, value
, FALSE
);
2994 static HRESULT WINAPI
isaxxmlreader_putProperty(
2995 ISAXXMLReader
* iface
,
2999 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3000 return internal_putProperty(This
, pProp
, value
, FALSE
);
3003 static HRESULT WINAPI
isaxxmlreader_getEntityResolver(
3004 ISAXXMLReader
* iface
,
3005 ISAXEntityResolver
**ppEntityResolver
)
3007 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3008 return internal_getEntityResolver(This
, ppEntityResolver
, FALSE
);
3011 static HRESULT WINAPI
isaxxmlreader_putEntityResolver(
3012 ISAXXMLReader
* iface
,
3013 ISAXEntityResolver
*pEntityResolver
)
3015 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3016 return internal_putEntityResolver(This
, pEntityResolver
, FALSE
);
3019 static HRESULT WINAPI
isaxxmlreader_getContentHandler(
3020 ISAXXMLReader
* iface
,
3021 ISAXContentHandler
**pContentHandler
)
3023 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3024 return internal_getContentHandler(This
, pContentHandler
, FALSE
);
3027 static HRESULT WINAPI
isaxxmlreader_putContentHandler(
3028 ISAXXMLReader
* iface
,
3029 ISAXContentHandler
*contentHandler
)
3031 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3032 return internal_putContentHandler(This
, contentHandler
, FALSE
);
3035 static HRESULT WINAPI
isaxxmlreader_getDTDHandler(
3036 ISAXXMLReader
* iface
,
3037 ISAXDTDHandler
**pDTDHandler
)
3039 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3040 return internal_getDTDHandler(This
, pDTDHandler
, FALSE
);
3043 static HRESULT WINAPI
isaxxmlreader_putDTDHandler(
3044 ISAXXMLReader
* iface
,
3045 ISAXDTDHandler
*pDTDHandler
)
3047 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3048 return internal_putDTDHandler(This
, pDTDHandler
, FALSE
);
3051 static HRESULT WINAPI
isaxxmlreader_getErrorHandler(
3052 ISAXXMLReader
* iface
,
3053 ISAXErrorHandler
**pErrorHandler
)
3055 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3056 return internal_getErrorHandler(This
, pErrorHandler
, FALSE
);
3059 static HRESULT WINAPI
isaxxmlreader_putErrorHandler(
3060 ISAXXMLReader
* iface
,
3061 ISAXErrorHandler
*errorHandler
)
3063 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3064 return internal_putErrorHandler(This
, errorHandler
, FALSE
);
3067 static HRESULT WINAPI
isaxxmlreader_getBaseURL(
3068 ISAXXMLReader
* iface
,
3069 const WCHAR
**pBaseUrl
)
3071 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3072 return IVBSAXXMLReader_get_baseURL(&This
->IVBSAXXMLReader_iface
, pBaseUrl
);
3075 static HRESULT WINAPI
isaxxmlreader_putBaseURL(
3076 ISAXXMLReader
* iface
,
3077 const WCHAR
*pBaseUrl
)
3079 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3080 return IVBSAXXMLReader_put_baseURL(&This
->IVBSAXXMLReader_iface
, pBaseUrl
);
3083 static HRESULT WINAPI
isaxxmlreader_getSecureBaseURL(
3084 ISAXXMLReader
* iface
,
3085 const WCHAR
**pSecureBaseUrl
)
3087 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3088 return IVBSAXXMLReader_get_secureBaseURL(&This
->IVBSAXXMLReader_iface
, pSecureBaseUrl
);
3091 static HRESULT WINAPI
isaxxmlreader_putSecureBaseURL(
3092 ISAXXMLReader
* iface
,
3093 const WCHAR
*secureBaseUrl
)
3095 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3096 return IVBSAXXMLReader_put_secureBaseURL(&This
->IVBSAXXMLReader_iface
, secureBaseUrl
);
3099 static HRESULT WINAPI
isaxxmlreader_parse(
3100 ISAXXMLReader
* iface
,
3103 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3104 return internal_parse(This
, varInput
, FALSE
);
3107 static HRESULT WINAPI
isaxxmlreader_parseURL(
3108 ISAXXMLReader
* iface
,
3111 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3112 return internal_parseURL(This
, url
, FALSE
);
3115 static const struct ISAXXMLReaderVtbl SAXXMLReaderVtbl
=
3117 isaxxmlreader_QueryInterface
,
3118 isaxxmlreader_AddRef
,
3119 isaxxmlreader_Release
,
3120 isaxxmlreader_getFeature
,
3121 isaxxmlreader_putFeature
,
3122 isaxxmlreader_getProperty
,
3123 isaxxmlreader_putProperty
,
3124 isaxxmlreader_getEntityResolver
,
3125 isaxxmlreader_putEntityResolver
,
3126 isaxxmlreader_getContentHandler
,
3127 isaxxmlreader_putContentHandler
,
3128 isaxxmlreader_getDTDHandler
,
3129 isaxxmlreader_putDTDHandler
,
3130 isaxxmlreader_getErrorHandler
,
3131 isaxxmlreader_putErrorHandler
,
3132 isaxxmlreader_getBaseURL
,
3133 isaxxmlreader_putBaseURL
,
3134 isaxxmlreader_getSecureBaseURL
,
3135 isaxxmlreader_putSecureBaseURL
,
3136 isaxxmlreader_parse
,
3137 isaxxmlreader_parseURL
3140 static const tid_t saxreader_iface_tids
[] = {
3141 IVBSAXXMLReader_tid
,
3144 static dispex_static_data_t saxreader_dispex
= {
3146 IVBSAXXMLReader_tid
,
3148 saxreader_iface_tids
3151 HRESULT
SAXXMLReader_create(MSXML_VERSION version
, IUnknown
*outer
, LPVOID
*ppObj
)
3155 TRACE("(%p, %p)\n", outer
, ppObj
);
3157 reader
= heap_alloc( sizeof (*reader
) );
3159 return E_OUTOFMEMORY
;
3161 reader
->IVBSAXXMLReader_iface
.lpVtbl
= &VBSAXXMLReaderVtbl
;
3162 reader
->ISAXXMLReader_iface
.lpVtbl
= &SAXXMLReaderVtbl
;
3164 reader
->contentHandler
= NULL
;
3165 reader
->vbcontentHandler
= NULL
;
3166 reader
->errorHandler
= NULL
;
3167 reader
->vberrorHandler
= NULL
;
3168 reader
->lexicalHandler
= NULL
;
3169 reader
->vblexicalHandler
= NULL
;
3170 reader
->declHandler
= NULL
;
3171 reader
->vbdeclHandler
= NULL
;
3172 reader
->isParsing
= FALSE
;
3173 reader
->pool
.pool
= NULL
;
3174 reader
->pool
.index
= 0;
3175 reader
->pool
.len
= 0;
3176 reader
->features
= Namespaces
;
3177 reader
->version
= version
;
3179 init_dispex(&reader
->dispex
, (IUnknown
*)&reader
->IVBSAXXMLReader_iface
, &saxreader_dispex
);
3181 memset(&reader
->sax
, 0, sizeof(xmlSAXHandler
));
3182 reader
->sax
.initialized
= XML_SAX2_MAGIC
;
3183 reader
->sax
.startDocument
= libxmlStartDocument
;
3184 reader
->sax
.endDocument
= libxmlEndDocument
;
3185 reader
->sax
.startElementNs
= libxmlStartElementNS
;
3186 reader
->sax
.endElementNs
= libxmlEndElementNS
;
3187 reader
->sax
.characters
= libxmlCharacters
;
3188 reader
->sax
.setDocumentLocator
= libxmlSetDocumentLocator
;
3189 reader
->sax
.comment
= libxmlComment
;
3190 reader
->sax
.error
= libxmlFatalError
;
3191 reader
->sax
.fatalError
= libxmlFatalError
;
3192 reader
->sax
.cdataBlock
= libxmlCDataBlock
;
3194 *ppObj
= &reader
->IVBSAXXMLReader_iface
;
3196 TRACE("returning iface %p\n", *ppObj
);
3203 HRESULT
SAXXMLReader_create(MSXML_VERSION version
, IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
3205 MESSAGE("This program tried to use a SAX XML Reader object, but\n"
3206 "libxml2 support was not present at compile time.\n");