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
77 typedef struct _saxreader
79 IVBSAXXMLReader IVBSAXXMLReader_iface
;
80 ISAXXMLReader ISAXXMLReader_iface
;
82 struct ISAXContentHandler
*contentHandler
;
83 struct IVBSAXContentHandler
*vbcontentHandler
;
84 struct ISAXErrorHandler
*errorHandler
;
85 struct IVBSAXErrorHandler
*vberrorHandler
;
86 struct ISAXLexicalHandler
*lexicalHandler
;
87 struct IVBSAXLexicalHandler
*vblexicalHandler
;
88 struct ISAXDeclHandler
*declHandler
;
89 struct IVBSAXDeclHandler
*vbdeclHandler
;
93 enum ReaderFeatures features
;
96 typedef struct _saxlocator
98 IVBSAXLocator IVBSAXLocator_iface
;
99 ISAXLocator ISAXLocator_iface
;
101 saxreader
*saxreader
;
103 xmlParserCtxtPtr pParserCtxt
;
117 typedef struct _saxattributes
119 IVBSAXAttributes IVBSAXAttributes_iface
;
120 ISAXAttributes ISAXAttributes_iface
;
129 static inline saxreader
*impl_from_IVBSAXXMLReader( IVBSAXXMLReader
*iface
)
131 return CONTAINING_RECORD(iface
, saxreader
, IVBSAXXMLReader_iface
);
134 static inline saxreader
*impl_from_ISAXXMLReader( ISAXXMLReader
*iface
)
136 return CONTAINING_RECORD(iface
, saxreader
, ISAXXMLReader_iface
);
139 static inline saxlocator
*impl_from_IVBSAXLocator( IVBSAXLocator
*iface
)
141 return CONTAINING_RECORD(iface
, saxlocator
, IVBSAXLocator_iface
);
144 static inline saxlocator
*impl_from_ISAXLocator( ISAXLocator
*iface
)
146 return CONTAINING_RECORD(iface
, saxlocator
, ISAXLocator_iface
);
149 static inline saxattributes
*impl_from_IVBSAXAttributes( IVBSAXAttributes
*iface
)
151 return CONTAINING_RECORD(iface
, saxattributes
, IVBSAXAttributes_iface
);
154 static inline saxattributes
*impl_from_ISAXAttributes( ISAXAttributes
*iface
)
156 return CONTAINING_RECORD(iface
, saxattributes
, ISAXAttributes_iface
);
160 static const WCHAR PropertyCharsetW
[] = {
161 'c','h','a','r','s','e','t',0
163 static const WCHAR PropertyDeclHandlerW
[] = {
164 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
165 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
166 'd','e','c','l','a','r','a','t','i','o','n',
167 '-','h','a','n','d','l','e','r',0
169 static const WCHAR PropertyDomNodeW
[] = {
170 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
171 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
172 'd','o','m','-','n','o','d','e',0
174 static const WCHAR PropertyInputSourceW
[] = {
175 'i','n','p','u','t','-','s','o','u','r','c','e',0
177 static const WCHAR PropertyLexicalHandlerW
[] = {
178 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
179 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
180 'l','e','x','i','c','a','l','-','h','a','n','d','l','e','r',0
182 static const WCHAR PropertyMaxElementDepthW
[] = {
183 'm','a','x','-','e','l','e','m','e','n','t','-','d','e','p','t','h',0
185 static const WCHAR PropertyMaxXMLSizeW
[] = {
186 'm','a','x','-','x','m','l','-','s','i','z','e',0
188 static const WCHAR PropertySchemaDeclHandlerW
[] = {
189 's','c','h','e','m','a','-','d','e','c','l','a','r','a','t','i','o','n','-',
190 'h','a','n','d','l','e','r',0
192 static const WCHAR PropertyXMLDeclEncodingW
[] = {
193 'x','m','l','d','e','c','l','-','e','n','c','o','d','i','n','g',0
195 static const WCHAR PropertyXMLDeclStandaloneW
[] = {
196 'x','m','l','d','e','c','l','-','s','t','a','n','d','a','l','o','n','e',0
198 static const WCHAR PropertyXMLDeclVersionW
[] = {
199 'x','m','l','d','e','c','l','-','v','e','r','s','i','o','n',0
203 static const WCHAR FeatureExternalGeneralEntitiesW
[] = {
204 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/','s','a','x','/',
205 'f','e','a','t','u','r','e','s','/','e','x','t','e','r','n','a','l','-','g','e','n','e','r','a','l',
206 '-','e','n','t','i','t','i','e','s',0
209 static inline HRESULT
set_feature_value(saxreader
*reader
, enum ReaderFeatures feature
, VARIANT_BOOL value
)
211 if (value
== VARIANT_TRUE
)
212 reader
->features
|= feature
;
214 reader
->features
&= ~feature
;
219 static inline BOOL
has_content_handler(const saxlocator
*locator
)
221 return (locator
->vbInterface
&& locator
->saxreader
->vbcontentHandler
) ||
222 (!locator
->vbInterface
&& locator
->saxreader
->contentHandler
);
225 static inline BOOL
has_error_handler(const saxlocator
*locator
)
227 return (locator
->vbInterface
&& locator
->saxreader
->vberrorHandler
) ||
228 (!locator
->vbInterface
&& locator
->saxreader
->errorHandler
);
231 static HRESULT
namespacePush(saxlocator
*locator
, int ns
)
233 if(locator
->nsStackLast
>=locator
->nsStackSize
)
237 new_stack
= HeapReAlloc(GetProcessHeap(), 0,
238 locator
->nsStack
, sizeof(int)*locator
->nsStackSize
*2);
239 if(!new_stack
) return E_OUTOFMEMORY
;
240 locator
->nsStack
= new_stack
;
241 locator
->nsStackSize
*= 2;
243 locator
->nsStack
[locator
->nsStackLast
++] = ns
;
248 static int namespacePop(saxlocator
*locator
)
250 if(locator
->nsStackLast
== 0) return 0;
251 return locator
->nsStack
[--locator
->nsStackLast
];
254 static BOOL
bstr_pool_insert(struct bstrpool
*pool
, BSTR pool_entry
)
258 pool
->pool
= HeapAlloc(GetProcessHeap(), 0, 16 * sizeof(*pool
->pool
));
265 else if (pool
->index
== pool
->len
)
267 BSTR
*realloc
= HeapReAlloc(GetProcessHeap(), 0, pool
->pool
, pool
->len
* 2 * sizeof(*realloc
));
272 pool
->pool
= realloc
;
276 pool
->pool
[pool
->index
++] = pool_entry
;
280 static void free_bstr_pool(struct bstrpool
*pool
)
284 for (i
= 0; i
< pool
->index
; i
++)
285 SysFreeString(pool
->pool
[i
]);
287 HeapFree(GetProcessHeap(), 0, pool
->pool
);
290 pool
->index
= pool
->len
= 0;
293 static BSTR
bstr_from_xmlCharN(const xmlChar
*buf
, int len
)
301 dLen
= MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)buf
, len
, NULL
, 0);
302 if(len
!= -1) dLen
++;
303 bstr
= SysAllocStringLen(NULL
, dLen
-1);
306 MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)buf
, len
, bstr
, dLen
);
307 if(len
!= -1) bstr
[dLen
-1] = '\0';
312 static BSTR
QName_from_xmlChar(const xmlChar
*prefix
, const xmlChar
*name
)
317 if(!name
) return NULL
;
319 if(!prefix
|| !*prefix
)
320 return bstr_from_xmlChar(name
);
322 qname
= xmlBuildQName(name
, prefix
, NULL
, 0);
323 bstr
= bstr_from_xmlChar(qname
);
329 static BSTR
pooled_bstr_from_xmlChar(struct bstrpool
*pool
, const xmlChar
*buf
)
331 BSTR pool_entry
= bstr_from_xmlChar(buf
);
333 if (pool_entry
&& !bstr_pool_insert(pool
, pool_entry
))
335 SysFreeString(pool_entry
);
342 static BSTR
pooled_bstr_from_xmlCharN(struct bstrpool
*pool
, const xmlChar
*buf
, int len
)
344 BSTR pool_entry
= bstr_from_xmlCharN(buf
, len
);
346 if (pool_entry
&& !bstr_pool_insert(pool
, pool_entry
))
348 SysFreeString(pool_entry
);
355 static BSTR
pooled_QName_from_xmlChar(struct bstrpool
*pool
, const xmlChar
*prefix
, const xmlChar
*name
)
357 BSTR pool_entry
= QName_from_xmlChar(prefix
, name
);
359 if (pool_entry
&& !bstr_pool_insert(pool
, pool_entry
))
361 SysFreeString(pool_entry
);
368 static void format_error_message_from_id(saxlocator
*This
, HRESULT hr
)
370 xmlStopParser(This
->pParserCtxt
);
373 if(has_error_handler(This
))
376 if(!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
,
377 NULL
, hr
, 0, msg
, sizeof(msg
), NULL
))
379 FIXME("MSXML errors not yet supported.\n");
383 if(This
->vbInterface
)
385 BSTR bstrMsg
= SysAllocString(msg
);
386 IVBSAXErrorHandler_fatalError(This
->saxreader
->vberrorHandler
,
387 &This
->IVBSAXLocator_iface
, &bstrMsg
, hr
);
388 SysFreeString(bstrMsg
);
391 ISAXErrorHandler_fatalError(This
->saxreader
->errorHandler
,
392 &This
->ISAXLocator_iface
, msg
, hr
);
396 static void update_position(saxlocator
*This
, xmlChar
*end
)
398 if(This
->lastCur
== NULL
)
400 This
->lastCur
= (xmlChar
*)This
->pParserCtxt
->input
->base
;
402 This
->realColumn
= 1;
404 else if(This
->lastCur
< This
->pParserCtxt
->input
->base
)
406 This
->lastCur
= (xmlChar
*)This
->pParserCtxt
->input
->base
;
408 This
->realColumn
= 1;
411 if(This
->pParserCtxt
->input
->cur
<This
->lastCur
)
413 This
->lastCur
= (xmlChar
*)This
->pParserCtxt
->input
->base
;
415 This
->realColumn
= 1;
418 if(!end
) end
= (xmlChar
*)This
->pParserCtxt
->input
->cur
;
420 while(This
->lastCur
< end
)
422 if(*(This
->lastCur
) == '\n')
425 This
->realColumn
= 1;
427 else if(*(This
->lastCur
) == '\r' &&
428 (This
->lastCur
==This
->pParserCtxt
->input
->end
||
429 *(This
->lastCur
+1)!='\n'))
432 This
->realColumn
= 1;
434 else This
->realColumn
++;
438 /* Count multibyte UTF8 encoded characters once */
439 while((*(This
->lastCur
)&0xC0) == 0x80) This
->lastCur
++;
442 This
->line
= This
->realLine
;
443 This
->column
= This
->realColumn
;
446 /*** IVBSAXAttributes interface ***/
447 /*** IUnknown methods ***/
448 static HRESULT WINAPI
ivbsaxattributes_QueryInterface(
449 IVBSAXAttributes
* iface
,
453 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
455 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
459 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
460 IsEqualGUID(riid
, &IID_IDispatch
) ||
461 IsEqualGUID(riid
, &IID_IVBSAXAttributes
))
467 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
468 return E_NOINTERFACE
;
471 IVBSAXAttributes_AddRef(iface
);
476 static ULONG WINAPI
ivbsaxattributes_AddRef(IVBSAXAttributes
* iface
)
478 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
479 return ISAXAttributes_AddRef(&This
->ISAXAttributes_iface
);
482 static ULONG WINAPI
ivbsaxattributes_Release(IVBSAXAttributes
* iface
)
484 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
485 return ISAXAttributes_Release(&This
->ISAXAttributes_iface
);
488 /*** IDispatch methods ***/
489 static HRESULT WINAPI
ivbsaxattributes_GetTypeInfoCount( IVBSAXAttributes
*iface
, UINT
* pctinfo
)
491 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
493 TRACE("(%p)->(%p)\n", This
, pctinfo
);
500 static HRESULT WINAPI
ivbsaxattributes_GetTypeInfo(
501 IVBSAXAttributes
*iface
,
502 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
504 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
507 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
509 hr
= get_typeinfo(IVBSAXAttributes_tid
, ppTInfo
);
514 static HRESULT WINAPI
ivbsaxattributes_GetIDsOfNames(
515 IVBSAXAttributes
*iface
,
522 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
526 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
529 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
532 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
535 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
536 ITypeInfo_Release(typeinfo
);
542 static HRESULT WINAPI
ivbsaxattributes_Invoke(
543 IVBSAXAttributes
*iface
,
548 DISPPARAMS
* pDispParams
,
550 EXCEPINFO
* pExcepInfo
,
553 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
557 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
558 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
560 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
563 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IVBSAXAttributes_iface
, dispIdMember
, wFlags
,
564 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
565 ITypeInfo_Release(typeinfo
);
571 /*** IVBSAXAttributes methods ***/
572 static HRESULT WINAPI
ivbsaxattributes_get_length(
573 IVBSAXAttributes
* iface
,
576 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
577 return ISAXAttributes_getLength(&This
->ISAXAttributes_iface
, nLength
);
580 static HRESULT WINAPI
ivbsaxattributes_getURI(
581 IVBSAXAttributes
* iface
,
586 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
587 return ISAXAttributes_getURI(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)uri
, &len
);
590 static HRESULT WINAPI
ivbsaxattributes_getLocalName(
591 IVBSAXAttributes
* iface
,
596 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
597 return ISAXAttributes_getLocalName(&This
->ISAXAttributes_iface
, nIndex
,
598 (const WCHAR
**)localName
, &len
);
601 static HRESULT WINAPI
ivbsaxattributes_getQName(
602 IVBSAXAttributes
* iface
,
607 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
608 return ISAXAttributes_getQName(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)QName
, &len
);
611 static HRESULT WINAPI
ivbsaxattributes_getIndexFromName(
612 IVBSAXAttributes
* iface
,
617 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
618 return ISAXAttributes_getIndexFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
619 localName
, SysStringLen(localName
), index
);
622 static HRESULT WINAPI
ivbsaxattributes_getIndexFromQName(
623 IVBSAXAttributes
* iface
,
627 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
628 return ISAXAttributes_getIndexFromQName(&This
->ISAXAttributes_iface
, QName
,
629 SysStringLen(QName
), index
);
632 static HRESULT WINAPI
ivbsaxattributes_getType(
633 IVBSAXAttributes
* iface
,
638 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
639 return ISAXAttributes_getType(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)type
, &len
);
642 static HRESULT WINAPI
ivbsaxattributes_getTypeFromName(
643 IVBSAXAttributes
* iface
,
649 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
650 return ISAXAttributes_getTypeFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
651 localName
, SysStringLen(localName
), (const WCHAR
**)type
, &len
);
654 static HRESULT WINAPI
ivbsaxattributes_getTypeFromQName(
655 IVBSAXAttributes
* iface
,
660 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
661 return ISAXAttributes_getTypeFromQName(&This
->ISAXAttributes_iface
, QName
, SysStringLen(QName
),
662 (const WCHAR
**)type
, &len
);
665 static HRESULT WINAPI
ivbsaxattributes_getValue(
666 IVBSAXAttributes
* iface
,
671 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
672 return ISAXAttributes_getValue(&This
->ISAXAttributes_iface
, nIndex
, (const WCHAR
**)value
, &len
);
675 static HRESULT WINAPI
ivbsaxattributes_getValueFromName(
676 IVBSAXAttributes
* iface
,
682 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
683 return ISAXAttributes_getValueFromName(&This
->ISAXAttributes_iface
, uri
, SysStringLen(uri
),
684 localName
, SysStringLen(localName
), (const WCHAR
**)value
, &len
);
687 static HRESULT WINAPI
ivbsaxattributes_getValueFromQName(
688 IVBSAXAttributes
* iface
,
693 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
694 return ISAXAttributes_getValueFromQName(&This
->ISAXAttributes_iface
, QName
,
695 SysStringLen(QName
), (const WCHAR
**)value
, &len
);
698 static const struct IVBSAXAttributesVtbl ivbsaxattributes_vtbl
=
700 ivbsaxattributes_QueryInterface
,
701 ivbsaxattributes_AddRef
,
702 ivbsaxattributes_Release
,
703 ivbsaxattributes_GetTypeInfoCount
,
704 ivbsaxattributes_GetTypeInfo
,
705 ivbsaxattributes_GetIDsOfNames
,
706 ivbsaxattributes_Invoke
,
707 ivbsaxattributes_get_length
,
708 ivbsaxattributes_getURI
,
709 ivbsaxattributes_getLocalName
,
710 ivbsaxattributes_getQName
,
711 ivbsaxattributes_getIndexFromName
,
712 ivbsaxattributes_getIndexFromQName
,
713 ivbsaxattributes_getType
,
714 ivbsaxattributes_getTypeFromName
,
715 ivbsaxattributes_getTypeFromQName
,
716 ivbsaxattributes_getValue
,
717 ivbsaxattributes_getValueFromName
,
718 ivbsaxattributes_getValueFromQName
721 /*** ISAXAttributes interface ***/
722 /*** IUnknown methods ***/
723 static HRESULT WINAPI
isaxattributes_QueryInterface(
724 ISAXAttributes
* iface
,
728 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
730 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
734 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
735 IsEqualGUID(riid
, &IID_ISAXAttributes
))
741 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
742 return E_NOINTERFACE
;
745 ISAXAttributes_AddRef(iface
);
750 static ULONG WINAPI
isaxattributes_AddRef(ISAXAttributes
* iface
)
752 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
754 return InterlockedIncrement(&This
->ref
);
757 static ULONG WINAPI
isaxattributes_Release(ISAXAttributes
* iface
)
759 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
764 ref
= InterlockedDecrement(&This
->ref
);
768 for(index
=0; index
<This
->nb_attributes
; index
++)
770 SysFreeString(This
->szLocalname
[index
]);
771 SysFreeString(This
->szURI
[index
]);
772 SysFreeString(This
->szValue
[index
]);
773 SysFreeString(This
->szQName
[index
]);
776 heap_free(This
->szLocalname
);
777 heap_free(This
->szURI
);
778 heap_free(This
->szValue
);
779 heap_free(This
->szQName
);
787 /*** ISAXAttributes methods ***/
788 static HRESULT WINAPI
isaxattributes_getLength(
789 ISAXAttributes
* iface
,
792 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
794 *length
= This
->nb_attributes
;
795 TRACE("Length set to %d\n", *length
);
799 static HRESULT WINAPI
isaxattributes_getURI(
800 ISAXAttributes
* iface
,
805 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
806 TRACE("(%p)->(%d)\n", This
, nIndex
);
808 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
809 if(!pUrl
|| !pUriSize
) return E_POINTER
;
811 *pUriSize
= SysStringLen(This
->szURI
[nIndex
]);
812 *pUrl
= This
->szURI
[nIndex
];
817 static HRESULT WINAPI
isaxattributes_getLocalName(
818 ISAXAttributes
* iface
,
820 const WCHAR
**pLocalName
,
821 int *pLocalNameLength
)
823 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
824 TRACE("(%p)->(%d)\n", This
, nIndex
);
826 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
827 if(!pLocalName
|| !pLocalNameLength
) return E_POINTER
;
829 *pLocalNameLength
= SysStringLen(This
->szLocalname
[nIndex
]);
830 *pLocalName
= This
->szLocalname
[nIndex
];
835 static HRESULT WINAPI
isaxattributes_getQName(
836 ISAXAttributes
* iface
,
838 const WCHAR
**pQName
,
841 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
842 TRACE("(%p)->(%d)\n", This
, nIndex
);
844 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
845 if(!pQName
|| !pQNameLength
) return E_POINTER
;
847 *pQNameLength
= SysStringLen(This
->szQName
[nIndex
]);
848 *pQName
= This
->szQName
[nIndex
];
853 static HRESULT WINAPI
isaxattributes_getName(
854 ISAXAttributes
* iface
,
858 const WCHAR
**pLocalName
,
860 const WCHAR
**pQName
,
863 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
864 TRACE("(%p)->(%d)\n", This
, nIndex
);
866 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
867 if(!pUri
|| !pUriLength
|| !pLocalName
|| !pLocalNameSize
868 || !pQName
|| !pQNameLength
) return E_POINTER
;
870 *pUriLength
= SysStringLen(This
->szURI
[nIndex
]);
871 *pUri
= This
->szURI
[nIndex
];
872 *pLocalNameSize
= SysStringLen(This
->szLocalname
[nIndex
]);
873 *pLocalName
= This
->szLocalname
[nIndex
];
874 *pQNameLength
= SysStringLen(This
->szQName
[nIndex
]);
875 *pQName
= This
->szQName
[nIndex
];
880 static HRESULT WINAPI
isaxattributes_getIndexFromName(
881 ISAXAttributes
* iface
,
884 const WCHAR
*pLocalName
,
888 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
890 TRACE("(%p)->(%s, %d, %s, %d)\n", This
, debugstr_w(pUri
), cUriLength
,
891 debugstr_w(pLocalName
), cocalNameLength
);
893 if(!pUri
|| !pLocalName
|| !index
) return E_POINTER
;
895 for(i
=0; i
<This
->nb_attributes
; i
++)
897 if(cUriLength
!=SysStringLen(This
->szURI
[i
])
898 || cocalNameLength
!=SysStringLen(This
->szLocalname
[i
]))
900 if(cUriLength
&& memcmp(pUri
, This
->szURI
[i
],
901 sizeof(WCHAR
)*cUriLength
))
903 if(cocalNameLength
&& memcmp(pLocalName
, This
->szLocalname
[i
],
904 sizeof(WCHAR
)*cocalNameLength
))
914 static HRESULT WINAPI
isaxattributes_getIndexFromQName(
915 ISAXAttributes
* iface
,
920 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
922 TRACE("(%p)->(%s, %d)\n", This
, debugstr_w(pQName
), nQNameLength
);
924 if(!pQName
|| !index
) return E_POINTER
;
925 if(!nQNameLength
) return E_INVALIDARG
;
927 for(i
=0; i
<This
->nb_attributes
; i
++)
929 if(nQNameLength
!=SysStringLen(This
->szQName
[i
])) continue;
930 if(memcmp(pQName
, This
->szQName
, sizeof(WCHAR
)*nQNameLength
)) continue;
939 static HRESULT WINAPI
isaxattributes_getType(
940 ISAXAttributes
* iface
,
945 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
947 FIXME("(%p)->(%d) stub\n", This
, nIndex
);
951 static HRESULT WINAPI
isaxattributes_getTypeFromName(
952 ISAXAttributes
* iface
,
955 const WCHAR
*pLocalName
,
960 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
962 FIXME("(%p)->(%s, %d, %s, %d) stub\n", This
, debugstr_w(pUri
), nUri
,
963 debugstr_w(pLocalName
), nLocalName
);
967 static HRESULT WINAPI
isaxattributes_getTypeFromQName(
968 ISAXAttributes
* iface
,
974 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
976 FIXME("(%p)->(%s, %d) stub\n", This
, debugstr_w(pQName
), nQName
);
980 static HRESULT WINAPI
isaxattributes_getValue(
981 ISAXAttributes
* iface
,
983 const WCHAR
**pValue
,
986 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
987 TRACE("(%p)->(%d)\n", This
, nIndex
);
989 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
990 if(!pValue
|| !nValue
) return E_POINTER
;
992 *nValue
= SysStringLen(This
->szValue
[nIndex
]);
993 *pValue
= This
->szValue
[nIndex
];
998 static HRESULT WINAPI
isaxattributes_getValueFromName(
999 ISAXAttributes
* iface
,
1002 const WCHAR
*pLocalName
,
1004 const WCHAR
**pValue
,
1009 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
1010 TRACE("(%p)->(%s, %d, %s, %d)\n", This
, debugstr_w(pUri
), nUri
,
1011 debugstr_w(pLocalName
), nLocalName
);
1013 hr
= ISAXAttributes_getIndexFromName(iface
,
1014 pUri
, nUri
, pLocalName
, nLocalName
, &index
);
1015 if(hr
==S_OK
) hr
= ISAXAttributes_getValue(iface
, index
, pValue
, nValue
);
1020 static HRESULT WINAPI
isaxattributes_getValueFromQName(
1021 ISAXAttributes
* iface
,
1022 const WCHAR
*pQName
,
1024 const WCHAR
**pValue
,
1029 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
1030 TRACE("(%p)->(%s, %d)\n", This
, debugstr_w(pQName
), nQName
);
1032 hr
= ISAXAttributes_getIndexFromQName(iface
, pQName
, nQName
, &index
);
1033 if(hr
==S_OK
) hr
= ISAXAttributes_getValue(iface
, index
, pValue
, nValue
);
1038 static const struct ISAXAttributesVtbl isaxattributes_vtbl
=
1040 isaxattributes_QueryInterface
,
1041 isaxattributes_AddRef
,
1042 isaxattributes_Release
,
1043 isaxattributes_getLength
,
1044 isaxattributes_getURI
,
1045 isaxattributes_getLocalName
,
1046 isaxattributes_getQName
,
1047 isaxattributes_getName
,
1048 isaxattributes_getIndexFromName
,
1049 isaxattributes_getIndexFromQName
,
1050 isaxattributes_getType
,
1051 isaxattributes_getTypeFromName
,
1052 isaxattributes_getTypeFromQName
,
1053 isaxattributes_getValue
,
1054 isaxattributes_getValueFromName
,
1055 isaxattributes_getValueFromQName
1058 static HRESULT
SAXAttributes_create(saxattributes
**attr
,
1059 int nb_namespaces
, const xmlChar
**xmlNamespaces
,
1060 int nb_attributes
, const xmlChar
**xmlAttributes
)
1062 saxattributes
*attributes
;
1064 static const xmlChar xmlns
[] = "xmlns";
1066 attributes
= heap_alloc(sizeof(*attributes
));
1068 return E_OUTOFMEMORY
;
1070 attributes
->IVBSAXAttributes_iface
.lpVtbl
= &ivbsaxattributes_vtbl
;
1071 attributes
->ISAXAttributes_iface
.lpVtbl
= &isaxattributes_vtbl
;
1072 attributes
->ref
= 1;
1074 attributes
->nb_attributes
= nb_namespaces
+nb_attributes
;
1076 attributes
->szLocalname
= heap_alloc(sizeof(BSTR
)*attributes
->nb_attributes
);
1077 attributes
->szURI
= heap_alloc(sizeof(BSTR
)*attributes
->nb_attributes
);
1078 attributes
->szValue
= heap_alloc(sizeof(BSTR
)*attributes
->nb_attributes
);
1079 attributes
->szQName
= heap_alloc(sizeof(BSTR
)*attributes
->nb_attributes
);
1081 if(!attributes
->szLocalname
|| !attributes
->szURI
1082 || !attributes
->szValue
|| !attributes
->szQName
)
1084 heap_free(attributes
->szLocalname
);
1085 heap_free(attributes
->szURI
);
1086 heap_free(attributes
->szValue
);
1087 heap_free(attributes
->szQName
);
1088 heap_free(attributes
);
1092 for(index
=0; index
<nb_namespaces
; index
++)
1094 attributes
->szLocalname
[index
] = SysAllocStringLen(NULL
, 0);
1095 attributes
->szURI
[index
] = SysAllocStringLen(NULL
, 0);
1096 attributes
->szValue
[index
] = bstr_from_xmlChar(xmlNamespaces
[2*index
+1]);
1097 attributes
->szQName
[index
] = QName_from_xmlChar(xmlns
, xmlNamespaces
[2*index
]);
1100 for(index
=0; index
<nb_attributes
; index
++)
1102 attributes
->szLocalname
[nb_namespaces
+index
] =
1103 bstr_from_xmlChar(xmlAttributes
[index
*5]);
1104 attributes
->szURI
[nb_namespaces
+index
] =
1105 bstr_from_xmlChar(xmlAttributes
[index
*5+2]);
1106 attributes
->szValue
[nb_namespaces
+index
] =
1107 bstr_from_xmlCharN(xmlAttributes
[index
*5+3],
1108 xmlAttributes
[index
*5+4]-xmlAttributes
[index
*5+3]);
1109 attributes
->szQName
[nb_namespaces
+index
] =
1110 QName_from_xmlChar(xmlAttributes
[index
*5+1], xmlAttributes
[index
*5]);
1115 TRACE("returning %p\n", *attr
);
1120 /*** LibXML callbacks ***/
1121 static void libxmlStartDocument(void *ctx
)
1123 saxlocator
*This
= ctx
;
1126 if(has_content_handler(This
))
1128 if(This
->vbInterface
)
1129 hr
= IVBSAXContentHandler_startDocument(This
->saxreader
->vbcontentHandler
);
1131 hr
= ISAXContentHandler_startDocument(This
->saxreader
->contentHandler
);
1134 format_error_message_from_id(This
, hr
);
1137 update_position(This
, NULL
);
1140 static void libxmlEndDocument(void *ctx
)
1142 saxlocator
*This
= ctx
;
1148 if(This
->ret
!= S_OK
) return;
1150 if(has_content_handler(This
))
1152 if(This
->vbInterface
)
1153 hr
= IVBSAXContentHandler_endDocument(This
->saxreader
->vbcontentHandler
);
1155 hr
= ISAXContentHandler_endDocument(This
->saxreader
->contentHandler
);
1158 format_error_message_from_id(This
, hr
);
1162 static void libxmlStartElementNS(
1164 const xmlChar
*localname
,
1165 const xmlChar
*prefix
,
1168 const xmlChar
**namespaces
,
1171 const xmlChar
**attributes
)
1173 BSTR NamespaceUri
, LocalName
, QName
, Prefix
, Uri
;
1174 saxlocator
*This
= ctx
;
1176 saxattributes
*attr
;
1179 if(*(This
->pParserCtxt
->input
->cur
) == '/')
1180 update_position(This
, (xmlChar
*)This
->pParserCtxt
->input
->cur
+2);
1182 update_position(This
, (xmlChar
*)This
->pParserCtxt
->input
->cur
+1);
1184 hr
= namespacePush(This
, nb_namespaces
);
1185 if(hr
==S_OK
&& has_content_handler(This
))
1187 for(index
=0; index
<nb_namespaces
; index
++)
1189 Prefix
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, namespaces
[2*index
]);
1190 Uri
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, namespaces
[2*index
+1]);
1192 if(This
->vbInterface
)
1193 hr
= IVBSAXContentHandler_startPrefixMapping(
1194 This
->saxreader
->vbcontentHandler
,
1197 hr
= ISAXContentHandler_startPrefixMapping(
1198 This
->saxreader
->contentHandler
,
1199 Prefix
, SysStringLen(Prefix
),
1200 Uri
, SysStringLen(Uri
));
1204 format_error_message_from_id(This
, hr
);
1209 NamespaceUri
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, URI
);
1210 LocalName
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, localname
);
1211 QName
= pooled_QName_from_xmlChar(&This
->saxreader
->pool
, prefix
, localname
);
1213 hr
= SAXAttributes_create(&attr
, nb_namespaces
, namespaces
, nb_attributes
, attributes
);
1216 if(This
->vbInterface
)
1217 hr
= IVBSAXContentHandler_startElement(This
->saxreader
->vbcontentHandler
,
1218 &NamespaceUri
, &LocalName
, &QName
, &attr
->IVBSAXAttributes_iface
);
1220 hr
= ISAXContentHandler_startElement(This
->saxreader
->contentHandler
, NamespaceUri
,
1221 SysStringLen(NamespaceUri
), LocalName
, SysStringLen(LocalName
), QName
,
1222 SysStringLen(QName
), &attr
->ISAXAttributes_iface
);
1224 ISAXAttributes_Release(&attr
->ISAXAttributes_iface
);
1229 format_error_message_from_id(This
, hr
);
1232 static void libxmlEndElementNS(
1234 const xmlChar
*localname
,
1235 const xmlChar
*prefix
,
1238 BSTR NamespaceUri
, LocalName
, QName
, Prefix
;
1239 saxlocator
*This
= ctx
;
1244 end
= (xmlChar
*)This
->pParserCtxt
->input
->cur
;
1245 if(*(end
-1) != '>' || *(end
-2) != '/')
1246 while(end
-2>=This
->pParserCtxt
->input
->base
1247 && *(end
-2)!='<' && *(end
-1)!='/') end
--;
1249 update_position(This
, end
);
1251 nsNr
= namespacePop(This
);
1253 if(has_content_handler(This
))
1255 NamespaceUri
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, URI
);
1256 LocalName
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, localname
);
1257 QName
= pooled_QName_from_xmlChar(&This
->saxreader
->pool
, prefix
, localname
);
1259 if(This
->vbInterface
)
1260 hr
= IVBSAXContentHandler_endElement(
1261 This
->saxreader
->vbcontentHandler
,
1262 &NamespaceUri
, &LocalName
, &QName
);
1264 hr
= ISAXContentHandler_endElement(
1265 This
->saxreader
->contentHandler
,
1266 NamespaceUri
, SysStringLen(NamespaceUri
),
1267 LocalName
, SysStringLen(LocalName
),
1268 QName
, SysStringLen(QName
));
1272 format_error_message_from_id(This
, hr
);
1276 for(index
=This
->pParserCtxt
->nsNr
-2;
1277 index
>=This
->pParserCtxt
->nsNr
-nsNr
*2; index
-=2)
1279 Prefix
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, This
->pParserCtxt
->nsTab
[index
]);
1281 if(This
->vbInterface
)
1282 hr
= IVBSAXContentHandler_endPrefixMapping(
1283 This
->saxreader
->vbcontentHandler
, &Prefix
);
1285 hr
= ISAXContentHandler_endPrefixMapping(
1286 This
->saxreader
->contentHandler
,
1287 Prefix
, SysStringLen(Prefix
));
1291 format_error_message_from_id(This
, hr
);
1298 update_position(This
, NULL
);
1301 static void libxmlCharacters(
1306 saxlocator
*This
= ctx
;
1311 BOOL lastEvent
= FALSE
;
1313 if(!(has_content_handler(This
))) return;
1316 if(*(ch
-1)=='\r') cur
--;
1319 if(ch
<This
->pParserCtxt
->input
->base
|| ch
>This
->pParserCtxt
->input
->end
)
1324 while(end
-ch
<len
&& *end
!='\r') end
++;
1331 if(!lastEvent
) *end
= '\n';
1333 Chars
= pooled_bstr_from_xmlCharN(&This
->saxreader
->pool
, cur
, end
-cur
+1);
1334 if(This
->vbInterface
)
1335 hr
= IVBSAXContentHandler_characters(
1336 This
->saxreader
->vbcontentHandler
, &Chars
);
1338 hr
= ISAXContentHandler_characters(
1339 This
->saxreader
->contentHandler
,
1340 Chars
, SysStringLen(Chars
));
1344 format_error_message_from_id(This
, hr
);
1348 This
->column
+= end
-cur
+1;
1362 if(end
-ch
== len
) break;
1365 if(ch
<This
->pParserCtxt
->input
->base
|| ch
>This
->pParserCtxt
->input
->end
)
1366 This
->column
= This
->realColumn
1367 +This
->pParserCtxt
->input
->cur
-This
->lastCur
;
1370 static void libxmlSetDocumentLocator(
1372 xmlSAXLocatorPtr loc
)
1374 saxlocator
*This
= ctx
;
1377 if(has_content_handler(This
))
1379 if(This
->vbInterface
)
1380 hr
= IVBSAXContentHandler_putref_documentLocator(This
->saxreader
->vbcontentHandler
,
1381 &This
->IVBSAXLocator_iface
);
1383 hr
= ISAXContentHandler_putDocumentLocator(This
->saxreader
->contentHandler
,
1384 &This
->ISAXLocator_iface
);
1388 format_error_message_from_id(This
, hr
);
1391 static void libxmlComment(void *ctx
, const xmlChar
*value
)
1393 saxlocator
*This
= ctx
;
1396 xmlChar
*beg
= (xmlChar
*)This
->pParserCtxt
->input
->cur
;
1398 while(beg
-4>=This
->pParserCtxt
->input
->base
1399 && memcmp(beg
-4, "<!--", sizeof(char[4]))) beg
--;
1400 update_position(This
, beg
);
1402 if(!This
->vbInterface
&& !This
->saxreader
->lexicalHandler
) return;
1403 if(This
->vbInterface
&& !This
->saxreader
->vblexicalHandler
) return;
1405 bValue
= pooled_bstr_from_xmlChar(&This
->saxreader
->pool
, value
);
1407 if(This
->vbInterface
)
1408 hr
= IVBSAXLexicalHandler_comment(
1409 This
->saxreader
->vblexicalHandler
, &bValue
);
1411 hr
= ISAXLexicalHandler_comment(
1412 This
->saxreader
->lexicalHandler
,
1413 bValue
, SysStringLen(bValue
));
1416 format_error_message_from_id(This
, hr
);
1418 update_position(This
, NULL
);
1421 static void libxmlFatalError(void *ctx
, const char *msg
, ...)
1423 saxlocator
*This
= ctx
;
1429 va_start(args
, msg
);
1430 vsprintf(message
, msg
, args
);
1433 len
= MultiByteToWideChar(CP_UNIXCP
, 0, message
, -1, NULL
, 0);
1434 error
= heap_alloc(sizeof(WCHAR
)*len
);
1437 MultiByteToWideChar(CP_UNIXCP
, 0, message
, -1, error
, len
);
1438 TRACE("fatal error for %p: %s\n", This
, debugstr_w(error
));
1441 if(!has_error_handler(This
))
1443 xmlStopParser(This
->pParserCtxt
);
1449 FIXME("Error handling is not compatible.\n");
1451 if(This
->vbInterface
)
1453 BSTR bstrError
= SysAllocString(error
);
1454 IVBSAXErrorHandler_fatalError(This
->saxreader
->vberrorHandler
, &This
->IVBSAXLocator_iface
,
1455 &bstrError
, E_FAIL
);
1456 SysFreeString(bstrError
);
1459 ISAXErrorHandler_fatalError(This
->saxreader
->errorHandler
, &This
->ISAXLocator_iface
,
1464 xmlStopParser(This
->pParserCtxt
);
1468 static void libxmlCDataBlock(void *ctx
, const xmlChar
*value
, int len
)
1470 saxlocator
*This
= ctx
;
1472 xmlChar
*beg
= (xmlChar
*)This
->pParserCtxt
->input
->cur
-len
;
1476 BOOL lastEvent
= FALSE
, change
;
1478 while(beg
-9>=This
->pParserCtxt
->input
->base
1479 && memcmp(beg
-9, "<![CDATA[", sizeof(char[9]))) beg
--;
1480 update_position(This
, beg
);
1482 if(This
->vbInterface
&& This
->saxreader
->vblexicalHandler
)
1483 hr
= IVBSAXLexicalHandler_startCDATA(This
->saxreader
->vblexicalHandler
);
1484 if(!This
->vbInterface
&& This
->saxreader
->lexicalHandler
)
1485 hr
= ISAXLexicalHandler_startCDATA(This
->saxreader
->lexicalHandler
);
1489 format_error_message_from_id(This
, hr
);
1493 realLen
= This
->pParserCtxt
->input
->cur
-beg
-3;
1499 while(end
-beg
<realLen
&& *end
!='\r') end
++;
1500 if(end
-beg
==realLen
)
1505 else if(end
-beg
==realLen
-1 && *end
=='\r' && *(end
+1)=='\n')
1508 if(*end
== '\r') change
= TRUE
;
1509 else change
= FALSE
;
1511 if(change
) *end
= '\n';
1513 if(has_content_handler(This
))
1515 Chars
= pooled_bstr_from_xmlCharN(&This
->saxreader
->pool
, cur
, end
-cur
+1);
1516 if(This
->vbInterface
)
1517 hr
= IVBSAXContentHandler_characters(
1518 This
->saxreader
->vbcontentHandler
, &Chars
);
1520 hr
= ISAXContentHandler_characters(
1521 This
->saxreader
->contentHandler
,
1522 Chars
, SysStringLen(Chars
));
1525 if(change
) *end
= '\r';
1530 This
->column
+= end
-cur
+2;
1535 if(This
->vbInterface
&& This
->saxreader
->vblexicalHandler
)
1536 hr
= IVBSAXLexicalHandler_endCDATA(This
->saxreader
->vblexicalHandler
);
1537 if(!This
->vbInterface
&& This
->saxreader
->lexicalHandler
)
1538 hr
= ISAXLexicalHandler_endCDATA(This
->saxreader
->lexicalHandler
);
1541 format_error_message_from_id(This
, hr
);
1543 This
->column
+= 4+end
-cur
;
1546 /*** IVBSAXLocator interface ***/
1547 /*** IUnknown methods ***/
1548 static HRESULT WINAPI
ivbsaxlocator_QueryInterface(IVBSAXLocator
* iface
, REFIID riid
, void **ppvObject
)
1550 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1552 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
1556 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
1557 IsEqualGUID( riid
, &IID_IDispatch
) ||
1558 IsEqualGUID( riid
, &IID_IVBSAXLocator
))
1564 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1565 return E_NOINTERFACE
;
1568 IVBSAXLocator_AddRef( iface
);
1573 static ULONG WINAPI
ivbsaxlocator_AddRef(IVBSAXLocator
* iface
)
1575 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1576 TRACE("%p\n", This
);
1577 return InterlockedIncrement( &This
->ref
);
1580 static ULONG WINAPI
ivbsaxlocator_Release(
1581 IVBSAXLocator
* iface
)
1583 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1584 return ISAXLocator_Release((ISAXLocator
*)&This
->IVBSAXLocator_iface
);
1587 /*** IDispatch methods ***/
1588 static HRESULT WINAPI
ivbsaxlocator_GetTypeInfoCount( IVBSAXLocator
*iface
, UINT
* pctinfo
)
1590 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1592 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1599 static HRESULT WINAPI
ivbsaxlocator_GetTypeInfo(
1600 IVBSAXLocator
*iface
,
1601 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
1603 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1606 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1608 hr
= get_typeinfo(IVBSAXLocator_tid
, ppTInfo
);
1613 static HRESULT WINAPI
ivbsaxlocator_GetIDsOfNames(
1614 IVBSAXLocator
*iface
,
1616 LPOLESTR
* rgszNames
,
1621 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1622 ITypeInfo
*typeinfo
;
1625 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1628 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
1629 return E_INVALIDARG
;
1631 hr
= get_typeinfo(IVBSAXLocator_tid
, &typeinfo
);
1634 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
1635 ITypeInfo_Release(typeinfo
);
1641 static HRESULT WINAPI
ivbsaxlocator_Invoke(
1642 IVBSAXLocator
*iface
,
1643 DISPID dispIdMember
,
1647 DISPPARAMS
* pDispParams
,
1648 VARIANT
* pVarResult
,
1649 EXCEPINFO
* pExcepInfo
,
1652 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1653 ITypeInfo
*typeinfo
;
1656 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1657 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1659 hr
= get_typeinfo(IVBSAXLocator_tid
, &typeinfo
);
1662 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IVBSAXLocator_iface
, dispIdMember
, wFlags
,
1663 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1664 ITypeInfo_Release(typeinfo
);
1670 /*** IVBSAXLocator methods ***/
1671 static HRESULT WINAPI
ivbsaxlocator_get_columnNumber(
1672 IVBSAXLocator
* iface
,
1675 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1676 return ISAXLocator_getColumnNumber((ISAXLocator
*)&This
->IVBSAXLocator_iface
, pnColumn
);
1679 static HRESULT WINAPI
ivbsaxlocator_get_lineNumber(
1680 IVBSAXLocator
* iface
,
1683 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1684 return ISAXLocator_getLineNumber((ISAXLocator
*)&This
->IVBSAXLocator_iface
, pnLine
);
1687 static HRESULT WINAPI
ivbsaxlocator_get_publicId(
1688 IVBSAXLocator
* iface
,
1691 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1692 return ISAXLocator_getPublicId((ISAXLocator
*)&This
->IVBSAXLocator_iface
,
1693 (const WCHAR
**)publicId
);
1696 static HRESULT WINAPI
ivbsaxlocator_get_systemId(
1697 IVBSAXLocator
* iface
,
1700 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1701 return ISAXLocator_getSystemId((ISAXLocator
*)&This
->IVBSAXLocator_iface
,
1702 (const WCHAR
**)systemId
);
1705 static const struct IVBSAXLocatorVtbl ivbsaxlocator_vtbl
=
1707 ivbsaxlocator_QueryInterface
,
1708 ivbsaxlocator_AddRef
,
1709 ivbsaxlocator_Release
,
1710 ivbsaxlocator_GetTypeInfoCount
,
1711 ivbsaxlocator_GetTypeInfo
,
1712 ivbsaxlocator_GetIDsOfNames
,
1713 ivbsaxlocator_Invoke
,
1714 ivbsaxlocator_get_columnNumber
,
1715 ivbsaxlocator_get_lineNumber
,
1716 ivbsaxlocator_get_publicId
,
1717 ivbsaxlocator_get_systemId
1720 /*** ISAXLocator interface ***/
1721 /*** IUnknown methods ***/
1722 static HRESULT WINAPI
isaxlocator_QueryInterface(ISAXLocator
* iface
, REFIID riid
, void **ppvObject
)
1724 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1726 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
1730 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
1731 IsEqualGUID( riid
, &IID_ISAXLocator
))
1737 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1738 return E_NOINTERFACE
;
1741 ISAXLocator_AddRef( iface
);
1746 static ULONG WINAPI
isaxlocator_AddRef(ISAXLocator
* iface
)
1748 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1749 TRACE("%p\n", This
);
1750 return InterlockedIncrement( &This
->ref
);
1753 static ULONG WINAPI
isaxlocator_Release(
1756 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1759 TRACE("%p\n", This
);
1761 ref
= InterlockedDecrement( &This
->ref
);
1764 SysFreeString(This
->publicId
);
1765 SysFreeString(This
->systemId
);
1766 heap_free(This
->nsStack
);
1768 ISAXXMLReader_Release(&This
->saxreader
->ISAXXMLReader_iface
);
1775 /*** ISAXLocator methods ***/
1776 static HRESULT WINAPI
isaxlocator_getColumnNumber(
1780 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1782 *pnColumn
= This
->column
;
1786 static HRESULT WINAPI
isaxlocator_getLineNumber(
1790 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1792 *pnLine
= This
->line
;
1796 static HRESULT WINAPI
isaxlocator_getPublicId(
1798 const WCHAR
** ppwchPublicId
)
1801 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1803 SysFreeString(This
->publicId
);
1805 publicId
= bstr_from_xmlChar(xmlSAX2GetPublicId(This
->pParserCtxt
));
1806 if(SysStringLen(publicId
))
1807 This
->publicId
= (WCHAR
*)&publicId
;
1810 SysFreeString(publicId
);
1811 This
->publicId
= NULL
;
1814 *ppwchPublicId
= This
->publicId
;
1818 static HRESULT WINAPI
isaxlocator_getSystemId(
1820 const WCHAR
** ppwchSystemId
)
1823 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1825 SysFreeString(This
->systemId
);
1827 systemId
= bstr_from_xmlChar(xmlSAX2GetSystemId(This
->pParserCtxt
));
1828 if(SysStringLen(systemId
))
1829 This
->systemId
= (WCHAR
*)&systemId
;
1832 SysFreeString(systemId
);
1833 This
->systemId
= NULL
;
1836 *ppwchSystemId
= This
->systemId
;
1840 static const struct ISAXLocatorVtbl isaxlocator_vtbl
=
1842 isaxlocator_QueryInterface
,
1844 isaxlocator_Release
,
1845 isaxlocator_getColumnNumber
,
1846 isaxlocator_getLineNumber
,
1847 isaxlocator_getPublicId
,
1848 isaxlocator_getSystemId
1851 static HRESULT
SAXLocator_create(saxreader
*reader
, saxlocator
**ppsaxlocator
, BOOL vbInterface
)
1853 saxlocator
*locator
;
1855 locator
= heap_alloc( sizeof (*locator
) );
1857 return E_OUTOFMEMORY
;
1859 locator
->IVBSAXLocator_iface
.lpVtbl
= &ivbsaxlocator_vtbl
;
1860 locator
->ISAXLocator_iface
.lpVtbl
= &isaxlocator_vtbl
;
1862 locator
->vbInterface
= vbInterface
;
1864 locator
->saxreader
= reader
;
1865 ISAXXMLReader_AddRef(&reader
->ISAXXMLReader_iface
);
1867 locator
->pParserCtxt
= NULL
;
1868 locator
->publicId
= NULL
;
1869 locator
->systemId
= NULL
;
1870 locator
->lastCur
= NULL
;
1872 locator
->column
= 0;
1873 locator
->ret
= S_OK
;
1874 locator
->nsStackSize
= 8;
1875 locator
->nsStackLast
= 0;
1876 locator
->nsStack
= heap_alloc(sizeof(int)*locator
->nsStackSize
);
1877 if(!locator
->nsStack
)
1879 ISAXXMLReader_Release(&reader
->ISAXXMLReader_iface
);
1881 return E_OUTOFMEMORY
;
1884 *ppsaxlocator
= locator
;
1886 TRACE("returning %p\n", *ppsaxlocator
);
1891 /*** SAXXMLReader internal functions ***/
1892 static HRESULT
internal_parseBuffer(saxreader
*This
, const char *buffer
, int size
, BOOL vbInterface
)
1894 xmlCharEncoding encoding
= XML_CHAR_ENCODING_NONE
;
1895 xmlChar
*enc_name
= NULL
;
1896 saxlocator
*locator
;
1899 hr
= SAXLocator_create(This
, &locator
, vbInterface
);
1905 const unsigned char *buff
= (unsigned char*)buffer
;
1907 encoding
= xmlDetectCharEncoding((xmlChar
*)buffer
, 4);
1908 enc_name
= (xmlChar
*)xmlGetCharEncodingName(encoding
);
1909 TRACE("detected encoding: %s\n", enc_name
);
1910 /* skip BOM, parser won't switch encodings and so won't skip it on its own */
1911 if ((encoding
== XML_CHAR_ENCODING_UTF8
) &&
1912 buff
[0] == 0xEF && buff
[1] == 0xBB && buff
[2] == 0xBF)
1919 locator
->pParserCtxt
= xmlCreateMemoryParserCtxt(buffer
, size
);
1920 if(!locator
->pParserCtxt
)
1922 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
1926 if (encoding
== XML_CHAR_ENCODING_UTF8
)
1927 locator
->pParserCtxt
->encoding
= xmlStrdup(enc_name
);
1929 xmlFree(locator
->pParserCtxt
->sax
);
1930 locator
->pParserCtxt
->sax
= &locator
->saxreader
->sax
;
1931 locator
->pParserCtxt
->userData
= locator
;
1933 This
->isParsing
= TRUE
;
1934 if(xmlParseDocument(locator
->pParserCtxt
) == -1) hr
= E_FAIL
;
1935 else hr
= locator
->ret
;
1936 This
->isParsing
= FALSE
;
1938 if(locator
->pParserCtxt
)
1940 locator
->pParserCtxt
->sax
= NULL
;
1941 xmlFreeParserCtxt(locator
->pParserCtxt
);
1942 locator
->pParserCtxt
= NULL
;
1945 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
1949 static HRESULT
internal_parseStream(saxreader
*This
, IStream
*stream
, BOOL vbInterface
)
1951 saxlocator
*locator
;
1958 hr
= IStream_Read(stream
, data
, sizeof(data
), &dataRead
);
1959 if(FAILED(hr
)) return hr
;
1961 hr
= SAXLocator_create(This
, &locator
, vbInterface
);
1962 if(FAILED(hr
)) return hr
;
1964 locator
->pParserCtxt
= xmlCreatePushParserCtxt(
1965 &locator
->saxreader
->sax
, locator
,
1966 data
, dataRead
, NULL
);
1967 if(!locator
->pParserCtxt
)
1969 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
1973 This
->isParsing
= TRUE
;
1975 if(dataRead
!= sizeof(data
))
1977 ret
= xmlParseChunk(locator
->pParserCtxt
, data
, 0, 1);
1978 hr
= ret
!= XML_ERR_OK
? E_FAIL
: locator
->ret
;
1985 hr
= IStream_Read(stream
, data
, sizeof(data
), &dataRead
);
1986 if (FAILED(hr
)) break;
1988 ret
= xmlParseChunk(locator
->pParserCtxt
, data
, dataRead
, 0);
1989 hr
= ret
!= XML_ERR_OK
? E_FAIL
: locator
->ret
;
1991 if (hr
!= S_OK
) break;
1993 if (dataRead
!= sizeof(data
))
1995 ret
= xmlParseChunk(locator
->pParserCtxt
, data
, 0, 1);
1996 hr
= ret
!= XML_ERR_OK
? E_FAIL
: locator
->ret
;
2002 This
->isParsing
= FALSE
;
2004 xmlFreeParserCtxt(locator
->pParserCtxt
);
2005 locator
->pParserCtxt
= NULL
;
2006 ISAXLocator_Release(&locator
->ISAXLocator_iface
);
2010 static HRESULT
internal_getEntityResolver(
2012 void *pEntityResolver
,
2015 FIXME("(%p)->(%p) stub\n", This
, pEntityResolver
);
2019 static HRESULT
internal_putEntityResolver(
2021 void *pEntityResolver
,
2024 FIXME("(%p)->(%p) stub\n", This
, pEntityResolver
);
2028 static HRESULT
internal_getContentHandler(
2030 void *pContentHandler
,
2033 TRACE("(%p)->(%p)\n", This
, pContentHandler
);
2034 if(pContentHandler
== NULL
)
2036 if((vbInterface
&& This
->vbcontentHandler
)
2037 || (!vbInterface
&& This
->contentHandler
))
2040 IVBSAXContentHandler_AddRef(This
->vbcontentHandler
);
2042 ISAXContentHandler_AddRef(This
->contentHandler
);
2044 if(vbInterface
) *(IVBSAXContentHandler
**)pContentHandler
=
2045 This
->vbcontentHandler
;
2046 else *(ISAXContentHandler
**)pContentHandler
= This
->contentHandler
;
2051 static HRESULT
internal_putContentHandler(
2053 void *contentHandler
,
2056 TRACE("(%p)->(%p)\n", This
, contentHandler
);
2060 IVBSAXContentHandler_AddRef((IVBSAXContentHandler
*)contentHandler
);
2062 ISAXContentHandler_AddRef((ISAXContentHandler
*)contentHandler
);
2064 if((vbInterface
&& This
->vbcontentHandler
)
2065 || (!vbInterface
&& This
->contentHandler
))
2068 IVBSAXContentHandler_Release(This
->vbcontentHandler
);
2070 ISAXContentHandler_Release(This
->contentHandler
);
2073 This
->vbcontentHandler
= contentHandler
;
2075 This
->contentHandler
= contentHandler
;
2080 static HRESULT
internal_getDTDHandler(
2085 FIXME("(%p)->(%p) stub\n", This
, pDTDHandler
);
2089 static HRESULT
internal_putDTDHandler(
2094 FIXME("(%p)->(%p) stub\n", This
, pDTDHandler
);
2098 static HRESULT
internal_getErrorHandler(
2100 void *pErrorHandler
,
2103 TRACE("(%p)->(%p)\n", This
, pErrorHandler
);
2104 if(pErrorHandler
== NULL
)
2107 if(vbInterface
&& This
->vberrorHandler
)
2108 IVBSAXErrorHandler_AddRef(This
->vberrorHandler
);
2109 else if(!vbInterface
&& This
->errorHandler
)
2110 ISAXErrorHandler_AddRef(This
->errorHandler
);
2113 *(IVBSAXErrorHandler
**)pErrorHandler
= This
->vberrorHandler
;
2115 *(ISAXErrorHandler
**)pErrorHandler
= This
->errorHandler
;
2121 static HRESULT
internal_putErrorHandler(
2126 TRACE("(%p)->(%p)\n", This
, errorHandler
);
2130 IVBSAXErrorHandler_AddRef((IVBSAXErrorHandler
*)errorHandler
);
2132 ISAXErrorHandler_AddRef((ISAXErrorHandler
*)errorHandler
);
2135 if(vbInterface
&& This
->vberrorHandler
)
2136 IVBSAXErrorHandler_Release(This
->vberrorHandler
);
2137 else if(!vbInterface
&& This
->errorHandler
)
2138 ISAXErrorHandler_Release(This
->errorHandler
);
2141 This
->vberrorHandler
= errorHandler
;
2143 This
->errorHandler
= errorHandler
;
2149 static HRESULT
internal_parse(
2156 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&varInput
));
2158 /* Dispose of the BSTRs in the pool from a prior run, if any. */
2159 free_bstr_pool(&This
->pool
);
2161 switch(V_VT(&varInput
))
2164 hr
= internal_parseBuffer(This
, (const char*)V_BSTR(&varInput
),
2165 SysStringByteLen(V_BSTR(&varInput
)), vbInterface
);
2167 case VT_ARRAY
|VT_UI1
: {
2169 LONG lBound
, uBound
;
2172 hr
= SafeArrayGetLBound(V_ARRAY(&varInput
), 1, &lBound
);
2173 if(hr
!= S_OK
) break;
2174 hr
= SafeArrayGetUBound(V_ARRAY(&varInput
), 1, &uBound
);
2175 if(hr
!= S_OK
) break;
2176 dataRead
= (uBound
-lBound
)*SafeArrayGetElemsize(V_ARRAY(&varInput
));
2177 hr
= SafeArrayAccessData(V_ARRAY(&varInput
), &pSAData
);
2178 if(hr
!= S_OK
) break;
2179 hr
= internal_parseBuffer(This
, pSAData
, dataRead
, vbInterface
);
2180 SafeArrayUnaccessData(V_ARRAY(&varInput
));
2185 IPersistStream
*persistStream
;
2186 IStream
*stream
= NULL
;
2187 IXMLDOMDocument
*xmlDoc
;
2189 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
2190 &IID_IXMLDOMDocument
, (void**)&xmlDoc
) == S_OK
)
2194 IXMLDOMDocument_get_xml(xmlDoc
, &bstrData
);
2195 hr
= internal_parseBuffer(This
, (const char*)bstrData
,
2196 SysStringByteLen(bstrData
), vbInterface
);
2197 IXMLDOMDocument_Release(xmlDoc
);
2198 SysFreeString(bstrData
);
2202 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
2203 &IID_IPersistStream
, (void**)&persistStream
) == S_OK
)
2205 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
2208 IPersistStream_Release(persistStream
);
2212 hr
= IPersistStream_Save(persistStream
, stream
, TRUE
);
2213 IPersistStream_Release(persistStream
);
2216 IStream_Release(stream
);
2220 if(stream
|| IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
2221 &IID_IStream
, (void**)&stream
) == S_OK
)
2223 hr
= internal_parseStream(This
, stream
, vbInterface
);
2224 IStream_Release(stream
);
2229 WARN("vt %d not implemented\n", V_VT(&varInput
));
2236 static HRESULT
internal_vbonDataAvailable(void *obj
, char *ptr
, DWORD len
)
2238 saxreader
*This
= obj
;
2240 return internal_parseBuffer(This
, ptr
, len
, TRUE
);
2243 static HRESULT
internal_onDataAvailable(void *obj
, char *ptr
, DWORD len
)
2245 saxreader
*This
= obj
;
2247 return internal_parseBuffer(This
, ptr
, len
, FALSE
);
2250 static HRESULT
internal_parseURL(
2258 TRACE("(%p)->(%s)\n", This
, debugstr_w(url
));
2260 if(vbInterface
) hr
= bind_url(url
, internal_vbonDataAvailable
, This
, &bsc
);
2261 else hr
= bind_url(url
, internal_onDataAvailable
, This
, &bsc
);
2271 static HRESULT
internal_putProperty(
2277 TRACE("(%p)->(%s %s)\n", This
, debugstr_w(prop
), debugstr_variant(&value
));
2279 if(!memcmp(prop
, PropertyDeclHandlerW
, sizeof(PropertyDeclHandlerW
)))
2281 if(This
->isParsing
) return E_FAIL
;
2283 switch (V_VT(&value
))
2288 if (This
->vbdeclHandler
)
2290 IVBSAXDeclHandler_Release(This
->vbdeclHandler
);
2291 This
->vbdeclHandler
= NULL
;
2295 if (This
->declHandler
)
2297 ISAXDeclHandler_Release(This
->declHandler
);
2298 This
->declHandler
= NULL
;
2302 if (V_UNKNOWN(&value
)) IUnknown_AddRef(V_UNKNOWN(&value
));
2304 if ((vbInterface
&& This
->vbdeclHandler
) ||
2305 (!vbInterface
&& This
->declHandler
))
2308 IVBSAXDeclHandler_Release(This
->vbdeclHandler
);
2310 ISAXDeclHandler_Release(This
->declHandler
);
2314 This
->vbdeclHandler
= (IVBSAXDeclHandler
*)V_UNKNOWN(&value
);
2316 This
->declHandler
= (ISAXDeclHandler
*)V_UNKNOWN(&value
);
2319 return E_INVALIDARG
;
2325 if(!memcmp(prop
, PropertyLexicalHandlerW
, sizeof(PropertyLexicalHandlerW
)))
2327 if(This
->isParsing
) return E_FAIL
;
2329 switch (V_VT(&value
))
2334 if (This
->vblexicalHandler
)
2336 IVBSAXLexicalHandler_Release(This
->vblexicalHandler
);
2337 This
->vblexicalHandler
= NULL
;
2341 if (This
->lexicalHandler
)
2343 ISAXLexicalHandler_Release(This
->lexicalHandler
);
2344 This
->lexicalHandler
= NULL
;
2348 if (V_UNKNOWN(&value
)) IUnknown_AddRef(V_UNKNOWN(&value
));
2350 if ((vbInterface
&& This
->vblexicalHandler
) ||
2351 (!vbInterface
&& This
->lexicalHandler
))
2354 IVBSAXLexicalHandler_Release(This
->vblexicalHandler
);
2356 ISAXLexicalHandler_Release(This
->lexicalHandler
);
2360 This
->vblexicalHandler
= (IVBSAXLexicalHandler
*)V_UNKNOWN(&value
);
2362 This
->lexicalHandler
= (ISAXLexicalHandler
*)V_UNKNOWN(&value
);
2365 return E_INVALIDARG
;
2371 FIXME("(%p)->(%s): unsupported property\n", This
, debugstr_w(prop
));
2373 if(!memcmp(prop
, PropertyCharsetW
, sizeof(PropertyCharsetW
)))
2376 if(!memcmp(prop
, PropertyDomNodeW
, sizeof(PropertyDomNodeW
)))
2379 if(!memcmp(prop
, PropertyInputSourceW
, sizeof(PropertyInputSourceW
)))
2382 if(!memcmp(prop
, PropertyMaxElementDepthW
, sizeof(PropertyMaxElementDepthW
)))
2385 if(!memcmp(prop
, PropertyMaxXMLSizeW
, sizeof(PropertyMaxXMLSizeW
)))
2388 if(!memcmp(prop
, PropertySchemaDeclHandlerW
, sizeof(PropertySchemaDeclHandlerW
)))
2391 if(!memcmp(prop
, PropertyXMLDeclEncodingW
, sizeof(PropertyXMLDeclEncodingW
)))
2394 if(!memcmp(prop
, PropertyXMLDeclStandaloneW
, sizeof(PropertyXMLDeclStandaloneW
)))
2397 if(!memcmp(prop
, PropertyXMLDeclVersionW
, sizeof(PropertyXMLDeclVersionW
)))
2400 return E_INVALIDARG
;
2403 static HRESULT
internal_getProperty(const saxreader
* This
, const WCHAR
*prop
, VARIANT
*value
, BOOL vb
)
2405 TRACE("(%p)->(%s)\n", This
, debugstr_w(prop
));
2407 if (!value
) return E_POINTER
;
2409 if (!memcmp(PropertyLexicalHandlerW
, prop
, sizeof(PropertyLexicalHandlerW
)))
2411 V_VT(value
) = VT_UNKNOWN
;
2412 V_UNKNOWN(value
) = vb
? (IUnknown
*)This
->vblexicalHandler
: (IUnknown
*)This
->lexicalHandler
;
2413 if (V_UNKNOWN(value
)) IUnknown_AddRef(V_UNKNOWN(value
));
2417 if (!memcmp(PropertyDeclHandlerW
, prop
, sizeof(PropertyDeclHandlerW
)))
2419 V_VT(value
) = VT_UNKNOWN
;
2420 V_UNKNOWN(value
) = vb
? (IUnknown
*)This
->vbdeclHandler
: (IUnknown
*)This
->declHandler
;
2421 if (V_UNKNOWN(value
)) IUnknown_AddRef(V_UNKNOWN(value
));
2425 FIXME("(%p)->(%s) unsupported property\n", This
, debugstr_w(prop
));
2430 /*** IVBSAXXMLReader interface ***/
2431 /*** IUnknown methods ***/
2432 static HRESULT WINAPI
saxxmlreader_QueryInterface(IVBSAXXMLReader
* iface
, REFIID riid
, void **ppvObject
)
2434 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2436 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
2440 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
2441 IsEqualGUID( riid
, &IID_IDispatch
) ||
2442 IsEqualGUID( riid
, &IID_IVBSAXXMLReader
))
2446 else if( IsEqualGUID( riid
, &IID_ISAXXMLReader
))
2448 *ppvObject
= &This
->ISAXXMLReader_iface
;
2452 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
2453 return E_NOINTERFACE
;
2456 IVBSAXXMLReader_AddRef( iface
);
2461 static ULONG WINAPI
saxxmlreader_AddRef(IVBSAXXMLReader
* iface
)
2463 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2464 TRACE("%p\n", This
);
2465 return InterlockedIncrement( &This
->ref
);
2468 static ULONG WINAPI
saxxmlreader_Release(
2469 IVBSAXXMLReader
* iface
)
2471 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2474 TRACE("%p\n", This
);
2476 ref
= InterlockedDecrement( &This
->ref
);
2479 if(This
->contentHandler
)
2480 ISAXContentHandler_Release(This
->contentHandler
);
2482 if(This
->vbcontentHandler
)
2483 IVBSAXContentHandler_Release(This
->vbcontentHandler
);
2485 if(This
->errorHandler
)
2486 ISAXErrorHandler_Release(This
->errorHandler
);
2488 if(This
->vberrorHandler
)
2489 IVBSAXErrorHandler_Release(This
->vberrorHandler
);
2491 if(This
->lexicalHandler
)
2492 ISAXLexicalHandler_Release(This
->lexicalHandler
);
2494 if(This
->vblexicalHandler
)
2495 IVBSAXLexicalHandler_Release(This
->vblexicalHandler
);
2497 if(This
->declHandler
)
2498 ISAXDeclHandler_Release(This
->declHandler
);
2500 if(This
->vbdeclHandler
)
2501 IVBSAXDeclHandler_Release(This
->vbdeclHandler
);
2503 free_bstr_pool(&This
->pool
);
2511 static HRESULT WINAPI
saxxmlreader_GetTypeInfoCount( IVBSAXXMLReader
*iface
, UINT
* pctinfo
)
2513 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2515 TRACE("(%p)->(%p)\n", This
, pctinfo
);
2522 static HRESULT WINAPI
saxxmlreader_GetTypeInfo(
2523 IVBSAXXMLReader
*iface
,
2524 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2526 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2529 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
2531 hr
= get_typeinfo(IVBSAXXMLReader_tid
, ppTInfo
);
2536 static HRESULT WINAPI
saxxmlreader_GetIDsOfNames(
2537 IVBSAXXMLReader
*iface
,
2539 LPOLESTR
* rgszNames
,
2544 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2545 ITypeInfo
*typeinfo
;
2548 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
2551 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
2552 return E_INVALIDARG
;
2554 hr
= get_typeinfo(IVBSAXXMLReader_tid
, &typeinfo
);
2557 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
2558 ITypeInfo_Release(typeinfo
);
2564 static HRESULT WINAPI
saxxmlreader_Invoke(
2565 IVBSAXXMLReader
*iface
,
2566 DISPID dispIdMember
,
2570 DISPPARAMS
* pDispParams
,
2571 VARIANT
* pVarResult
,
2572 EXCEPINFO
* pExcepInfo
,
2575 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2576 ITypeInfo
*typeinfo
;
2579 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
2580 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2582 hr
= get_typeinfo(IVBSAXXMLReader_tid
, &typeinfo
);
2585 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IVBSAXXMLReader_iface
, dispIdMember
, wFlags
,
2586 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2587 ITypeInfo_Release(typeinfo
);
2593 /*** IVBSAXXMLReader methods ***/
2594 static HRESULT WINAPI
saxxmlreader_getFeature(
2595 IVBSAXXMLReader
* iface
,
2596 const WCHAR
*pFeature
,
2597 VARIANT_BOOL
*pValue
)
2599 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2601 FIXME("(%p)->(%s %p) stub\n", This
, debugstr_w(pFeature
), pValue
);
2605 static HRESULT WINAPI
saxxmlreader_putFeature(
2606 IVBSAXXMLReader
* iface
,
2607 const WCHAR
*feature
,
2610 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2612 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(feature
), value
);
2614 if (!strcmpW(FeatureExternalGeneralEntitiesW
, feature
) && value
== VARIANT_FALSE
)
2615 return set_feature_value(This
, ExternalGeneralEntities
, value
);
2617 FIXME("(%p)->(%s %x) stub\n", This
, debugstr_w(feature
), value
);
2621 static HRESULT WINAPI
saxxmlreader_getProperty(
2622 IVBSAXXMLReader
* iface
,
2626 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2627 return internal_getProperty(This
, prop
, value
, TRUE
);
2630 static HRESULT WINAPI
saxxmlreader_putProperty(
2631 IVBSAXXMLReader
* iface
,
2635 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2636 return internal_putProperty(This
, pProp
, value
, TRUE
);
2639 static HRESULT WINAPI
saxxmlreader_get_entityResolver(
2640 IVBSAXXMLReader
* iface
,
2641 IVBSAXEntityResolver
**pEntityResolver
)
2643 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2644 return internal_getEntityResolver(This
, pEntityResolver
, TRUE
);
2647 static HRESULT WINAPI
saxxmlreader_put_entityResolver(
2648 IVBSAXXMLReader
* iface
,
2649 IVBSAXEntityResolver
*pEntityResolver
)
2651 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2652 return internal_putEntityResolver(This
, pEntityResolver
, TRUE
);
2655 static HRESULT WINAPI
saxxmlreader_get_contentHandler(
2656 IVBSAXXMLReader
* iface
,
2657 IVBSAXContentHandler
**ppContentHandler
)
2659 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2660 return internal_getContentHandler(This
, ppContentHandler
, TRUE
);
2663 static HRESULT WINAPI
saxxmlreader_put_contentHandler(
2664 IVBSAXXMLReader
* iface
,
2665 IVBSAXContentHandler
*contentHandler
)
2667 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2668 return internal_putContentHandler(This
, contentHandler
, TRUE
);
2671 static HRESULT WINAPI
saxxmlreader_get_dtdHandler(
2672 IVBSAXXMLReader
* iface
,
2673 IVBSAXDTDHandler
**pDTDHandler
)
2675 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2676 return internal_getDTDHandler(This
, pDTDHandler
, TRUE
);
2679 static HRESULT WINAPI
saxxmlreader_put_dtdHandler(
2680 IVBSAXXMLReader
* iface
,
2681 IVBSAXDTDHandler
*pDTDHandler
)
2683 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2684 return internal_putDTDHandler(This
, pDTDHandler
, TRUE
);
2687 static HRESULT WINAPI
saxxmlreader_get_errorHandler(
2688 IVBSAXXMLReader
* iface
,
2689 IVBSAXErrorHandler
**pErrorHandler
)
2691 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2692 return internal_getErrorHandler(This
, pErrorHandler
, TRUE
);
2695 static HRESULT WINAPI
saxxmlreader_put_errorHandler(
2696 IVBSAXXMLReader
* iface
,
2697 IVBSAXErrorHandler
*errorHandler
)
2699 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2700 return internal_putErrorHandler(This
, errorHandler
, TRUE
);
2703 static HRESULT WINAPI
saxxmlreader_get_baseURL(
2704 IVBSAXXMLReader
* iface
,
2705 const WCHAR
**pBaseUrl
)
2707 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2709 FIXME("(%p)->(%p) stub\n", This
, pBaseUrl
);
2713 static HRESULT WINAPI
saxxmlreader_put_baseURL(
2714 IVBSAXXMLReader
* iface
,
2715 const WCHAR
*pBaseUrl
)
2717 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2719 FIXME("(%p)->(%s) stub\n", This
, debugstr_w(pBaseUrl
));
2723 static HRESULT WINAPI
saxxmlreader_get_secureBaseURL(
2724 IVBSAXXMLReader
* iface
,
2725 const WCHAR
**pSecureBaseUrl
)
2727 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2729 FIXME("(%p)->(%p) stub\n", This
, pSecureBaseUrl
);
2734 static HRESULT WINAPI
saxxmlreader_put_secureBaseURL(
2735 IVBSAXXMLReader
* iface
,
2736 const WCHAR
*secureBaseUrl
)
2738 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2740 FIXME("(%p)->(%s) stub\n", This
, debugstr_w(secureBaseUrl
));
2744 static HRESULT WINAPI
saxxmlreader_parse(
2745 IVBSAXXMLReader
* iface
,
2748 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2749 return internal_parse(This
, varInput
, TRUE
);
2752 static HRESULT WINAPI
saxxmlreader_parseURL(
2753 IVBSAXXMLReader
* iface
,
2756 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2757 return internal_parseURL(This
, url
, TRUE
);
2760 static const struct IVBSAXXMLReaderVtbl saxreader_vtbl
=
2762 saxxmlreader_QueryInterface
,
2763 saxxmlreader_AddRef
,
2764 saxxmlreader_Release
,
2765 saxxmlreader_GetTypeInfoCount
,
2766 saxxmlreader_GetTypeInfo
,
2767 saxxmlreader_GetIDsOfNames
,
2768 saxxmlreader_Invoke
,
2769 saxxmlreader_getFeature
,
2770 saxxmlreader_putFeature
,
2771 saxxmlreader_getProperty
,
2772 saxxmlreader_putProperty
,
2773 saxxmlreader_get_entityResolver
,
2774 saxxmlreader_put_entityResolver
,
2775 saxxmlreader_get_contentHandler
,
2776 saxxmlreader_put_contentHandler
,
2777 saxxmlreader_get_dtdHandler
,
2778 saxxmlreader_put_dtdHandler
,
2779 saxxmlreader_get_errorHandler
,
2780 saxxmlreader_put_errorHandler
,
2781 saxxmlreader_get_baseURL
,
2782 saxxmlreader_put_baseURL
,
2783 saxxmlreader_get_secureBaseURL
,
2784 saxxmlreader_put_secureBaseURL
,
2786 saxxmlreader_parseURL
2789 /*** ISAXXMLReader interface ***/
2790 /*** IUnknown methods ***/
2791 static HRESULT WINAPI
isaxxmlreader_QueryInterface(ISAXXMLReader
* iface
, REFIID riid
, void **ppvObject
)
2793 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2794 return saxxmlreader_QueryInterface(&This
->IVBSAXXMLReader_iface
, riid
, ppvObject
);
2797 static ULONG WINAPI
isaxxmlreader_AddRef(ISAXXMLReader
* iface
)
2799 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2800 return saxxmlreader_AddRef(&This
->IVBSAXXMLReader_iface
);
2803 static ULONG WINAPI
isaxxmlreader_Release(ISAXXMLReader
* iface
)
2805 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2806 return saxxmlreader_Release(&This
->IVBSAXXMLReader_iface
);
2809 /*** ISAXXMLReader methods ***/
2810 static HRESULT WINAPI
isaxxmlreader_getFeature(
2811 ISAXXMLReader
* iface
,
2812 const WCHAR
*pFeature
,
2813 VARIANT_BOOL
*pValue
)
2815 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2816 return IVBSAXXMLReader_getFeature(&This
->IVBSAXXMLReader_iface
, pFeature
, pValue
);
2819 static HRESULT WINAPI
isaxxmlreader_putFeature(
2820 ISAXXMLReader
* iface
,
2821 const WCHAR
*pFeature
,
2822 VARIANT_BOOL vfValue
)
2824 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2825 return IVBSAXXMLReader_putFeature(&This
->IVBSAXXMLReader_iface
, pFeature
, vfValue
);
2828 static HRESULT WINAPI
isaxxmlreader_getProperty(
2829 ISAXXMLReader
* iface
,
2833 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2834 return internal_getProperty(This
, prop
, value
, FALSE
);
2837 static HRESULT WINAPI
isaxxmlreader_putProperty(
2838 ISAXXMLReader
* iface
,
2842 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2843 return internal_putProperty(This
, pProp
, value
, FALSE
);
2846 static HRESULT WINAPI
isaxxmlreader_getEntityResolver(
2847 ISAXXMLReader
* iface
,
2848 ISAXEntityResolver
**ppEntityResolver
)
2850 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2851 return internal_getEntityResolver(This
, ppEntityResolver
, FALSE
);
2854 static HRESULT WINAPI
isaxxmlreader_putEntityResolver(
2855 ISAXXMLReader
* iface
,
2856 ISAXEntityResolver
*pEntityResolver
)
2858 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2859 return internal_putEntityResolver(This
, pEntityResolver
, FALSE
);
2862 static HRESULT WINAPI
isaxxmlreader_getContentHandler(
2863 ISAXXMLReader
* iface
,
2864 ISAXContentHandler
**pContentHandler
)
2866 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2867 return internal_getContentHandler(This
, pContentHandler
, FALSE
);
2870 static HRESULT WINAPI
isaxxmlreader_putContentHandler(
2871 ISAXXMLReader
* iface
,
2872 ISAXContentHandler
*contentHandler
)
2874 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2875 return internal_putContentHandler(This
, contentHandler
, FALSE
);
2878 static HRESULT WINAPI
isaxxmlreader_getDTDHandler(
2879 ISAXXMLReader
* iface
,
2880 ISAXDTDHandler
**pDTDHandler
)
2882 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2883 return internal_getDTDHandler(This
, pDTDHandler
, FALSE
);
2886 static HRESULT WINAPI
isaxxmlreader_putDTDHandler(
2887 ISAXXMLReader
* iface
,
2888 ISAXDTDHandler
*pDTDHandler
)
2890 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2891 return internal_putDTDHandler(This
, pDTDHandler
, FALSE
);
2894 static HRESULT WINAPI
isaxxmlreader_getErrorHandler(
2895 ISAXXMLReader
* iface
,
2896 ISAXErrorHandler
**pErrorHandler
)
2898 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2899 return internal_getErrorHandler(This
, pErrorHandler
, FALSE
);
2902 static HRESULT WINAPI
isaxxmlreader_putErrorHandler(
2903 ISAXXMLReader
* iface
,
2904 ISAXErrorHandler
*errorHandler
)
2906 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2907 return internal_putErrorHandler(This
, errorHandler
, FALSE
);
2910 static HRESULT WINAPI
isaxxmlreader_getBaseURL(
2911 ISAXXMLReader
* iface
,
2912 const WCHAR
**pBaseUrl
)
2914 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2915 return IVBSAXXMLReader_get_baseURL(&This
->IVBSAXXMLReader_iface
, pBaseUrl
);
2918 static HRESULT WINAPI
isaxxmlreader_putBaseURL(
2919 ISAXXMLReader
* iface
,
2920 const WCHAR
*pBaseUrl
)
2922 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2923 return IVBSAXXMLReader_put_baseURL(&This
->IVBSAXXMLReader_iface
, pBaseUrl
);
2926 static HRESULT WINAPI
isaxxmlreader_getSecureBaseURL(
2927 ISAXXMLReader
* iface
,
2928 const WCHAR
**pSecureBaseUrl
)
2930 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2931 return IVBSAXXMLReader_get_secureBaseURL(&This
->IVBSAXXMLReader_iface
, pSecureBaseUrl
);
2934 static HRESULT WINAPI
isaxxmlreader_putSecureBaseURL(
2935 ISAXXMLReader
* iface
,
2936 const WCHAR
*secureBaseUrl
)
2938 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2939 return IVBSAXXMLReader_put_secureBaseURL(&This
->IVBSAXXMLReader_iface
, secureBaseUrl
);
2942 static HRESULT WINAPI
isaxxmlreader_parse(
2943 ISAXXMLReader
* iface
,
2946 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2947 return internal_parse(This
, varInput
, FALSE
);
2950 static HRESULT WINAPI
isaxxmlreader_parseURL(
2951 ISAXXMLReader
* iface
,
2954 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2955 return internal_parseURL(This
, url
, FALSE
);
2958 static const struct ISAXXMLReaderVtbl isaxreader_vtbl
=
2960 isaxxmlreader_QueryInterface
,
2961 isaxxmlreader_AddRef
,
2962 isaxxmlreader_Release
,
2963 isaxxmlreader_getFeature
,
2964 isaxxmlreader_putFeature
,
2965 isaxxmlreader_getProperty
,
2966 isaxxmlreader_putProperty
,
2967 isaxxmlreader_getEntityResolver
,
2968 isaxxmlreader_putEntityResolver
,
2969 isaxxmlreader_getContentHandler
,
2970 isaxxmlreader_putContentHandler
,
2971 isaxxmlreader_getDTDHandler
,
2972 isaxxmlreader_putDTDHandler
,
2973 isaxxmlreader_getErrorHandler
,
2974 isaxxmlreader_putErrorHandler
,
2975 isaxxmlreader_getBaseURL
,
2976 isaxxmlreader_putBaseURL
,
2977 isaxxmlreader_getSecureBaseURL
,
2978 isaxxmlreader_putSecureBaseURL
,
2979 isaxxmlreader_parse
,
2980 isaxxmlreader_parseURL
2983 HRESULT
SAXXMLReader_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
2987 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
2989 reader
= heap_alloc( sizeof (*reader
) );
2991 return E_OUTOFMEMORY
;
2993 reader
->IVBSAXXMLReader_iface
.lpVtbl
= &saxreader_vtbl
;
2994 reader
->ISAXXMLReader_iface
.lpVtbl
= &isaxreader_vtbl
;
2996 reader
->contentHandler
= NULL
;
2997 reader
->vbcontentHandler
= NULL
;
2998 reader
->errorHandler
= NULL
;
2999 reader
->vberrorHandler
= NULL
;
3000 reader
->lexicalHandler
= NULL
;
3001 reader
->vblexicalHandler
= NULL
;
3002 reader
->declHandler
= NULL
;
3003 reader
->vbdeclHandler
= NULL
;
3004 reader
->isParsing
= FALSE
;
3005 reader
->pool
.pool
= NULL
;
3006 reader
->pool
.index
= 0;
3007 reader
->pool
.len
= 0;
3008 reader
->features
= 0;
3010 memset(&reader
->sax
, 0, sizeof(xmlSAXHandler
));
3011 reader
->sax
.initialized
= XML_SAX2_MAGIC
;
3012 reader
->sax
.startDocument
= libxmlStartDocument
;
3013 reader
->sax
.endDocument
= libxmlEndDocument
;
3014 reader
->sax
.startElementNs
= libxmlStartElementNS
;
3015 reader
->sax
.endElementNs
= libxmlEndElementNS
;
3016 reader
->sax
.characters
= libxmlCharacters
;
3017 reader
->sax
.setDocumentLocator
= libxmlSetDocumentLocator
;
3018 reader
->sax
.comment
= libxmlComment
;
3019 reader
->sax
.error
= libxmlFatalError
;
3020 reader
->sax
.fatalError
= libxmlFatalError
;
3021 reader
->sax
.cdataBlock
= libxmlCDataBlock
;
3023 *ppObj
= &reader
->IVBSAXXMLReader_iface
;
3025 TRACE("returning iface %p\n", *ppObj
);
3032 HRESULT
SAXXMLReader_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
3034 MESSAGE("This program tried to use a SAX XML Reader object, but\n"
3035 "libxml2 support was not present at compile time.\n");