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 const WCHAR FeatureNamespacesW
[] = {
225 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/','f','e','a','t','u','r','e','s',
226 '/','n','a','m','e','s','p','a','c','e','s',0
229 static inline HRESULT
set_feature_value(saxreader
*reader
, enum ReaderFeatures feature
, VARIANT_BOOL value
)
231 if (value
== VARIANT_TRUE
)
232 reader
->features
|= feature
;
234 reader
->features
&= ~feature
;
239 static inline HRESULT
get_feature_value(const saxreader
*reader
, enum ReaderFeatures feature
, VARIANT_BOOL
*value
)
241 *value
= reader
->features
& feature
? VARIANT_TRUE
: VARIANT_FALSE
;
245 static inline BOOL
has_content_handler(const saxlocator
*locator
)
247 return (locator
->vbInterface
&& locator
->saxreader
->vbcontentHandler
) ||
248 (!locator
->vbInterface
&& locator
->saxreader
->contentHandler
);
251 static inline BOOL
has_error_handler(const saxlocator
*locator
)
253 return (locator
->vbInterface
&& locator
->saxreader
->vberrorHandler
) ||
254 (!locator
->vbInterface
&& locator
->saxreader
->errorHandler
);
257 static HRESULT
namespacePush(saxlocator
*locator
, int ns
)
259 if(locator
->nsStackLast
>=locator
->nsStackSize
)
263 new_stack
= HeapReAlloc(GetProcessHeap(), 0,
264 locator
->nsStack
, sizeof(int)*locator
->nsStackSize
*2);
265 if(!new_stack
) return E_OUTOFMEMORY
;
266 locator
->nsStack
= new_stack
;
267 locator
->nsStackSize
*= 2;
269 locator
->nsStack
[locator
->nsStackLast
++] = ns
;
274 static int namespacePop(saxlocator
*locator
)
276 if(locator
->nsStackLast
== 0) return 0;
277 return locator
->nsStack
[--locator
->nsStackLast
];
280 static BOOL
bstr_pool_insert(struct bstrpool
*pool
, BSTR pool_entry
)
284 pool
->pool
= HeapAlloc(GetProcessHeap(), 0, 16 * sizeof(*pool
->pool
));
291 else if (pool
->index
== pool
->len
)
293 BSTR
*realloc
= HeapReAlloc(GetProcessHeap(), 0, pool
->pool
, pool
->len
* 2 * sizeof(*realloc
));
298 pool
->pool
= realloc
;
302 pool
->pool
[pool
->index
++] = pool_entry
;
306 static void free_bstr_pool(struct bstrpool
*pool
)
310 for (i
= 0; i
< pool
->index
; i
++)
311 SysFreeString(pool
->pool
[i
]);
313 HeapFree(GetProcessHeap(), 0, pool
->pool
);
316 pool
->index
= pool
->len
= 0;
319 static BSTR
bstr_from_xmlCharN(const xmlChar
*buf
, int len
)
327 dLen
= MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)buf
, len
, NULL
, 0);
328 if(len
!= -1) dLen
++;
329 bstr
= SysAllocStringLen(NULL
, dLen
-1);
332 MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)buf
, len
, bstr
, dLen
);
333 if(len
!= -1) bstr
[dLen
-1] = '\0';
338 static BSTR
QName_from_xmlChar(const xmlChar
*prefix
, const xmlChar
*name
)
343 if(!name
) return NULL
;
345 if(!prefix
|| !*prefix
)
346 return bstr_from_xmlChar(name
);
348 qname
= xmlBuildQName(name
, prefix
, NULL
, 0);
349 bstr
= bstr_from_xmlChar(qname
);
355 static BSTR
pooled_bstr_from_xmlChar(struct bstrpool
*pool
, const xmlChar
*buf
)
357 BSTR pool_entry
= bstr_from_xmlChar(buf
);
359 if (pool_entry
&& !bstr_pool_insert(pool
, pool_entry
))
361 SysFreeString(pool_entry
);
368 static BSTR
pooled_bstr_from_xmlCharN(struct bstrpool
*pool
, const xmlChar
*buf
, int len
)
370 BSTR pool_entry
= bstr_from_xmlCharN(buf
, len
);
372 if (pool_entry
&& !bstr_pool_insert(pool
, pool_entry
))
374 SysFreeString(pool_entry
);
381 static BSTR
pooled_QName_from_xmlChar(struct bstrpool
*pool
, const xmlChar
*prefix
, const xmlChar
*name
)
383 BSTR pool_entry
= QName_from_xmlChar(prefix
, name
);
385 if (pool_entry
&& !bstr_pool_insert(pool
, pool_entry
))
387 SysFreeString(pool_entry
);
394 static void format_error_message_from_id(saxlocator
*This
, HRESULT hr
)
396 xmlStopParser(This
->pParserCtxt
);
399 if(has_error_handler(This
))
402 if(!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
,
403 NULL
, hr
, 0, msg
, sizeof(msg
), NULL
))
405 FIXME("MSXML errors not yet supported.\n");
409 if(This
->vbInterface
)
411 BSTR bstrMsg
= SysAllocString(msg
);
412 IVBSAXErrorHandler_fatalError(This
->saxreader
->vberrorHandler
,
413 &This
->IVBSAXLocator_iface
, &bstrMsg
, hr
);
414 SysFreeString(bstrMsg
);
417 ISAXErrorHandler_fatalError(This
->saxreader
->errorHandler
,
418 &This
->ISAXLocator_iface
, msg
, hr
);
422 static void update_position(saxlocator
*This
, xmlChar
*end
)
424 if(This
->lastCur
== NULL
)
426 This
->lastCur
= (xmlChar
*)This
->pParserCtxt
->input
->base
;
428 This
->realColumn
= 1;
430 else if(This
->lastCur
< This
->pParserCtxt
->input
->base
)
432 This
->lastCur
= (xmlChar
*)This
->pParserCtxt
->input
->base
;
434 This
->realColumn
= 1;
437 if(This
->pParserCtxt
->input
->cur
<This
->lastCur
)
439 This
->lastCur
= (xmlChar
*)This
->pParserCtxt
->input
->base
;
441 This
->realColumn
= 1;
444 if(!end
) end
= (xmlChar
*)This
->pParserCtxt
->input
->cur
;
446 while(This
->lastCur
< end
)
448 if(*(This
->lastCur
) == '\n')
451 This
->realColumn
= 1;
453 else if(*(This
->lastCur
) == '\r' &&
454 (This
->lastCur
==This
->pParserCtxt
->input
->end
||
455 *(This
->lastCur
+1)!='\n'))
458 This
->realColumn
= 1;
460 else This
->realColumn
++;
464 /* Count multibyte UTF8 encoded characters once */
465 while((*(This
->lastCur
)&0xC0) == 0x80) This
->lastCur
++;
468 This
->line
= This
->realLine
;
469 This
->column
= This
->realColumn
;
472 /*** IVBSAXAttributes interface ***/
473 /*** IUnknown methods ***/
474 static HRESULT WINAPI
ivbsaxattributes_QueryInterface(
475 IVBSAXAttributes
* iface
,
479 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
481 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
485 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
486 IsEqualGUID(riid
, &IID_IDispatch
) ||
487 IsEqualGUID(riid
, &IID_IVBSAXAttributes
))
493 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
494 return E_NOINTERFACE
;
497 IVBSAXAttributes_AddRef(iface
);
502 static ULONG WINAPI
ivbsaxattributes_AddRef(IVBSAXAttributes
* iface
)
504 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
505 return ISAXAttributes_AddRef(&This
->ISAXAttributes_iface
);
508 static ULONG WINAPI
ivbsaxattributes_Release(IVBSAXAttributes
* iface
)
510 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
511 return ISAXAttributes_Release(&This
->ISAXAttributes_iface
);
514 /*** IDispatch methods ***/
515 static HRESULT WINAPI
ivbsaxattributes_GetTypeInfoCount( IVBSAXAttributes
*iface
, UINT
* pctinfo
)
517 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
519 TRACE("(%p)->(%p)\n", This
, pctinfo
);
526 static HRESULT WINAPI
ivbsaxattributes_GetTypeInfo(
527 IVBSAXAttributes
*iface
,
528 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
530 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
533 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
535 hr
= get_typeinfo(IVBSAXAttributes_tid
, ppTInfo
);
540 static HRESULT WINAPI
ivbsaxattributes_GetIDsOfNames(
541 IVBSAXAttributes
*iface
,
548 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
552 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
555 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
558 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
561 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
562 ITypeInfo_Release(typeinfo
);
568 static HRESULT WINAPI
ivbsaxattributes_Invoke(
569 IVBSAXAttributes
*iface
,
574 DISPPARAMS
* pDispParams
,
576 EXCEPINFO
* pExcepInfo
,
579 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
583 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
584 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
586 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
589 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IVBSAXAttributes_iface
, dispIdMember
, wFlags
,
590 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
591 ITypeInfo_Release(typeinfo
);
597 /*** IVBSAXAttributes methods ***/
598 static HRESULT WINAPI
ivbsaxattributes_get_length(
599 IVBSAXAttributes
* iface
,
602 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
603 return ISAXAttributes_getLength(&This
->ISAXAttributes_iface
, nLength
);
606 static HRESULT WINAPI
ivbsaxattributes_getURI(
607 IVBSAXAttributes
* iface
,
612 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
613 return ISAXAttributes_getURI(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)uri
, &len
);
616 static HRESULT WINAPI
ivbsaxattributes_getLocalName(
617 IVBSAXAttributes
* iface
,
622 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
623 return ISAXAttributes_getLocalName(&This
->ISAXAttributes_iface
, nIndex
,
624 (const WCHAR
**)localName
, &len
);
627 static HRESULT WINAPI
ivbsaxattributes_getQName(
628 IVBSAXAttributes
* iface
,
633 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
634 return ISAXAttributes_getQName(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)QName
, &len
);
637 static HRESULT WINAPI
ivbsaxattributes_getIndexFromName(
638 IVBSAXAttributes
* iface
,
643 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
644 return ISAXAttributes_getIndexFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
645 localName
, SysStringLen(localName
), index
);
648 static HRESULT WINAPI
ivbsaxattributes_getIndexFromQName(
649 IVBSAXAttributes
* iface
,
653 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
654 return ISAXAttributes_getIndexFromQName(&This
->ISAXAttributes_iface
, QName
,
655 SysStringLen(QName
), index
);
658 static HRESULT WINAPI
ivbsaxattributes_getType(
659 IVBSAXAttributes
* iface
,
664 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
665 return ISAXAttributes_getType(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)type
, &len
);
668 static HRESULT WINAPI
ivbsaxattributes_getTypeFromName(
669 IVBSAXAttributes
* iface
,
675 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
676 return ISAXAttributes_getTypeFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
677 localName
, SysStringLen(localName
), (const WCHAR
**)type
, &len
);
680 static HRESULT WINAPI
ivbsaxattributes_getTypeFromQName(
681 IVBSAXAttributes
* iface
,
686 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
687 return ISAXAttributes_getTypeFromQName(&This
->ISAXAttributes_iface
, QName
, SysStringLen(QName
),
688 (const WCHAR
**)type
, &len
);
691 static HRESULT WINAPI
ivbsaxattributes_getValue(
692 IVBSAXAttributes
* iface
,
697 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
698 return ISAXAttributes_getValue(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)value
, &len
);
701 static HRESULT WINAPI
ivbsaxattributes_getValueFromName(
702 IVBSAXAttributes
* iface
,
708 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
709 return ISAXAttributes_getValueFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
710 localName
, SysStringLen(localName
), (const WCHAR
**)value
, &len
);
713 static HRESULT WINAPI
ivbsaxattributes_getValueFromQName(
714 IVBSAXAttributes
* iface
,
719 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
720 return ISAXAttributes_getValueFromQName(&This
->ISAXAttributes_iface
, QName
,
721 SysStringLen(QName
), (const WCHAR
**)value
, &len
);
724 static const struct IVBSAXAttributesVtbl ivbsaxattributes_vtbl
=
726 ivbsaxattributes_QueryInterface
,
727 ivbsaxattributes_AddRef
,
728 ivbsaxattributes_Release
,
729 ivbsaxattributes_GetTypeInfoCount
,
730 ivbsaxattributes_GetTypeInfo
,
731 ivbsaxattributes_GetIDsOfNames
,
732 ivbsaxattributes_Invoke
,
733 ivbsaxattributes_get_length
,
734 ivbsaxattributes_getURI
,
735 ivbsaxattributes_getLocalName
,
736 ivbsaxattributes_getQName
,
737 ivbsaxattributes_getIndexFromName
,
738 ivbsaxattributes_getIndexFromQName
,
739 ivbsaxattributes_getType
,
740 ivbsaxattributes_getTypeFromName
,
741 ivbsaxattributes_getTypeFromQName
,
742 ivbsaxattributes_getValue
,
743 ivbsaxattributes_getValueFromName
,
744 ivbsaxattributes_getValueFromQName
747 /*** ISAXAttributes interface ***/
748 /*** IUnknown methods ***/
749 static HRESULT WINAPI
isaxattributes_QueryInterface(
750 ISAXAttributes
* iface
,
754 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
756 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
760 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
761 IsEqualGUID(riid
, &IID_ISAXAttributes
))
767 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
768 return E_NOINTERFACE
;
771 ISAXAttributes_AddRef(iface
);
776 static ULONG WINAPI
isaxattributes_AddRef(ISAXAttributes
* iface
)
778 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
780 return InterlockedIncrement(&This
->ref
);
783 static ULONG WINAPI
isaxattributes_Release(ISAXAttributes
* iface
)
785 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
790 ref
= InterlockedDecrement(&This
->ref
);
794 for(index
=0; index
<This
->nb_attributes
; index
++)
796 SysFreeString(This
->szLocalname
[index
]);
797 SysFreeString(This
->szURI
[index
]);
798 SysFreeString(This
->szValue
[index
]);
799 SysFreeString(This
->szQName
[index
]);
802 heap_free(This
->szLocalname
);
803 heap_free(This
->szURI
);
804 heap_free(This
->szValue
);
805 heap_free(This
->szQName
);
813 /*** ISAXAttributes methods ***/
814 static HRESULT WINAPI
isaxattributes_getLength(
815 ISAXAttributes
* iface
,
818 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
820 *length
= This
->nb_attributes
;
821 TRACE("Length set to %d\n", *length
);
825 static HRESULT WINAPI
isaxattributes_getURI(
826 ISAXAttributes
* iface
,
831 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
832 TRACE("(%p)->(%d)\n", This
, index
);
834 if(index
>= This
->nb_attributes
|| index
< 0) return E_INVALIDARG
;
835 if(!url
|| !size
) return E_POINTER
;
837 *size
= SysStringLen(This
->szURI
[index
]);
838 *url
= This
->szURI
[index
];
840 TRACE("(%s:%d)\n", debugstr_w(This
->szURI
[index
]), *size
);
845 static HRESULT WINAPI
isaxattributes_getLocalName(
846 ISAXAttributes
* iface
,
848 const WCHAR
**pLocalName
,
849 int *pLocalNameLength
)
851 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
852 TRACE("(%p)->(%d)\n", This
, nIndex
);
854 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
855 if(!pLocalName
|| !pLocalNameLength
) return E_POINTER
;
857 *pLocalNameLength
= SysStringLen(This
->szLocalname
[nIndex
]);
858 *pLocalName
= This
->szLocalname
[nIndex
];
863 static HRESULT WINAPI
isaxattributes_getQName(
864 ISAXAttributes
* iface
,
866 const WCHAR
**pQName
,
869 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
870 TRACE("(%p)->(%d)\n", This
, nIndex
);
872 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
873 if(!pQName
|| !pQNameLength
) return E_POINTER
;
875 *pQNameLength
= SysStringLen(This
->szQName
[nIndex
]);
876 *pQName
= This
->szQName
[nIndex
];
881 static HRESULT WINAPI
isaxattributes_getName(
882 ISAXAttributes
* iface
,
886 const WCHAR
**localName
,
891 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
892 TRACE("(%p)->(%d)\n", This
, index
);
894 if(index
>=This
->nb_attributes
|| index
<0) return E_INVALIDARG
;
895 if(!uri
|| !pUriLength
|| !localName
|| !pLocalNameSize
896 || !QName
|| !pQNameLength
) return E_POINTER
;
898 *pUriLength
= SysStringLen(This
->szURI
[index
]);
899 *uri
= This
->szURI
[index
];
900 *pLocalNameSize
= SysStringLen(This
->szLocalname
[index
]);
901 *localName
= This
->szLocalname
[index
];
902 *pQNameLength
= SysStringLen(This
->szQName
[index
]);
903 *QName
= This
->szQName
[index
];
905 TRACE("(%s, %s, %s)\n", debugstr_w(*uri
), debugstr_w(*localName
), debugstr_w(*QName
));
910 static HRESULT WINAPI
isaxattributes_getIndexFromName(
911 ISAXAttributes
* iface
,
914 const WCHAR
*pLocalName
,
918 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
920 TRACE("(%p)->(%s, %d, %s, %d)\n", This
, debugstr_w(pUri
), cUriLength
,
921 debugstr_w(pLocalName
), cocalNameLength
);
923 if(!pUri
|| !pLocalName
|| !index
) return E_POINTER
;
925 for(i
=0; i
<This
->nb_attributes
; i
++)
927 if(cUriLength
!=SysStringLen(This
->szURI
[i
])
928 || cocalNameLength
!=SysStringLen(This
->szLocalname
[i
]))
930 if(cUriLength
&& memcmp(pUri
, This
->szURI
[i
],
931 sizeof(WCHAR
)*cUriLength
))
933 if(cocalNameLength
&& memcmp(pLocalName
, This
->szLocalname
[i
],
934 sizeof(WCHAR
)*cocalNameLength
))
944 static HRESULT WINAPI
isaxattributes_getIndexFromQName(
945 ISAXAttributes
* iface
,
950 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
952 TRACE("(%p)->(%s, %d)\n", This
, debugstr_w(pQName
), nQNameLength
);
954 if(!pQName
|| !index
) return E_POINTER
;
955 if(!nQNameLength
) return E_INVALIDARG
;
957 for(i
=0; i
<This
->nb_attributes
; i
++)
959 if(nQNameLength
!=SysStringLen(This
->szQName
[i
])) continue;
960 if(memcmp(pQName
, This
->szQName
, sizeof(WCHAR
)*nQNameLength
)) continue;
969 static HRESULT WINAPI
isaxattributes_getType(
970 ISAXAttributes
* iface
,
975 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
977 FIXME("(%p)->(%d) stub\n", This
, nIndex
);
981 static HRESULT WINAPI
isaxattributes_getTypeFromName(
982 ISAXAttributes
* iface
,
985 const WCHAR
*pLocalName
,
990 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
992 FIXME("(%p)->(%s, %d, %s, %d) stub\n", This
, debugstr_w(pUri
), nUri
,
993 debugstr_w(pLocalName
), nLocalName
);
997 static HRESULT WINAPI
isaxattributes_getTypeFromQName(
998 ISAXAttributes
* iface
,
1001 const WCHAR
**pType
,
1004 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
1006 FIXME("(%p)->(%s, %d) stub\n", This
, debugstr_w(pQName
), nQName
);
1010 static HRESULT WINAPI
isaxattributes_getValue(
1011 ISAXAttributes
* iface
,
1013 const WCHAR
**value
,
1016 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
1017 TRACE("(%p)->(%d)\n", This
, index
);
1019 if(index
>=This
->nb_attributes
|| index
<0) return E_INVALIDARG
;
1020 if(!value
|| !nValue
) return E_POINTER
;
1022 *nValue
= SysStringLen(This
->szValue
[index
]);
1023 *value
= This
->szValue
[index
];
1025 TRACE("(%s:%d)\n", debugstr_w(*value
), *nValue
);
1030 static HRESULT WINAPI
isaxattributes_getValueFromName(
1031 ISAXAttributes
* iface
,
1034 const WCHAR
*pLocalName
,
1036 const WCHAR
**pValue
,
1041 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
1042 TRACE("(%p)->(%s, %d, %s, %d)\n", This
, debugstr_w(pUri
), nUri
,
1043 debugstr_w(pLocalName
), nLocalName
);
1045 hr
= ISAXAttributes_getIndexFromName(iface
,
1046 pUri
, nUri
, pLocalName
, nLocalName
, &index
);
1047 if(hr
==S_OK
) hr
= ISAXAttributes_getValue(iface
, index
, pValue
, nValue
);
1052 static HRESULT WINAPI
isaxattributes_getValueFromQName(
1053 ISAXAttributes
* iface
,
1054 const WCHAR
*pQName
,
1056 const WCHAR
**pValue
,
1061 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
1062 TRACE("(%p)->(%s, %d)\n", This
, debugstr_w(pQName
), nQName
);
1064 hr
= ISAXAttributes_getIndexFromQName(iface
, pQName
, nQName
, &index
);
1065 if(hr
==S_OK
) hr
= ISAXAttributes_getValue(iface
, index
, pValue
, nValue
);
1070 static const struct ISAXAttributesVtbl isaxattributes_vtbl
=
1072 isaxattributes_QueryInterface
,
1073 isaxattributes_AddRef
,
1074 isaxattributes_Release
,
1075 isaxattributes_getLength
,
1076 isaxattributes_getURI
,
1077 isaxattributes_getLocalName
,
1078 isaxattributes_getQName
,
1079 isaxattributes_getName
,
1080 isaxattributes_getIndexFromName
,
1081 isaxattributes_getIndexFromQName
,
1082 isaxattributes_getType
,
1083 isaxattributes_getTypeFromName
,
1084 isaxattributes_getTypeFromQName
,
1085 isaxattributes_getValue
,
1086 isaxattributes_getValueFromName
,
1087 isaxattributes_getValueFromQName
1090 static HRESULT
SAXAttributes_create(saxattributes
**attr
,
1091 int nb_namespaces
, const xmlChar
**xmlNamespaces
,
1092 int nb_attributes
, const xmlChar
**xmlAttributes
)
1094 saxattributes
*attributes
;
1096 static const xmlChar xmlns
[] = "xmlns";
1098 attributes
= heap_alloc(sizeof(*attributes
));
1100 return E_OUTOFMEMORY
;
1102 attributes
->IVBSAXAttributes_iface
.lpVtbl
= &ivbsaxattributes_vtbl
;
1103 attributes
->ISAXAttributes_iface
.lpVtbl
= &isaxattributes_vtbl
;
1104 attributes
->ref
= 1;
1106 attributes
->nb_attributes
= nb_namespaces
+nb_attributes
;
1108 attributes
->szLocalname
= heap_alloc(sizeof(BSTR
)*attributes
->nb_attributes
);
1109 attributes
->szURI
= heap_alloc(sizeof(BSTR
)*attributes
->nb_attributes
);
1110 attributes
->szValue
= heap_alloc(sizeof(BSTR
)*attributes
->nb_attributes
);
1111 attributes
->szQName
= heap_alloc(sizeof(BSTR
)*attributes
->nb_attributes
);
1113 if(!attributes
->szLocalname
|| !attributes
->szURI
1114 || !attributes
->szValue
|| !attributes
->szQName
)
1116 heap_free(attributes
->szLocalname
);
1117 heap_free(attributes
->szURI
);
1118 heap_free(attributes
->szValue
);
1119 heap_free(attributes
->szQName
);
1120 heap_free(attributes
);
1124 for(index
=0; index
<nb_namespaces
; index
++)
1126 attributes
->szLocalname
[index
] = SysAllocStringLen(NULL
, 0);
1127 attributes
->szURI
[index
] = SysAllocStringLen(NULL
, 0);
1128 attributes
->szValue
[index
] = bstr_from_xmlChar(xmlNamespaces
[2*index
+1]);
1129 attributes
->szQName
[index
] = QName_from_xmlChar(xmlns
, xmlNamespaces
[2*index
]);
1132 for(index
=0; index
<nb_attributes
; index
++)
1134 attributes
->szLocalname
[nb_namespaces
+index
] =
1135 bstr_from_xmlChar(xmlAttributes
[index
*5]);
1136 attributes
->szURI
[nb_namespaces
+index
] =
1137 bstr_from_xmlChar(xmlAttributes
[index
*5+2]);
1138 attributes
->szValue
[nb_namespaces
+index
] =
1139 bstr_from_xmlCharN(xmlAttributes
[index
*5+3],
1140 xmlAttributes
[index
*5+4]-xmlAttributes
[index
*5+3]);
1141 attributes
->szQName
[nb_namespaces
+index
] =
1142 QName_from_xmlChar(xmlAttributes
[index
*5+1], xmlAttributes
[index
*5]);
1147 TRACE("returning %p\n", *attr
);
1152 /*** LibXML callbacks ***/
1153 static void libxmlStartDocument(void *ctx
)
1155 saxlocator
*This
= ctx
;
1158 if(has_content_handler(This
))
1160 if(This
->vbInterface
)
1161 hr
= IVBSAXContentHandler_startDocument(This
->saxreader
->vbcontentHandler
);
1163 hr
= ISAXContentHandler_startDocument(This
->saxreader
->contentHandler
);
1166 format_error_message_from_id(This
, hr
);
1169 update_position(This
, NULL
);
1172 static void libxmlEndDocument(void *ctx
)
1174 saxlocator
*This
= ctx
;
1180 if(This
->ret
!= S_OK
) return;
1182 if(has_content_handler(This
))
1184 if(This
->vbInterface
)
1185 hr
= IVBSAXContentHandler_endDocument(This
->saxreader
->vbcontentHandler
);
1187 hr
= ISAXContentHandler_endDocument(This
->saxreader
->contentHandler
);
1190 format_error_message_from_id(This
, hr
);
1194 static void libxmlStartElementNS(
1196 const xmlChar
*localname
,
1197 const xmlChar
*prefix
,
1200 const xmlChar
**namespaces
,
1203 const xmlChar
**attributes
)
1205 BSTR NamespaceUri
, LocalName
, QName
, Prefix
, Uri
;
1206 saxlocator
*This
= ctx
;
1208 saxattributes
*attr
;
1211 if(*(This
->pParserCtxt
->input
->cur
) == '/')
1212 update_position(This
, (xmlChar
*)This
->pParserCtxt
->input
->cur
+2);
1214 update_position(This
, (xmlChar
*)This
->pParserCtxt
->input
->cur
+1);
1216 hr
= namespacePush(This
, nb_namespaces
);
1217 if(hr
==S_OK
&& has_content_handler(This
))
1219 for(index
=0; index
<nb_namespaces
; index
++)
1221 Prefix
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, namespaces
[2*index
]);
1222 Uri
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, namespaces
[2*index
+1]);
1224 if(This
->vbInterface
)
1225 hr
= IVBSAXContentHandler_startPrefixMapping(
1226 This
->saxreader
->vbcontentHandler
,
1229 hr
= ISAXContentHandler_startPrefixMapping(
1230 This
->saxreader
->contentHandler
,
1231 Prefix
, SysStringLen(Prefix
),
1232 Uri
, SysStringLen(Uri
));
1236 format_error_message_from_id(This
, hr
);
1241 NamespaceUri
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, URI
);
1242 LocalName
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, localname
);
1243 QName
= pooled_QName_from_xmlChar(&This
->saxreader
->pool
, prefix
, localname
);
1245 hr
= SAXAttributes_create(&attr
, nb_namespaces
, namespaces
, nb_attributes
, attributes
);
1248 if(This
->vbInterface
)
1249 hr
= IVBSAXContentHandler_startElement(This
->saxreader
->vbcontentHandler
,
1250 &NamespaceUri
, &LocalName
, &QName
, &attr
->IVBSAXAttributes_iface
);
1252 hr
= ISAXContentHandler_startElement(This
->saxreader
->contentHandler
, NamespaceUri
,
1253 SysStringLen(NamespaceUri
), LocalName
, SysStringLen(LocalName
), QName
,
1254 SysStringLen(QName
), &attr
->ISAXAttributes_iface
);
1256 ISAXAttributes_Release(&attr
->ISAXAttributes_iface
);
1261 format_error_message_from_id(This
, hr
);
1264 static void libxmlEndElementNS(
1266 const xmlChar
*localname
,
1267 const xmlChar
*prefix
,
1270 BSTR NamespaceUri
, LocalName
, QName
, Prefix
;
1271 saxlocator
*This
= ctx
;
1276 end
= (xmlChar
*)This
->pParserCtxt
->input
->cur
;
1277 if(*(end
-1) != '>' || *(end
-2) != '/')
1278 while(end
-2>=This
->pParserCtxt
->input
->base
1279 && *(end
-2)!='<' && *(end
-1)!='/') end
--;
1281 update_position(This
, end
);
1283 nsNr
= namespacePop(This
);
1285 if(has_content_handler(This
))
1287 NamespaceUri
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, URI
);
1288 LocalName
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, localname
);
1289 QName
= pooled_QName_from_xmlChar(&This
->saxreader
->pool
, prefix
, localname
);
1291 if(This
->vbInterface
)
1292 hr
= IVBSAXContentHandler_endElement(
1293 This
->saxreader
->vbcontentHandler
,
1294 &NamespaceUri
, &LocalName
, &QName
);
1296 hr
= ISAXContentHandler_endElement(
1297 This
->saxreader
->contentHandler
,
1298 NamespaceUri
, SysStringLen(NamespaceUri
),
1299 LocalName
, SysStringLen(LocalName
),
1300 QName
, SysStringLen(QName
));
1304 format_error_message_from_id(This
, hr
);
1308 for(index
=This
->pParserCtxt
->nsNr
-2;
1309 index
>=This
->pParserCtxt
->nsNr
-nsNr
*2; index
-=2)
1311 Prefix
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, This
->pParserCtxt
->nsTab
[index
]);
1313 if(This
->vbInterface
)
1314 hr
= IVBSAXContentHandler_endPrefixMapping(
1315 This
->saxreader
->vbcontentHandler
, &Prefix
);
1317 hr
= ISAXContentHandler_endPrefixMapping(
1318 This
->saxreader
->contentHandler
,
1319 Prefix
, SysStringLen(Prefix
));
1323 format_error_message_from_id(This
, hr
);
1330 update_position(This
, NULL
);
1333 static void libxmlCharacters(
1338 saxlocator
*This
= ctx
;
1343 BOOL lastEvent
= FALSE
;
1345 if(!(has_content_handler(This
))) return;
1348 if(*(ch
-1)=='\r') cur
--;
1351 if(ch
<This
->pParserCtxt
->input
->base
|| ch
>This
->pParserCtxt
->input
->end
)
1356 while(end
-ch
<len
&& *end
!='\r') end
++;
1363 if(!lastEvent
) *end
= '\n';
1365 Chars
= pooled_bstr_from_xmlCharN(&This
->saxreader
->pool
, cur
, end
-cur
+1);
1366 if(This
->vbInterface
)
1367 hr
= IVBSAXContentHandler_characters(
1368 This
->saxreader
->vbcontentHandler
, &Chars
);
1370 hr
= ISAXContentHandler_characters(
1371 This
->saxreader
->contentHandler
,
1372 Chars
, SysStringLen(Chars
));
1376 format_error_message_from_id(This
, hr
);
1380 This
->column
+= end
-cur
+1;
1394 if(end
-ch
== len
) break;
1397 if(ch
<This
->pParserCtxt
->input
->base
|| ch
>This
->pParserCtxt
->input
->end
)
1398 This
->column
= This
->realColumn
1399 +This
->pParserCtxt
->input
->cur
-This
->lastCur
;
1402 static void libxmlSetDocumentLocator(
1404 xmlSAXLocatorPtr loc
)
1406 saxlocator
*This
= ctx
;
1409 if(has_content_handler(This
))
1411 if(This
->vbInterface
)
1412 hr
= IVBSAXContentHandler_putref_documentLocator(This
->saxreader
->vbcontentHandler
,
1413 &This
->IVBSAXLocator_iface
);
1415 hr
= ISAXContentHandler_putDocumentLocator(This
->saxreader
->contentHandler
,
1416 &This
->ISAXLocator_iface
);
1420 format_error_message_from_id(This
, hr
);
1423 static void libxmlComment(void *ctx
, const xmlChar
*value
)
1425 saxlocator
*This
= ctx
;
1428 xmlChar
*beg
= (xmlChar
*)This
->pParserCtxt
->input
->cur
;
1430 while(beg
-4>=This
->pParserCtxt
->input
->base
1431 && memcmp(beg
-4, "<!--", sizeof(char[4]))) beg
--;
1432 update_position(This
, beg
);
1434 if(!This
->vbInterface
&& !This
->saxreader
->lexicalHandler
) return;
1435 if(This
->vbInterface
&& !This
->saxreader
->vblexicalHandler
) return;
1437 bValue
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, value
);
1439 if(This
->vbInterface
)
1440 hr
= IVBSAXLexicalHandler_comment(
1441 This
->saxreader
->vblexicalHandler
, &bValue
);
1443 hr
= ISAXLexicalHandler_comment(
1444 This
->saxreader
->lexicalHandler
,
1445 bValue
, SysStringLen(bValue
));
1448 format_error_message_from_id(This
, hr
);
1450 update_position(This
, NULL
);
1453 static void libxmlFatalError(void *ctx
, const char *msg
, ...)
1455 saxlocator
*This
= ctx
;
1461 va_start(args
, msg
);
1462 vsprintf(message
, msg
, args
);
1465 len
= MultiByteToWideChar(CP_UNIXCP
, 0, message
, -1, NULL
, 0);
1466 error
= heap_alloc(sizeof(WCHAR
)*len
);
1469 MultiByteToWideChar(CP_UNIXCP
, 0, message
, -1, error
, len
);
1470 TRACE("fatal error for %p: %s\n", This
, debugstr_w(error
));
1473 if(!has_error_handler(This
))
1475 xmlStopParser(This
->pParserCtxt
);
1481 FIXME("Error handling is not compatible.\n");
1483 if(This
->vbInterface
)
1485 BSTR bstrError
= SysAllocString(error
);
1486 IVBSAXErrorHandler_fatalError(This
->saxreader
->vberrorHandler
, &This
->IVBSAXLocator_iface
,
1487 &bstrError
, E_FAIL
);
1488 SysFreeString(bstrError
);
1491 ISAXErrorHandler_fatalError(This
->saxreader
->errorHandler
, &This
->ISAXLocator_iface
,
1496 xmlStopParser(This
->pParserCtxt
);
1500 static void libxmlCDataBlock(void *ctx
, const xmlChar
*value
, int len
)
1502 saxlocator
*This
= ctx
;
1504 xmlChar
*beg
= (xmlChar
*)This
->pParserCtxt
->input
->cur
-len
;
1508 BOOL lastEvent
= FALSE
, change
;
1510 while(beg
-9>=This
->pParserCtxt
->input
->base
1511 && memcmp(beg
-9, "<![CDATA[", sizeof(char[9]))) beg
--;
1512 update_position(This
, beg
);
1514 if(This
->vbInterface
&& This
->saxreader
->vblexicalHandler
)
1515 hr
= IVBSAXLexicalHandler_startCDATA(This
->saxreader
->vblexicalHandler
);
1516 if(!This
->vbInterface
&& This
->saxreader
->lexicalHandler
)
1517 hr
= ISAXLexicalHandler_startCDATA(This
->saxreader
->lexicalHandler
);
1521 format_error_message_from_id(This
, hr
);
1525 realLen
= This
->pParserCtxt
->input
->cur
-beg
-3;
1531 while(end
-beg
<realLen
&& *end
!='\r') end
++;
1532 if(end
-beg
==realLen
)
1537 else if(end
-beg
==realLen
-1 && *end
=='\r' && *(end
+1)=='\n')
1540 if(*end
== '\r') change
= TRUE
;
1541 else change
= FALSE
;
1543 if(change
) *end
= '\n';
1545 if(has_content_handler(This
))
1547 Chars
= pooled_bstr_from_xmlCharN(&This
->saxreader
->pool
, cur
, end
-cur
+1);
1548 if(This
->vbInterface
)
1549 hr
= IVBSAXContentHandler_characters(
1550 This
->saxreader
->vbcontentHandler
, &Chars
);
1552 hr
= ISAXContentHandler_characters(
1553 This
->saxreader
->contentHandler
,
1554 Chars
, SysStringLen(Chars
));
1557 if(change
) *end
= '\r';
1562 This
->column
+= end
-cur
+2;
1567 if(This
->vbInterface
&& This
->saxreader
->vblexicalHandler
)
1568 hr
= IVBSAXLexicalHandler_endCDATA(This
->saxreader
->vblexicalHandler
);
1569 if(!This
->vbInterface
&& This
->saxreader
->lexicalHandler
)
1570 hr
= ISAXLexicalHandler_endCDATA(This
->saxreader
->lexicalHandler
);
1573 format_error_message_from_id(This
, hr
);
1575 This
->column
+= 4+end
-cur
;
1578 /*** IVBSAXLocator interface ***/
1579 /*** IUnknown methods ***/
1580 static HRESULT WINAPI
ivbsaxlocator_QueryInterface(IVBSAXLocator
* iface
, REFIID riid
, void **ppvObject
)
1582 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1584 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
1588 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
1589 IsEqualGUID( riid
, &IID_IDispatch
) ||
1590 IsEqualGUID( riid
, &IID_IVBSAXLocator
))
1596 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1597 return E_NOINTERFACE
;
1600 IVBSAXLocator_AddRef( iface
);
1605 static ULONG WINAPI
ivbsaxlocator_AddRef(IVBSAXLocator
* iface
)
1607 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1608 TRACE("%p\n", This
);
1609 return InterlockedIncrement( &This
->ref
);
1612 static ULONG WINAPI
ivbsaxlocator_Release(
1613 IVBSAXLocator
* iface
)
1615 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1616 return ISAXLocator_Release((ISAXLocator
*)&This
->IVBSAXLocator_iface
);
1619 /*** IDispatch methods ***/
1620 static HRESULT WINAPI
ivbsaxlocator_GetTypeInfoCount( IVBSAXLocator
*iface
, UINT
* pctinfo
)
1622 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1624 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1631 static HRESULT WINAPI
ivbsaxlocator_GetTypeInfo(
1632 IVBSAXLocator
*iface
,
1633 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
1635 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1638 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1640 hr
= get_typeinfo(IVBSAXLocator_tid
, ppTInfo
);
1645 static HRESULT WINAPI
ivbsaxlocator_GetIDsOfNames(
1646 IVBSAXLocator
*iface
,
1648 LPOLESTR
* rgszNames
,
1653 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1654 ITypeInfo
*typeinfo
;
1657 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1660 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
1661 return E_INVALIDARG
;
1663 hr
= get_typeinfo(IVBSAXLocator_tid
, &typeinfo
);
1666 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
1667 ITypeInfo_Release(typeinfo
);
1673 static HRESULT WINAPI
ivbsaxlocator_Invoke(
1674 IVBSAXLocator
*iface
,
1675 DISPID dispIdMember
,
1679 DISPPARAMS
* pDispParams
,
1680 VARIANT
* pVarResult
,
1681 EXCEPINFO
* pExcepInfo
,
1684 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1685 ITypeInfo
*typeinfo
;
1688 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1689 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1691 hr
= get_typeinfo(IVBSAXLocator_tid
, &typeinfo
);
1694 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IVBSAXLocator_iface
, dispIdMember
, wFlags
,
1695 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1696 ITypeInfo_Release(typeinfo
);
1702 /*** IVBSAXLocator methods ***/
1703 static HRESULT WINAPI
ivbsaxlocator_get_columnNumber(
1704 IVBSAXLocator
* iface
,
1707 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1708 return ISAXLocator_getColumnNumber((ISAXLocator
*)&This
->IVBSAXLocator_iface
, pnColumn
);
1711 static HRESULT WINAPI
ivbsaxlocator_get_lineNumber(
1712 IVBSAXLocator
* iface
,
1715 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1716 return ISAXLocator_getLineNumber((ISAXLocator
*)&This
->IVBSAXLocator_iface
, pnLine
);
1719 static HRESULT WINAPI
ivbsaxlocator_get_publicId(
1720 IVBSAXLocator
* iface
,
1723 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1724 return ISAXLocator_getPublicId((ISAXLocator
*)&This
->IVBSAXLocator_iface
,
1725 (const WCHAR
**)publicId
);
1728 static HRESULT WINAPI
ivbsaxlocator_get_systemId(
1729 IVBSAXLocator
* iface
,
1732 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1733 return ISAXLocator_getSystemId((ISAXLocator
*)&This
->IVBSAXLocator_iface
,
1734 (const WCHAR
**)systemId
);
1737 static const struct IVBSAXLocatorVtbl ivbsaxlocator_vtbl
=
1739 ivbsaxlocator_QueryInterface
,
1740 ivbsaxlocator_AddRef
,
1741 ivbsaxlocator_Release
,
1742 ivbsaxlocator_GetTypeInfoCount
,
1743 ivbsaxlocator_GetTypeInfo
,
1744 ivbsaxlocator_GetIDsOfNames
,
1745 ivbsaxlocator_Invoke
,
1746 ivbsaxlocator_get_columnNumber
,
1747 ivbsaxlocator_get_lineNumber
,
1748 ivbsaxlocator_get_publicId
,
1749 ivbsaxlocator_get_systemId
1752 /*** ISAXLocator interface ***/
1753 /*** IUnknown methods ***/
1754 static HRESULT WINAPI
isaxlocator_QueryInterface(ISAXLocator
* iface
, REFIID riid
, void **ppvObject
)
1756 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1758 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
1762 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
1763 IsEqualGUID( riid
, &IID_ISAXLocator
))
1769 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1770 return E_NOINTERFACE
;
1773 ISAXLocator_AddRef( iface
);
1778 static ULONG WINAPI
isaxlocator_AddRef(ISAXLocator
* iface
)
1780 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1781 TRACE("%p\n", This
);
1782 return InterlockedIncrement( &This
->ref
);
1785 static ULONG WINAPI
isaxlocator_Release(
1788 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1791 TRACE("%p\n", This
);
1793 ref
= InterlockedDecrement( &This
->ref
);
1796 SysFreeString(This
->publicId
);
1797 SysFreeString(This
->systemId
);
1798 heap_free(This
->nsStack
);
1800 ISAXXMLReader_Release(&This
->saxreader
->ISAXXMLReader_iface
);
1807 /*** ISAXLocator methods ***/
1808 static HRESULT WINAPI
isaxlocator_getColumnNumber(
1812 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1814 *pnColumn
= This
->column
;
1818 static HRESULT WINAPI
isaxlocator_getLineNumber(
1822 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1824 *pnLine
= This
->line
;
1828 static HRESULT WINAPI
isaxlocator_getPublicId(
1830 const WCHAR
** ppwchPublicId
)
1833 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1835 SysFreeString(This
->publicId
);
1837 publicId
= bstr_from_xmlChar(xmlSAX2GetPublicId(This
->pParserCtxt
));
1838 if(SysStringLen(publicId
))
1839 This
->publicId
= (WCHAR
*)&publicId
;
1842 SysFreeString(publicId
);
1843 This
->publicId
= NULL
;
1846 *ppwchPublicId
= This
->publicId
;
1850 static HRESULT WINAPI
isaxlocator_getSystemId(
1852 const WCHAR
** ppwchSystemId
)
1855 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1857 SysFreeString(This
->systemId
);
1859 systemId
= bstr_from_xmlChar(xmlSAX2GetSystemId(This
->pParserCtxt
));
1860 if(SysStringLen(systemId
))
1861 This
->systemId
= (WCHAR
*)&systemId
;
1864 SysFreeString(systemId
);
1865 This
->systemId
= NULL
;
1868 *ppwchSystemId
= This
->systemId
;
1872 static const struct ISAXLocatorVtbl isaxlocator_vtbl
=
1874 isaxlocator_QueryInterface
,
1876 isaxlocator_Release
,
1877 isaxlocator_getColumnNumber
,
1878 isaxlocator_getLineNumber
,
1879 isaxlocator_getPublicId
,
1880 isaxlocator_getSystemId
1883 static HRESULT
SAXLocator_create(saxreader
*reader
, saxlocator
**ppsaxlocator
, BOOL vbInterface
)
1885 saxlocator
*locator
;
1887 locator
= heap_alloc( sizeof (*locator
) );
1889 return E_OUTOFMEMORY
;
1891 locator
->IVBSAXLocator_iface
.lpVtbl
= &ivbsaxlocator_vtbl
;
1892 locator
->ISAXLocator_iface
.lpVtbl
= &isaxlocator_vtbl
;
1894 locator
->vbInterface
= vbInterface
;
1896 locator
->saxreader
= reader
;
1897 ISAXXMLReader_AddRef(&reader
->ISAXXMLReader_iface
);
1899 locator
->pParserCtxt
= NULL
;
1900 locator
->publicId
= NULL
;
1901 locator
->systemId
= NULL
;
1902 locator
->lastCur
= NULL
;
1904 locator
->column
= 0;
1905 locator
->ret
= S_OK
;
1906 locator
->nsStackSize
= 8;
1907 locator
->nsStackLast
= 0;
1908 locator
->nsStack
= heap_alloc(sizeof(int)*locator
->nsStackSize
);
1909 if(!locator
->nsStack
)
1911 ISAXXMLReader_Release(&reader
->ISAXXMLReader_iface
);
1913 return E_OUTOFMEMORY
;
1916 *ppsaxlocator
= locator
;
1918 TRACE("returning %p\n", *ppsaxlocator
);
1923 /*** SAXXMLReader internal functions ***/
1924 static HRESULT
internal_parseBuffer(saxreader
*This
, const char *buffer
, int size
, BOOL vbInterface
)
1926 xmlCharEncoding encoding
= XML_CHAR_ENCODING_NONE
;
1927 xmlChar
*enc_name
= NULL
;
1928 saxlocator
*locator
;
1931 hr
= SAXLocator_create(This
, &locator
, vbInterface
);
1937 const unsigned char *buff
= (unsigned char*)buffer
;
1939 encoding
= xmlDetectCharEncoding((xmlChar
*)buffer
, 4);
1940 enc_name
= (xmlChar
*)xmlGetCharEncodingName(encoding
);
1941 TRACE("detected encoding: %s\n", enc_name
);
1942 /* skip BOM, parser won't switch encodings and so won't skip it on its own */
1943 if ((encoding
== XML_CHAR_ENCODING_UTF8
) &&
1944 buff
[0] == 0xEF && buff
[1] == 0xBB && buff
[2] == 0xBF)
1951 locator
->pParserCtxt
= xmlCreateMemoryParserCtxt(buffer
, size
);
1952 if(!locator
->pParserCtxt
)
1954 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
1958 if (encoding
== XML_CHAR_ENCODING_UTF8
)
1959 locator
->pParserCtxt
->encoding
= xmlStrdup(enc_name
);
1961 xmlFree(locator
->pParserCtxt
->sax
);
1962 locator
->pParserCtxt
->sax
= &locator
->saxreader
->sax
;
1963 locator
->pParserCtxt
->userData
= locator
;
1965 This
->isParsing
= TRUE
;
1966 if(xmlParseDocument(locator
->pParserCtxt
) == -1) hr
= E_FAIL
;
1967 else hr
= locator
->ret
;
1968 This
->isParsing
= FALSE
;
1970 if(locator
->pParserCtxt
)
1972 locator
->pParserCtxt
->sax
= NULL
;
1973 xmlFreeParserCtxt(locator
->pParserCtxt
);
1974 locator
->pParserCtxt
= NULL
;
1977 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
1981 static HRESULT
internal_parseStream(saxreader
*This
, IStream
*stream
, BOOL vbInterface
)
1983 saxlocator
*locator
;
1990 hr
= IStream_Read(stream
, data
, sizeof(data
), &dataRead
);
1991 if(FAILED(hr
)) return hr
;
1993 hr
= SAXLocator_create(This
, &locator
, vbInterface
);
1994 if(FAILED(hr
)) return hr
;
1996 locator
->pParserCtxt
= xmlCreatePushParserCtxt(
1997 &locator
->saxreader
->sax
, locator
,
1998 data
, dataRead
, NULL
);
1999 if(!locator
->pParserCtxt
)
2001 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
2005 This
->isParsing
= TRUE
;
2007 if(dataRead
!= sizeof(data
))
2009 ret
= xmlParseChunk(locator
->pParserCtxt
, data
, 0, 1);
2010 hr
= ret
!= XML_ERR_OK
? E_FAIL
: locator
->ret
;
2017 hr
= IStream_Read(stream
, data
, sizeof(data
), &dataRead
);
2018 if (FAILED(hr
)) break;
2020 ret
= xmlParseChunk(locator
->pParserCtxt
, data
, dataRead
, 0);
2021 hr
= ret
!= XML_ERR_OK
? E_FAIL
: locator
->ret
;
2023 if (hr
!= S_OK
) break;
2025 if (dataRead
!= sizeof(data
))
2027 ret
= xmlParseChunk(locator
->pParserCtxt
, data
, 0, 1);
2028 hr
= ret
!= XML_ERR_OK
? E_FAIL
: locator
->ret
;
2034 This
->isParsing
= FALSE
;
2036 xmlFreeParserCtxt(locator
->pParserCtxt
);
2037 locator
->pParserCtxt
= NULL
;
2038 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
2042 static HRESULT
internal_getEntityResolver(
2044 void *pEntityResolver
,
2047 FIXME("(%p)->(%p) stub\n", This
, pEntityResolver
);
2051 static HRESULT
internal_putEntityResolver(
2053 void *pEntityResolver
,
2056 FIXME("(%p)->(%p) stub\n", This
, pEntityResolver
);
2060 static HRESULT
internal_getContentHandler(
2062 void *pContentHandler
,
2065 TRACE("(%p)->(%p)\n", This
, pContentHandler
);
2066 if(pContentHandler
== NULL
)
2068 if((vbInterface
&& This
->vbcontentHandler
)
2069 || (!vbInterface
&& This
->contentHandler
))
2072 IVBSAXContentHandler_AddRef(This
->vbcontentHandler
);
2074 ISAXContentHandler_AddRef(This
->contentHandler
);
2076 if(vbInterface
) *(IVBSAXContentHandler
**)pContentHandler
=
2077 This
->vbcontentHandler
;
2078 else *(ISAXContentHandler
**)pContentHandler
= This
->contentHandler
;
2083 static HRESULT
internal_putContentHandler(
2085 void *contentHandler
,
2088 TRACE("(%p)->(%p)\n", This
, contentHandler
);
2092 IVBSAXContentHandler_AddRef((IVBSAXContentHandler
*)contentHandler
);
2094 ISAXContentHandler_AddRef((ISAXContentHandler
*)contentHandler
);
2096 if((vbInterface
&& This
->vbcontentHandler
)
2097 || (!vbInterface
&& This
->contentHandler
))
2100 IVBSAXContentHandler_Release(This
->vbcontentHandler
);
2102 ISAXContentHandler_Release(This
->contentHandler
);
2105 This
->vbcontentHandler
= contentHandler
;
2107 This
->contentHandler
= contentHandler
;
2112 static HRESULT
internal_getDTDHandler(
2117 FIXME("(%p)->(%p) stub\n", This
, pDTDHandler
);
2121 static HRESULT
internal_putDTDHandler(
2126 FIXME("(%p)->(%p) stub\n", This
, pDTDHandler
);
2130 static HRESULT
internal_getErrorHandler(
2132 void *pErrorHandler
,
2135 TRACE("(%p)->(%p)\n", This
, pErrorHandler
);
2136 if(pErrorHandler
== NULL
)
2139 if(vbInterface
&& This
->vberrorHandler
)
2140 IVBSAXErrorHandler_AddRef(This
->vberrorHandler
);
2141 else if(!vbInterface
&& This
->errorHandler
)
2142 ISAXErrorHandler_AddRef(This
->errorHandler
);
2145 *(IVBSAXErrorHandler
**)pErrorHandler
= This
->vberrorHandler
;
2147 *(ISAXErrorHandler
**)pErrorHandler
= This
->errorHandler
;
2153 static HRESULT
internal_putErrorHandler(
2158 TRACE("(%p)->(%p)\n", This
, errorHandler
);
2162 IVBSAXErrorHandler_AddRef((IVBSAXErrorHandler
*)errorHandler
);
2164 ISAXErrorHandler_AddRef((ISAXErrorHandler
*)errorHandler
);
2167 if(vbInterface
&& This
->vberrorHandler
)
2168 IVBSAXErrorHandler_Release(This
->vberrorHandler
);
2169 else if(!vbInterface
&& This
->errorHandler
)
2170 ISAXErrorHandler_Release(This
->errorHandler
);
2173 This
->vberrorHandler
= errorHandler
;
2175 This
->errorHandler
= errorHandler
;
2181 static HRESULT
internal_parse(
2188 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&varInput
));
2190 /* Dispose of the BSTRs in the pool from a prior run, if any. */
2191 free_bstr_pool(&This
->pool
);
2193 switch(V_VT(&varInput
))
2196 hr
= internal_parseBuffer(This
, (const char*)V_BSTR(&varInput
),
2197 SysStringByteLen(V_BSTR(&varInput
)), vbInterface
);
2199 case VT_ARRAY
|VT_UI1
: {
2201 LONG lBound
, uBound
;
2204 hr
= SafeArrayGetLBound(V_ARRAY(&varInput
), 1, &lBound
);
2205 if(hr
!= S_OK
) break;
2206 hr
= SafeArrayGetUBound(V_ARRAY(&varInput
), 1, &uBound
);
2207 if(hr
!= S_OK
) break;
2208 dataRead
= (uBound
-lBound
)*SafeArrayGetElemsize(V_ARRAY(&varInput
));
2209 hr
= SafeArrayAccessData(V_ARRAY(&varInput
), &pSAData
);
2210 if(hr
!= S_OK
) break;
2211 hr
= internal_parseBuffer(This
, pSAData
, dataRead
, vbInterface
);
2212 SafeArrayUnaccessData(V_ARRAY(&varInput
));
2217 IPersistStream
*persistStream
;
2218 IStream
*stream
= NULL
;
2219 IXMLDOMDocument
*xmlDoc
;
2221 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
2222 &IID_IXMLDOMDocument
, (void**)&xmlDoc
) == S_OK
)
2226 IXMLDOMDocument_get_xml(xmlDoc
, &bstrData
);
2227 hr
= internal_parseBuffer(This
, (const char*)bstrData
,
2228 SysStringByteLen(bstrData
), vbInterface
);
2229 IXMLDOMDocument_Release(xmlDoc
);
2230 SysFreeString(bstrData
);
2234 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
2235 &IID_IPersistStream
, (void**)&persistStream
) == S_OK
)
2237 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
2240 IPersistStream_Release(persistStream
);
2244 hr
= IPersistStream_Save(persistStream
, stream
, TRUE
);
2245 IPersistStream_Release(persistStream
);
2248 IStream_Release(stream
);
2252 if(stream
|| IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
2253 &IID_IStream
, (void**)&stream
) == S_OK
)
2255 hr
= internal_parseStream(This
, stream
, vbInterface
);
2256 IStream_Release(stream
);
2261 WARN("vt %d not implemented\n", V_VT(&varInput
));
2268 static HRESULT
internal_vbonDataAvailable(void *obj
, char *ptr
, DWORD len
)
2270 saxreader
*This
= obj
;
2272 return internal_parseBuffer(This
, ptr
, len
, TRUE
);
2275 static HRESULT
internal_onDataAvailable(void *obj
, char *ptr
, DWORD len
)
2277 saxreader
*This
= obj
;
2279 return internal_parseBuffer(This
, ptr
, len
, FALSE
);
2282 static HRESULT
internal_parseURL(
2290 TRACE("(%p)->(%s)\n", This
, debugstr_w(url
));
2292 if(vbInterface
) hr
= bind_url(url
, internal_vbonDataAvailable
, This
, &bsc
);
2293 else hr
= bind_url(url
, internal_onDataAvailable
, This
, &bsc
);
2303 static HRESULT
internal_putProperty(
2309 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(prop
), debugstr_variant(&value
));
2311 if(!memcmp(prop
, PropertyDeclHandlerW
, sizeof(PropertyDeclHandlerW
)))
2313 if(This
->isParsing
) return E_FAIL
;
2315 switch (V_VT(&value
))
2320 if (This
->vbdeclHandler
)
2322 IVBSAXDeclHandler_Release(This
->vbdeclHandler
);
2323 This
->vbdeclHandler
= NULL
;
2327 if (This
->declHandler
)
2329 ISAXDeclHandler_Release(This
->declHandler
);
2330 This
->declHandler
= NULL
;
2334 if (V_UNKNOWN(&value
)) IUnknown_AddRef(V_UNKNOWN(&value
));
2336 if ((vbInterface
&& This
->vbdeclHandler
) ||
2337 (!vbInterface
&& This
->declHandler
))
2340 IVBSAXDeclHandler_Release(This
->vbdeclHandler
);
2342 ISAXDeclHandler_Release(This
->declHandler
);
2346 This
->vbdeclHandler
= (IVBSAXDeclHandler
*)V_UNKNOWN(&value
);
2348 This
->declHandler
= (ISAXDeclHandler
*)V_UNKNOWN(&value
);
2351 return E_INVALIDARG
;
2357 if(!memcmp(prop
, PropertyLexicalHandlerW
, sizeof(PropertyLexicalHandlerW
)))
2359 if(This
->isParsing
) return E_FAIL
;
2361 switch (V_VT(&value
))
2366 if (This
->vblexicalHandler
)
2368 IVBSAXLexicalHandler_Release(This
->vblexicalHandler
);
2369 This
->vblexicalHandler
= NULL
;
2373 if (This
->lexicalHandler
)
2375 ISAXLexicalHandler_Release(This
->lexicalHandler
);
2376 This
->lexicalHandler
= NULL
;
2380 if (V_UNKNOWN(&value
)) IUnknown_AddRef(V_UNKNOWN(&value
));
2382 if ((vbInterface
&& This
->vblexicalHandler
) ||
2383 (!vbInterface
&& This
->lexicalHandler
))
2386 IVBSAXLexicalHandler_Release(This
->vblexicalHandler
);
2388 ISAXLexicalHandler_Release(This
->lexicalHandler
);
2392 This
->vblexicalHandler
= (IVBSAXLexicalHandler
*)V_UNKNOWN(&value
);
2394 This
->lexicalHandler
= (ISAXLexicalHandler
*)V_UNKNOWN(&value
);
2397 return E_INVALIDARG
;
2403 if(!memcmp(prop
, PropertyMaxXMLSizeW
, sizeof(PropertyMaxXMLSizeW
)))
2405 if (V_VT(&value
) == VT_I4
&& V_I4(&value
) == 0) return S_OK
;
2406 FIXME("(%p)->(%s): max-xml-size unsupported\n", This
, debugstr_variant(&value
));
2410 if(!memcmp(prop
, PropertyMaxElementDepthW
, sizeof(PropertyMaxElementDepthW
)))
2412 if (V_VT(&value
) == VT_I4
&& V_I4(&value
) == 0) return S_OK
;
2413 FIXME("(%p)->(%s): max-element-depth unsupported\n", This
, debugstr_variant(&value
));
2417 FIXME("(%p)->(%s:%s): unsupported property\n", This
, debugstr_w(prop
), debugstr_variant(&value
));
2419 if(!memcmp(prop
, PropertyCharsetW
, sizeof(PropertyCharsetW
)))
2422 if(!memcmp(prop
, PropertyDomNodeW
, sizeof(PropertyDomNodeW
)))
2425 if(!memcmp(prop
, PropertyInputSourceW
, sizeof(PropertyInputSourceW
)))
2428 if(!memcmp(prop
, PropertySchemaDeclHandlerW
, sizeof(PropertySchemaDeclHandlerW
)))
2431 if(!memcmp(prop
, PropertyXMLDeclEncodingW
, sizeof(PropertyXMLDeclEncodingW
)))
2434 if(!memcmp(prop
, PropertyXMLDeclStandaloneW
, sizeof(PropertyXMLDeclStandaloneW
)))
2437 if(!memcmp(prop
, PropertyXMLDeclVersionW
, sizeof(PropertyXMLDeclVersionW
)))
2440 return E_INVALIDARG
;
2443 static HRESULT
internal_getProperty(const saxreader
* This
, const WCHAR
*prop
, VARIANT
*value
, BOOL vb
)
2445 TRACE("(%p)->(%s)\n", This
, debugstr_w(prop
));
2447 if (!value
) return E_POINTER
;
2449 if (!memcmp(PropertyLexicalHandlerW
, prop
, sizeof(PropertyLexicalHandlerW
)))
2451 V_VT(value
) = VT_UNKNOWN
;
2452 V_UNKNOWN(value
) = vb
? (IUnknown
*)This
->vblexicalHandler
: (IUnknown
*)This
->lexicalHandler
;
2453 if (V_UNKNOWN(value
)) IUnknown_AddRef(V_UNKNOWN(value
));
2457 if (!memcmp(PropertyDeclHandlerW
, prop
, sizeof(PropertyDeclHandlerW
)))
2459 V_VT(value
) = VT_UNKNOWN
;
2460 V_UNKNOWN(value
) = vb
? (IUnknown
*)This
->vbdeclHandler
: (IUnknown
*)This
->declHandler
;
2461 if (V_UNKNOWN(value
)) IUnknown_AddRef(V_UNKNOWN(value
));
2465 FIXME("(%p)->(%s) unsupported property\n", This
, debugstr_w(prop
));
2470 /*** IVBSAXXMLReader interface ***/
2471 /*** IUnknown methods ***/
2472 static HRESULT WINAPI
saxxmlreader_QueryInterface(IVBSAXXMLReader
* iface
, REFIID riid
, void **ppvObject
)
2474 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2476 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
2480 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
2481 IsEqualGUID( riid
, &IID_IDispatch
) ||
2482 IsEqualGUID( riid
, &IID_IVBSAXXMLReader
))
2486 else if( IsEqualGUID( riid
, &IID_ISAXXMLReader
))
2488 *ppvObject
= &This
->ISAXXMLReader_iface
;
2492 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
2493 return E_NOINTERFACE
;
2496 IVBSAXXMLReader_AddRef( iface
);
2501 static ULONG WINAPI
saxxmlreader_AddRef(IVBSAXXMLReader
* iface
)
2503 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2504 TRACE("%p\n", This
);
2505 return InterlockedIncrement( &This
->ref
);
2508 static ULONG WINAPI
saxxmlreader_Release(
2509 IVBSAXXMLReader
* iface
)
2511 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2514 TRACE("%p\n", This
);
2516 ref
= InterlockedDecrement( &This
->ref
);
2519 if(This
->contentHandler
)
2520 ISAXContentHandler_Release(This
->contentHandler
);
2522 if(This
->vbcontentHandler
)
2523 IVBSAXContentHandler_Release(This
->vbcontentHandler
);
2525 if(This
->errorHandler
)
2526 ISAXErrorHandler_Release(This
->errorHandler
);
2528 if(This
->vberrorHandler
)
2529 IVBSAXErrorHandler_Release(This
->vberrorHandler
);
2531 if(This
->lexicalHandler
)
2532 ISAXLexicalHandler_Release(This
->lexicalHandler
);
2534 if(This
->vblexicalHandler
)
2535 IVBSAXLexicalHandler_Release(This
->vblexicalHandler
);
2537 if(This
->declHandler
)
2538 ISAXDeclHandler_Release(This
->declHandler
);
2540 if(This
->vbdeclHandler
)
2541 IVBSAXDeclHandler_Release(This
->vbdeclHandler
);
2543 free_bstr_pool(&This
->pool
);
2551 static HRESULT WINAPI
saxxmlreader_GetTypeInfoCount( IVBSAXXMLReader
*iface
, UINT
* pctinfo
)
2553 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2555 TRACE("(%p)->(%p)\n", This
, pctinfo
);
2562 static HRESULT WINAPI
saxxmlreader_GetTypeInfo(
2563 IVBSAXXMLReader
*iface
,
2564 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2566 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2569 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
2571 hr
= get_typeinfo(IVBSAXXMLReader_tid
, ppTInfo
);
2576 static HRESULT WINAPI
saxxmlreader_GetIDsOfNames(
2577 IVBSAXXMLReader
*iface
,
2579 LPOLESTR
* rgszNames
,
2584 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2585 ITypeInfo
*typeinfo
;
2588 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
2591 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
2592 return E_INVALIDARG
;
2594 hr
= get_typeinfo(IVBSAXXMLReader_tid
, &typeinfo
);
2597 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
2598 ITypeInfo_Release(typeinfo
);
2604 static HRESULT WINAPI
saxxmlreader_Invoke(
2605 IVBSAXXMLReader
*iface
,
2606 DISPID dispIdMember
,
2610 DISPPARAMS
* pDispParams
,
2611 VARIANT
* pVarResult
,
2612 EXCEPINFO
* pExcepInfo
,
2615 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2616 ITypeInfo
*typeinfo
;
2619 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
2620 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2622 hr
= get_typeinfo(IVBSAXXMLReader_tid
, &typeinfo
);
2625 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IVBSAXXMLReader_iface
, dispIdMember
, wFlags
,
2626 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2627 ITypeInfo_Release(typeinfo
);
2633 /*** IVBSAXXMLReader methods ***/
2634 static HRESULT WINAPI
saxxmlreader_getFeature(
2635 IVBSAXXMLReader
* iface
,
2636 const WCHAR
*feature
,
2637 VARIANT_BOOL
*value
)
2639 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2641 if (!strcmpW(FeatureNamespacesW
, feature
))
2642 return get_feature_value(This
, Namespaces
, value
);
2644 FIXME("(%p)->(%s %p) stub\n", This
, debugstr_w(feature
), value
);
2648 static HRESULT WINAPI
saxxmlreader_putFeature(
2649 IVBSAXXMLReader
* iface
,
2650 const WCHAR
*feature
,
2653 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2655 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(feature
), value
);
2657 if (!strcmpW(FeatureExternalGeneralEntitiesW
, feature
) && value
== VARIANT_FALSE
)
2658 return set_feature_value(This
, ExternalGeneralEntities
, value
);
2660 if (!strcmpW(FeatureExternalParameterEntitiesW
, feature
) && value
== VARIANT_FALSE
)
2661 return set_feature_value(This
, ExternalParameterEntities
, value
);
2663 if (!strcmpW(FeatureLexicalHandlerParEntitiesW
, feature
))
2665 FIXME("(%p)->(%s %x) stub\n", This
, debugstr_w(feature
), value
);
2666 return set_feature_value(This
, LexicalHandlerParEntities
, value
);
2669 if (!strcmpW(FeatureProhibitDTDW
, feature
))
2671 FIXME("(%p)->(%s %x) stub\n", This
, debugstr_w(feature
), value
);
2672 return set_feature_value(This
, ProhibitDTD
, value
);
2675 if (!strcmpW(FeatureNamespacesW
, feature
) && value
== VARIANT_TRUE
)
2676 return set_feature_value(This
, Namespaces
, value
);
2678 FIXME("(%p)->(%s %x) stub\n", This
, debugstr_w(feature
), value
);
2682 static HRESULT WINAPI
saxxmlreader_getProperty(
2683 IVBSAXXMLReader
* iface
,
2687 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2688 return internal_getProperty(This
, prop
, value
, TRUE
);
2691 static HRESULT WINAPI
saxxmlreader_putProperty(
2692 IVBSAXXMLReader
* iface
,
2696 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2697 return internal_putProperty(This
, pProp
, value
, TRUE
);
2700 static HRESULT WINAPI
saxxmlreader_get_entityResolver(
2701 IVBSAXXMLReader
* iface
,
2702 IVBSAXEntityResolver
**pEntityResolver
)
2704 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2705 return internal_getEntityResolver(This
, pEntityResolver
, TRUE
);
2708 static HRESULT WINAPI
saxxmlreader_put_entityResolver(
2709 IVBSAXXMLReader
* iface
,
2710 IVBSAXEntityResolver
*pEntityResolver
)
2712 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2713 return internal_putEntityResolver(This
, pEntityResolver
, TRUE
);
2716 static HRESULT WINAPI
saxxmlreader_get_contentHandler(
2717 IVBSAXXMLReader
* iface
,
2718 IVBSAXContentHandler
**ppContentHandler
)
2720 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2721 return internal_getContentHandler(This
, ppContentHandler
, TRUE
);
2724 static HRESULT WINAPI
saxxmlreader_put_contentHandler(
2725 IVBSAXXMLReader
* iface
,
2726 IVBSAXContentHandler
*contentHandler
)
2728 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2729 return internal_putContentHandler(This
, contentHandler
, TRUE
);
2732 static HRESULT WINAPI
saxxmlreader_get_dtdHandler(
2733 IVBSAXXMLReader
* iface
,
2734 IVBSAXDTDHandler
**pDTDHandler
)
2736 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2737 return internal_getDTDHandler(This
, pDTDHandler
, TRUE
);
2740 static HRESULT WINAPI
saxxmlreader_put_dtdHandler(
2741 IVBSAXXMLReader
* iface
,
2742 IVBSAXDTDHandler
*pDTDHandler
)
2744 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2745 return internal_putDTDHandler(This
, pDTDHandler
, TRUE
);
2748 static HRESULT WINAPI
saxxmlreader_get_errorHandler(
2749 IVBSAXXMLReader
* iface
,
2750 IVBSAXErrorHandler
**pErrorHandler
)
2752 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2753 return internal_getErrorHandler(This
, pErrorHandler
, TRUE
);
2756 static HRESULT WINAPI
saxxmlreader_put_errorHandler(
2757 IVBSAXXMLReader
* iface
,
2758 IVBSAXErrorHandler
*errorHandler
)
2760 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2761 return internal_putErrorHandler(This
, errorHandler
, TRUE
);
2764 static HRESULT WINAPI
saxxmlreader_get_baseURL(
2765 IVBSAXXMLReader
* iface
,
2766 const WCHAR
**pBaseUrl
)
2768 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2770 FIXME("(%p)->(%p) stub\n", This
, pBaseUrl
);
2774 static HRESULT WINAPI
saxxmlreader_put_baseURL(
2775 IVBSAXXMLReader
* iface
,
2776 const WCHAR
*pBaseUrl
)
2778 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2780 FIXME("(%p)->(%s) stub\n", This
, debugstr_w(pBaseUrl
));
2784 static HRESULT WINAPI
saxxmlreader_get_secureBaseURL(
2785 IVBSAXXMLReader
* iface
,
2786 const WCHAR
**pSecureBaseUrl
)
2788 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2790 FIXME("(%p)->(%p) stub\n", This
, pSecureBaseUrl
);
2795 static HRESULT WINAPI
saxxmlreader_put_secureBaseURL(
2796 IVBSAXXMLReader
* iface
,
2797 const WCHAR
*secureBaseUrl
)
2799 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2801 FIXME("(%p)->(%s) stub\n", This
, debugstr_w(secureBaseUrl
));
2805 static HRESULT WINAPI
saxxmlreader_parse(
2806 IVBSAXXMLReader
* iface
,
2809 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2810 return internal_parse(This
, varInput
, TRUE
);
2813 static HRESULT WINAPI
saxxmlreader_parseURL(
2814 IVBSAXXMLReader
* iface
,
2817 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2818 return internal_parseURL(This
, url
, TRUE
);
2821 static const struct IVBSAXXMLReaderVtbl saxreader_vtbl
=
2823 saxxmlreader_QueryInterface
,
2824 saxxmlreader_AddRef
,
2825 saxxmlreader_Release
,
2826 saxxmlreader_GetTypeInfoCount
,
2827 saxxmlreader_GetTypeInfo
,
2828 saxxmlreader_GetIDsOfNames
,
2829 saxxmlreader_Invoke
,
2830 saxxmlreader_getFeature
,
2831 saxxmlreader_putFeature
,
2832 saxxmlreader_getProperty
,
2833 saxxmlreader_putProperty
,
2834 saxxmlreader_get_entityResolver
,
2835 saxxmlreader_put_entityResolver
,
2836 saxxmlreader_get_contentHandler
,
2837 saxxmlreader_put_contentHandler
,
2838 saxxmlreader_get_dtdHandler
,
2839 saxxmlreader_put_dtdHandler
,
2840 saxxmlreader_get_errorHandler
,
2841 saxxmlreader_put_errorHandler
,
2842 saxxmlreader_get_baseURL
,
2843 saxxmlreader_put_baseURL
,
2844 saxxmlreader_get_secureBaseURL
,
2845 saxxmlreader_put_secureBaseURL
,
2847 saxxmlreader_parseURL
2850 /*** ISAXXMLReader interface ***/
2851 /*** IUnknown methods ***/
2852 static HRESULT WINAPI
isaxxmlreader_QueryInterface(ISAXXMLReader
* iface
, REFIID riid
, void **ppvObject
)
2854 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2855 return saxxmlreader_QueryInterface(&This
->IVBSAXXMLReader_iface
, riid
, ppvObject
);
2858 static ULONG WINAPI
isaxxmlreader_AddRef(ISAXXMLReader
* iface
)
2860 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2861 return saxxmlreader_AddRef(&This
->IVBSAXXMLReader_iface
);
2864 static ULONG WINAPI
isaxxmlreader_Release(ISAXXMLReader
* iface
)
2866 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2867 return saxxmlreader_Release(&This
->IVBSAXXMLReader_iface
);
2870 /*** ISAXXMLReader methods ***/
2871 static HRESULT WINAPI
isaxxmlreader_getFeature(
2872 ISAXXMLReader
* iface
,
2873 const WCHAR
*pFeature
,
2874 VARIANT_BOOL
*pValue
)
2876 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2877 return IVBSAXXMLReader_getFeature(&This
->IVBSAXXMLReader_iface
, pFeature
, pValue
);
2880 static HRESULT WINAPI
isaxxmlreader_putFeature(
2881 ISAXXMLReader
* iface
,
2882 const WCHAR
*pFeature
,
2883 VARIANT_BOOL vfValue
)
2885 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2886 return IVBSAXXMLReader_putFeature(&This
->IVBSAXXMLReader_iface
, pFeature
, vfValue
);
2889 static HRESULT WINAPI
isaxxmlreader_getProperty(
2890 ISAXXMLReader
* iface
,
2894 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2895 return internal_getProperty(This
, prop
, value
, FALSE
);
2898 static HRESULT WINAPI
isaxxmlreader_putProperty(
2899 ISAXXMLReader
* iface
,
2903 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2904 return internal_putProperty(This
, pProp
, value
, FALSE
);
2907 static HRESULT WINAPI
isaxxmlreader_getEntityResolver(
2908 ISAXXMLReader
* iface
,
2909 ISAXEntityResolver
**ppEntityResolver
)
2911 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2912 return internal_getEntityResolver(This
, ppEntityResolver
, FALSE
);
2915 static HRESULT WINAPI
isaxxmlreader_putEntityResolver(
2916 ISAXXMLReader
* iface
,
2917 ISAXEntityResolver
*pEntityResolver
)
2919 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2920 return internal_putEntityResolver(This
, pEntityResolver
, FALSE
);
2923 static HRESULT WINAPI
isaxxmlreader_getContentHandler(
2924 ISAXXMLReader
* iface
,
2925 ISAXContentHandler
**pContentHandler
)
2927 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2928 return internal_getContentHandler(This
, pContentHandler
, FALSE
);
2931 static HRESULT WINAPI
isaxxmlreader_putContentHandler(
2932 ISAXXMLReader
* iface
,
2933 ISAXContentHandler
*contentHandler
)
2935 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2936 return internal_putContentHandler(This
, contentHandler
, FALSE
);
2939 static HRESULT WINAPI
isaxxmlreader_getDTDHandler(
2940 ISAXXMLReader
* iface
,
2941 ISAXDTDHandler
**pDTDHandler
)
2943 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2944 return internal_getDTDHandler(This
, pDTDHandler
, FALSE
);
2947 static HRESULT WINAPI
isaxxmlreader_putDTDHandler(
2948 ISAXXMLReader
* iface
,
2949 ISAXDTDHandler
*pDTDHandler
)
2951 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2952 return internal_putDTDHandler(This
, pDTDHandler
, FALSE
);
2955 static HRESULT WINAPI
isaxxmlreader_getErrorHandler(
2956 ISAXXMLReader
* iface
,
2957 ISAXErrorHandler
**pErrorHandler
)
2959 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2960 return internal_getErrorHandler(This
, pErrorHandler
, FALSE
);
2963 static HRESULT WINAPI
isaxxmlreader_putErrorHandler(
2964 ISAXXMLReader
* iface
,
2965 ISAXErrorHandler
*errorHandler
)
2967 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2968 return internal_putErrorHandler(This
, errorHandler
, FALSE
);
2971 static HRESULT WINAPI
isaxxmlreader_getBaseURL(
2972 ISAXXMLReader
* iface
,
2973 const WCHAR
**pBaseUrl
)
2975 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2976 return IVBSAXXMLReader_get_baseURL(&This
->IVBSAXXMLReader_iface
, pBaseUrl
);
2979 static HRESULT WINAPI
isaxxmlreader_putBaseURL(
2980 ISAXXMLReader
* iface
,
2981 const WCHAR
*pBaseUrl
)
2983 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2984 return IVBSAXXMLReader_put_baseURL(&This
->IVBSAXXMLReader_iface
, pBaseUrl
);
2987 static HRESULT WINAPI
isaxxmlreader_getSecureBaseURL(
2988 ISAXXMLReader
* iface
,
2989 const WCHAR
**pSecureBaseUrl
)
2991 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2992 return IVBSAXXMLReader_get_secureBaseURL(&This
->IVBSAXXMLReader_iface
, pSecureBaseUrl
);
2995 static HRESULT WINAPI
isaxxmlreader_putSecureBaseURL(
2996 ISAXXMLReader
* iface
,
2997 const WCHAR
*secureBaseUrl
)
2999 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3000 return IVBSAXXMLReader_put_secureBaseURL(&This
->IVBSAXXMLReader_iface
, secureBaseUrl
);
3003 static HRESULT WINAPI
isaxxmlreader_parse(
3004 ISAXXMLReader
* iface
,
3007 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3008 return internal_parse(This
, varInput
, FALSE
);
3011 static HRESULT WINAPI
isaxxmlreader_parseURL(
3012 ISAXXMLReader
* iface
,
3015 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
3016 return internal_parseURL(This
, url
, FALSE
);
3019 static const struct ISAXXMLReaderVtbl isaxreader_vtbl
=
3021 isaxxmlreader_QueryInterface
,
3022 isaxxmlreader_AddRef
,
3023 isaxxmlreader_Release
,
3024 isaxxmlreader_getFeature
,
3025 isaxxmlreader_putFeature
,
3026 isaxxmlreader_getProperty
,
3027 isaxxmlreader_putProperty
,
3028 isaxxmlreader_getEntityResolver
,
3029 isaxxmlreader_putEntityResolver
,
3030 isaxxmlreader_getContentHandler
,
3031 isaxxmlreader_putContentHandler
,
3032 isaxxmlreader_getDTDHandler
,
3033 isaxxmlreader_putDTDHandler
,
3034 isaxxmlreader_getErrorHandler
,
3035 isaxxmlreader_putErrorHandler
,
3036 isaxxmlreader_getBaseURL
,
3037 isaxxmlreader_putBaseURL
,
3038 isaxxmlreader_getSecureBaseURL
,
3039 isaxxmlreader_putSecureBaseURL
,
3040 isaxxmlreader_parse
,
3041 isaxxmlreader_parseURL
3044 HRESULT
SAXXMLReader_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
3048 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
3050 reader
= heap_alloc( sizeof (*reader
) );
3052 return E_OUTOFMEMORY
;
3054 reader
->IVBSAXXMLReader_iface
.lpVtbl
= &saxreader_vtbl
;
3055 reader
->ISAXXMLReader_iface
.lpVtbl
= &isaxreader_vtbl
;
3057 reader
->contentHandler
= NULL
;
3058 reader
->vbcontentHandler
= NULL
;
3059 reader
->errorHandler
= NULL
;
3060 reader
->vberrorHandler
= NULL
;
3061 reader
->lexicalHandler
= NULL
;
3062 reader
->vblexicalHandler
= NULL
;
3063 reader
->declHandler
= NULL
;
3064 reader
->vbdeclHandler
= NULL
;
3065 reader
->isParsing
= FALSE
;
3066 reader
->pool
.pool
= NULL
;
3067 reader
->pool
.index
= 0;
3068 reader
->pool
.len
= 0;
3069 reader
->features
= Namespaces
;
3071 memset(&reader
->sax
, 0, sizeof(xmlSAXHandler
));
3072 reader
->sax
.initialized
= XML_SAX2_MAGIC
;
3073 reader
->sax
.startDocument
= libxmlStartDocument
;
3074 reader
->sax
.endDocument
= libxmlEndDocument
;
3075 reader
->sax
.startElementNs
= libxmlStartElementNS
;
3076 reader
->sax
.endElementNs
= libxmlEndElementNS
;
3077 reader
->sax
.characters
= libxmlCharacters
;
3078 reader
->sax
.setDocumentLocator
= libxmlSetDocumentLocator
;
3079 reader
->sax
.comment
= libxmlComment
;
3080 reader
->sax
.error
= libxmlFatalError
;
3081 reader
->sax
.fatalError
= libxmlFatalError
;
3082 reader
->sax
.cdataBlock
= libxmlCDataBlock
;
3084 *ppObj
= &reader
->IVBSAXXMLReader_iface
;
3086 TRACE("returning iface %p\n", *ppObj
);
3093 HRESULT
SAXXMLReader_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
3095 MESSAGE("This program tried to use a SAX XML Reader object, but\n"
3096 "libxml2 support was not present at compile time.\n");