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
38 #include "wine/debug.h"
40 #include "msxml_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
46 #include <libxml/SAX2.h>
47 #include <libxml/parserInternals.h>
49 typedef struct _saxreader
51 const struct IVBSAXXMLReaderVtbl
*lpVBSAXXMLReaderVtbl
;
52 const struct ISAXXMLReaderVtbl
*lpSAXXMLReaderVtbl
;
54 struct ISAXContentHandler
*contentHandler
;
55 struct IVBSAXContentHandler
*vbcontentHandler
;
56 struct ISAXErrorHandler
*errorHandler
;
57 struct IVBSAXErrorHandler
*vberrorHandler
;
61 typedef struct _saxlocator
63 const struct IVBSAXLocatorVtbl
*lpVBSAXLocatorVtbl
;
64 const struct ISAXLocatorVtbl
*lpSAXLocatorVtbl
;
68 xmlParserCtxtPtr pParserCtxt
;
77 typedef struct _saxattributes
79 const struct IVBSAXAttributesVtbl
*lpVBSAXAttributesVtbl
;
80 const struct ISAXAttributesVtbl
*lpSAXAttributesVtbl
;
90 static inline saxreader
*impl_from_IVBSAXXMLReader( IVBSAXXMLReader
*iface
)
92 return (saxreader
*)((char*)iface
- FIELD_OFFSET(saxreader
, lpVBSAXXMLReaderVtbl
));
95 static inline saxreader
*impl_from_ISAXXMLReader( ISAXXMLReader
*iface
)
97 return (saxreader
*)((char*)iface
- FIELD_OFFSET(saxreader
, lpSAXXMLReaderVtbl
));
100 static inline saxlocator
*impl_from_IVBSAXLocator( IVBSAXLocator
*iface
)
102 return (saxlocator
*)((char*)iface
- FIELD_OFFSET(saxlocator
, lpVBSAXLocatorVtbl
));
105 static inline saxlocator
*impl_from_ISAXLocator( ISAXLocator
*iface
)
107 return (saxlocator
*)((char*)iface
- FIELD_OFFSET(saxlocator
, lpSAXLocatorVtbl
));
110 static inline saxattributes
*impl_from_IVBSAXAttributes( IVBSAXAttributes
*iface
)
112 return (saxattributes
*)((char*)iface
- FIELD_OFFSET(saxattributes
, lpVBSAXAttributesVtbl
));
115 static inline saxattributes
*impl_from_ISAXAttributes( ISAXAttributes
*iface
)
117 return (saxattributes
*)((char*)iface
- FIELD_OFFSET(saxattributes
, lpSAXAttributesVtbl
));
121 BSTR
bstr_from_xmlCharN(const xmlChar
*buf
, int len
)
130 dLen
= MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)buf
, len
, NULL
, 0);
131 if(len
!= -1) dLen
++;
132 str
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, dLen
* sizeof (WCHAR
));
135 MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)buf
, len
, str
, dLen
);
136 if(len
!= -1) str
[dLen
-1] = '\0';
137 bstr
= SysAllocString(str
);
138 HeapFree(GetProcessHeap(), 0, str
);
143 static void format_error_message_from_id(saxlocator
*This
, HRESULT hr
)
145 xmlStopParser(This
->pParserCtxt
);
148 if(This
->saxreader
->errorHandler
)
151 if(!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
,
152 NULL
, hr
, 0, msg
, sizeof(msg
), NULL
))
154 FIXME("MSXML errors not yet supported.\n");
158 if(This
->vbInterface
)
160 BSTR bstrMsg
= SysAllocString(msg
);
161 IVBSAXErrorHandler_fatalError(This
->saxreader
->vberrorHandler
,
162 (IVBSAXLocator
*)&This
->lpVBSAXLocatorVtbl
, &bstrMsg
, hr
);
165 ISAXErrorHandler_fatalError(This
->saxreader
->errorHandler
,
166 (ISAXLocator
*)&This
->lpSAXLocatorVtbl
, msg
, hr
);
170 static void update_position(saxlocator
*This
, xmlChar
*end
)
172 if(This
->lastCur
== NULL
)
174 This
->lastCur
= (xmlChar
*)This
->pParserCtxt
->input
->base
;
178 else if(This
->lastCur
< This
->pParserCtxt
->input
->base
)
180 This
->lastCur
= (xmlChar
*)This
->pParserCtxt
->input
->base
;
185 if(!end
) end
= (xmlChar
*)This
->pParserCtxt
->input
->cur
;
187 while(This
->lastCur
< end
)
189 if(*(This
->lastCur
) == '\n')
194 else if(*(This
->lastCur
) == '\r' && (This
->lastCur
==This
->pParserCtxt
->input
->end
|| *(This
->lastCur
+1)!='\n'))
205 /*** IVBSAXAttributes interface ***/
206 /*** IUnknown methods ***/
207 static HRESULT WINAPI
ivbsaxattributes_QueryInterface(
208 IVBSAXAttributes
* iface
,
212 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
214 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
218 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
219 IsEqualGUID(riid
, &IID_IDispatch
) ||
220 IsEqualGUID(riid
, &IID_IVBSAXAttributes
))
226 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
227 return E_NOINTERFACE
;
230 IVBSAXAttributes_AddRef(iface
);
235 static ULONG WINAPI
ivbsaxattributes_AddRef(IVBSAXAttributes
* iface
)
237 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
238 return ISAXAttributes_AddRef((ISAXAttributes
*)&This
->lpSAXAttributesVtbl
);
241 static ULONG WINAPI
ivbsaxattributes_Release(IVBSAXAttributes
* iface
)
243 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
244 return ISAXAttributes_Release((ISAXAttributes
*)&This
->lpSAXAttributesVtbl
);
247 /*** IDispatch methods ***/
248 static HRESULT WINAPI
ivbsaxattributes_GetTypeInfoCount( IVBSAXAttributes
*iface
, UINT
* pctinfo
)
250 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
252 TRACE("(%p)->(%p)\n", This
, pctinfo
);
259 static HRESULT WINAPI
ivbsaxattributes_GetTypeInfo(
260 IVBSAXAttributes
*iface
,
261 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
263 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
266 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
268 hr
= get_typeinfo(IVBSAXAttributes_tid
, ppTInfo
);
273 static HRESULT WINAPI
ivbsaxattributes_GetIDsOfNames(
274 IVBSAXAttributes
*iface
,
281 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
285 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
288 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
291 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
294 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
295 ITypeInfo_Release(typeinfo
);
301 static HRESULT WINAPI
ivbsaxattributes_Invoke(
302 IVBSAXAttributes
*iface
,
307 DISPPARAMS
* pDispParams
,
309 EXCEPINFO
* pExcepInfo
,
312 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
316 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
317 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
319 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
322 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVBSAXAttributesVtbl
), dispIdMember
, wFlags
, pDispParams
,
323 pVarResult
, pExcepInfo
, puArgErr
);
324 ITypeInfo_Release(typeinfo
);
330 /*** IVBSAXAttributes methods ***/
331 static HRESULT WINAPI
ivbsaxattributes_get_length(
332 IVBSAXAttributes
* iface
,
335 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
336 return ISAXAttributes_getLength(
337 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
341 static HRESULT WINAPI
ivbsaxattributes_getURI(
342 IVBSAXAttributes
* iface
,
347 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
348 return ISAXAttributes_getURI(
349 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
350 nIndex
, (const WCHAR
**)uri
, &len
);
353 static HRESULT WINAPI
ivbsaxattributes_getLocalName(
354 IVBSAXAttributes
* iface
,
359 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
360 return ISAXAttributes_getLocalName(
361 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
362 nIndex
, (const WCHAR
**)localName
, &len
);
365 static HRESULT WINAPI
ivbsaxattributes_getQName(
366 IVBSAXAttributes
* iface
,
371 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
372 return ISAXAttributes_getQName(
373 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
374 nIndex
, (const WCHAR
**)QName
, &len
);
377 static HRESULT WINAPI
ivbsaxattributes_getIndexFromName(
378 IVBSAXAttributes
* iface
,
383 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
384 return ISAXAttributes_getIndexFromName(
385 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
386 (const WCHAR
*)uri
, SysStringLen(uri
),
387 (const WCHAR
*)localName
, SysStringLen(localName
), index
);
390 static HRESULT WINAPI
ivbsaxattributes_getIndexFromQName(
391 IVBSAXAttributes
* iface
,
395 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
396 return ISAXAttributes_getIndexFromQName(
397 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
398 (const WCHAR
*)QName
, SysStringLen(QName
), index
);
401 static HRESULT WINAPI
ivbsaxattributes_getType(
402 IVBSAXAttributes
* iface
,
407 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
408 return ISAXAttributes_getType(
409 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
410 nIndex
, (const WCHAR
**)type
, &len
);
413 static HRESULT WINAPI
ivbsaxattributes_getTypeFromName(
414 IVBSAXAttributes
* iface
,
420 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
421 return ISAXAttributes_getTypeFromName(
422 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
423 (const WCHAR
*)uri
, SysStringLen(uri
),
424 (const WCHAR
*)localName
, SysStringLen(localName
),
425 (const WCHAR
**)type
, &len
);
428 static HRESULT WINAPI
ivbsaxattributes_getTypeFromQName(
429 IVBSAXAttributes
* iface
,
434 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
435 return ISAXAttributes_getTypeFromQName(
436 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
437 (const WCHAR
*)QName
, SysStringLen(QName
),
438 (const WCHAR
**)type
, &len
);
441 static HRESULT WINAPI
ivbsaxattributes_getValue(
442 IVBSAXAttributes
* iface
,
447 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
448 return ISAXAttributes_getValue(
449 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
450 nIndex
, (const WCHAR
**)value
, &len
);
453 static HRESULT WINAPI
ivbsaxattributes_getValueFromName(
454 IVBSAXAttributes
* iface
,
460 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
461 return ISAXAttributes_getValueFromName(
462 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
463 (const WCHAR
*)uri
, SysStringLen(uri
),
464 (const WCHAR
*)localName
, SysStringLen(localName
),
465 (const WCHAR
**)value
, &len
);
468 static HRESULT WINAPI
ivbsaxattributes_getValueFromQName(
469 IVBSAXAttributes
* iface
,
474 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
475 return ISAXAttributes_getValueFromQName(
476 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
477 (const WCHAR
*)QName
, SysStringLen(QName
),
478 (const WCHAR
**)value
, &len
);
481 static const struct IVBSAXAttributesVtbl ivbsaxattributes_vtbl
=
483 ivbsaxattributes_QueryInterface
,
484 ivbsaxattributes_AddRef
,
485 ivbsaxattributes_Release
,
486 ivbsaxattributes_GetTypeInfoCount
,
487 ivbsaxattributes_GetTypeInfo
,
488 ivbsaxattributes_GetIDsOfNames
,
489 ivbsaxattributes_Invoke
,
490 ivbsaxattributes_get_length
,
491 ivbsaxattributes_getURI
,
492 ivbsaxattributes_getLocalName
,
493 ivbsaxattributes_getQName
,
494 ivbsaxattributes_getIndexFromName
,
495 ivbsaxattributes_getIndexFromQName
,
496 ivbsaxattributes_getType
,
497 ivbsaxattributes_getTypeFromName
,
498 ivbsaxattributes_getTypeFromQName
,
499 ivbsaxattributes_getValue
,
500 ivbsaxattributes_getValueFromName
,
501 ivbsaxattributes_getValueFromQName
504 /*** ISAXAttributes interface ***/
505 /*** IUnknown methods ***/
506 static HRESULT WINAPI
isaxattributes_QueryInterface(
507 ISAXAttributes
* iface
,
511 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
513 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
517 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
518 IsEqualGUID(riid
, &IID_ISAXAttributes
))
524 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
525 return E_NOINTERFACE
;
528 ISAXAttributes_AddRef(iface
);
533 static ULONG WINAPI
isaxattributes_AddRef(ISAXAttributes
* iface
)
535 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
537 return InterlockedIncrement(&This
->ref
);
540 static ULONG WINAPI
isaxattributes_Release(ISAXAttributes
* iface
)
542 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
547 ref
= InterlockedDecrement(&This
->ref
);
551 for(index
=0; index
<This
->nb_attributes
; index
++)
553 SysFreeString(This
->szLocalname
[index
]);
554 SysFreeString(This
->szPrefix
[index
]);
555 SysFreeString(This
->szURI
[index
]);
556 SysFreeString(This
->szValue
[index
]);
559 HeapFree(GetProcessHeap(), 0, This
->szLocalname
);
560 HeapFree(GetProcessHeap(), 0, This
->szPrefix
);
561 HeapFree(GetProcessHeap(), 0, This
->szURI
);
562 HeapFree(GetProcessHeap(), 0, This
->szValue
);
564 HeapFree(GetProcessHeap(), 0, This
);
570 /*** ISAXAttributes methods ***/
571 static HRESULT WINAPI
isaxattributes_getLength(
572 ISAXAttributes
* iface
,
575 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
577 *length
= This
->nb_attributes
;
578 TRACE("Length set to %d\n", *length
);
582 static HRESULT WINAPI
isaxattributes_getURI(
583 ISAXAttributes
* iface
,
588 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
590 FIXME("(%p)->(%d) stub\n", This
, nIndex
);
594 static HRESULT WINAPI
isaxattributes_getLocalName(
595 ISAXAttributes
* iface
,
597 const WCHAR
**pLocalName
,
598 int *pLocalNameLength
)
600 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
601 TRACE("(%p)->(%d)\n", This
, nIndex
);
603 if(nIndex
>= This
->nb_attributes
) return E_INVALIDARG
;
605 *pLocalNameLength
= SysStringLen(This
->szLocalname
[nIndex
]);
606 *pLocalName
= This
->szLocalname
[nIndex
];
611 static HRESULT WINAPI
isaxattributes_getQName(
612 ISAXAttributes
* iface
,
614 const WCHAR
**pQName
,
617 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
618 TRACE("(%p)->(%d)\n", This
, nIndex
);
620 if(nIndex
>= This
->nb_attributes
) return E_INVALIDARG
;
622 *pQNameLength
= SysStringLen(This
->szQName
[nIndex
]);
623 *pQName
= This
->szQName
[nIndex
];
628 static HRESULT WINAPI
isaxattributes_getName(
629 ISAXAttributes
* iface
,
633 const WCHAR
**pLocalName
,
635 const WCHAR
**pQName
,
638 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
640 FIXME("(%p)->(%d) stub\n", This
, nIndex
);
644 static HRESULT WINAPI
isaxattributes_getIndexFromName(
645 ISAXAttributes
* iface
,
648 const WCHAR
*pLocalName
,
652 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
654 FIXME("(%p)->(%s, %d, %s, %d) stub\n", This
, debugstr_w(pUri
), cUriLength
,
655 debugstr_w(pLocalName
), cocalNameLength
);
659 static HRESULT WINAPI
isaxattributes_getIndexFromQName(
660 ISAXAttributes
* iface
,
665 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
667 FIXME("(%p)->(%s, %d) stub\n", This
, debugstr_w(pQName
), nQNameLength
);
671 static HRESULT WINAPI
isaxattributes_getType(
672 ISAXAttributes
* iface
,
677 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
679 FIXME("(%p)->(%d) stub\n", This
, nIndex
);
683 static HRESULT WINAPI
isaxattributes_getTypeFromName(
684 ISAXAttributes
* iface
,
687 const WCHAR
*pLocalName
,
692 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
694 FIXME("(%p)->(%s, %d, %s, %d) stub\n", This
, debugstr_w(pUri
), nUri
,
695 debugstr_w(pLocalName
), nLocalName
);
699 static HRESULT WINAPI
isaxattributes_getTypeFromQName(
700 ISAXAttributes
* iface
,
706 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
708 FIXME("(%p)->(%s, %d) stub\n", This
, debugstr_w(pQName
), nQName
);
712 static HRESULT WINAPI
isaxattributes_getValue(
713 ISAXAttributes
* iface
,
715 const WCHAR
**pValue
,
718 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
719 TRACE("(%p)->(%d)\n", This
, nIndex
);
721 if(nIndex
>= This
->nb_attributes
) return E_INVALIDARG
;
723 *nValue
= SysStringLen(This
->szValue
[nIndex
]);
724 *pValue
= This
->szValue
[nIndex
];
729 static HRESULT WINAPI
isaxattributes_getValueFromName(
730 ISAXAttributes
* iface
,
733 const WCHAR
*pLocalName
,
735 const WCHAR
**pValue
,
738 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
740 FIXME("(%p)->(%s, %d, %s, %d) stub\n", This
, debugstr_w(pUri
), nUri
,
741 debugstr_w(pLocalName
), nLocalName
);
745 static HRESULT WINAPI
isaxattributes_getValueFromQName(
746 ISAXAttributes
* iface
,
749 const WCHAR
**pValue
,
752 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
754 FIXME("(%p)->(%s, %d) stub\n", This
, debugstr_w(pQName
), nQName
);
758 static const struct ISAXAttributesVtbl isaxattributes_vtbl
=
760 isaxattributes_QueryInterface
,
761 isaxattributes_AddRef
,
762 isaxattributes_Release
,
763 isaxattributes_getLength
,
764 isaxattributes_getURI
,
765 isaxattributes_getLocalName
,
766 isaxattributes_getQName
,
767 isaxattributes_getName
,
768 isaxattributes_getIndexFromName
,
769 isaxattributes_getIndexFromQName
,
770 isaxattributes_getType
,
771 isaxattributes_getTypeFromName
,
772 isaxattributes_getTypeFromQName
,
773 isaxattributes_getValue
,
774 isaxattributes_getValueFromName
,
775 isaxattributes_getValueFromQName
778 static HRESULT
SAXAttributes_create(saxattributes
**attr
,
779 int nb_attributes
, const xmlChar
**xmlAttributes
)
781 saxattributes
*attributes
;
784 attributes
= HeapAlloc(GetProcessHeap(), 0, sizeof(*attributes
));
786 return E_OUTOFMEMORY
;
788 attributes
->lpVBSAXAttributesVtbl
= &ivbsaxattributes_vtbl
;
789 attributes
->lpSAXAttributesVtbl
= &isaxattributes_vtbl
;
792 attributes
->nb_attributes
= nb_attributes
;
794 attributes
->szLocalname
=
795 HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR
)*nb_attributes
);
796 attributes
->szPrefix
=
797 HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR
)*nb_attributes
);
799 HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR
)*nb_attributes
);
800 attributes
->szValue
=
801 HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR
)*nb_attributes
);
802 attributes
->szQName
=
803 HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR
)*nb_attributes
);
805 if(!attributes
->szLocalname
|| !attributes
->szPrefix
806 || !attributes
->szURI
|| !attributes
->szValue
807 || !attributes
->szQName
)
809 HeapFree(GetProcessHeap(), 0, attributes
->szLocalname
);
810 HeapFree(GetProcessHeap(), 0, attributes
->szPrefix
);
811 HeapFree(GetProcessHeap(), 0, attributes
->szURI
);
812 HeapFree(GetProcessHeap(), 0, attributes
->szValue
);
813 HeapFree(GetProcessHeap(), 0, attributes
->szQName
);
814 HeapFree(GetProcessHeap(), 0, attributes
);
818 for(index
=0; index
<nb_attributes
; index
++)
822 attributes
->szLocalname
[index
] =
823 bstr_from_xmlChar(xmlAttributes
[index
*5]);
824 attributes
->szPrefix
[index
] =
825 bstr_from_xmlChar(xmlAttributes
[index
*5+1]);
826 attributes
->szURI
[index
] =
827 bstr_from_xmlChar(xmlAttributes
[index
*5+2]);
828 attributes
->szValue
[index
] =
829 bstr_from_xmlCharN(xmlAttributes
[index
*5+3],
830 xmlAttributes
[index
*5+4]-xmlAttributes
[index
*5+3]);
832 len1
= SysStringLen(attributes
->szPrefix
[index
]);
833 len2
= SysStringLen(attributes
->szLocalname
[index
]);
834 attributes
->szQName
[index
] = SysAllocStringLen(NULL
, len1
+len2
);
835 memcpy(attributes
->szQName
[index
], attributes
->szPrefix
[index
],
837 memcpy(attributes
->szQName
[index
]+len1
,
838 attributes
->szLocalname
[index
], len2
*sizeof(WCHAR
));
839 attributes
->szQName
[index
][len1
+len2
] = '\0';
844 TRACE("returning %p\n", *attr
);
849 /*** LibXML callbacks ***/
850 static void libxmlStartDocument(void *ctx
)
852 saxlocator
*This
= ctx
;
855 if(This
->saxreader
->contentHandler
)
857 if(This
->vbInterface
)
858 hr
= IVBSAXContentHandler_startDocument(This
->saxreader
->vbcontentHandler
);
860 hr
= ISAXContentHandler_startDocument(This
->saxreader
->contentHandler
);
863 format_error_message_from_id(This
, hr
);
866 update_position(This
, NULL
);
869 static void libxmlEndDocument(void *ctx
)
871 saxlocator
*This
= ctx
;
877 if(This
->ret
!= S_OK
) return;
879 if(This
->saxreader
->contentHandler
)
881 if(This
->vbInterface
)
882 hr
= IVBSAXContentHandler_endDocument(This
->saxreader
->vbcontentHandler
);
884 hr
= ISAXContentHandler_endDocument(This
->saxreader
->contentHandler
);
887 format_error_message_from_id(This
, hr
);
891 static void libxmlStartElementNS(
893 const xmlChar
*localname
,
894 const xmlChar
*prefix
,
897 const xmlChar
**namespaces
,
900 const xmlChar
**attributes
)
902 BSTR NamespaceUri
, LocalName
, QName
;
903 saxlocator
*This
= ctx
;
907 update_position(This
, (xmlChar
*)This
->pParserCtxt
->input
->cur
+1);
909 if(This
->saxreader
->contentHandler
)
911 NamespaceUri
= bstr_from_xmlChar(URI
);
912 LocalName
= bstr_from_xmlChar(localname
);
913 QName
= bstr_from_xmlChar(localname
);
915 hr
= SAXAttributes_create(&attr
, nb_attributes
, attributes
);
918 if(This
->vbInterface
)
919 hr
= IVBSAXContentHandler_startElement(
920 This
->saxreader
->vbcontentHandler
,
921 &NamespaceUri
, &LocalName
, &QName
,
922 (IVBSAXAttributes
*)&attr
->lpVBSAXAttributesVtbl
);
924 hr
= ISAXContentHandler_startElement(
925 This
->saxreader
->contentHandler
,
926 NamespaceUri
, SysStringLen(NamespaceUri
),
927 LocalName
, SysStringLen(LocalName
),
928 QName
, SysStringLen(QName
),
929 (ISAXAttributes
*)&attr
->lpSAXAttributesVtbl
);
931 ISAXAttributes_Release((ISAXAttributes
*)&attr
->lpSAXAttributesVtbl
);
934 SysFreeString(NamespaceUri
);
935 SysFreeString(LocalName
);
936 SysFreeString(QName
);
939 format_error_message_from_id(This
, hr
);
943 static void libxmlEndElementNS(
945 const xmlChar
*localname
,
946 const xmlChar
*prefix
,
949 BSTR NamespaceUri
, LocalName
, QName
;
950 saxlocator
*This
= ctx
;
955 while(*end
!= '<' && *(end
+1) != '/') end
++;
956 update_position(This
, end
+2);
958 if(This
->saxreader
->contentHandler
)
960 NamespaceUri
= bstr_from_xmlChar(URI
);
961 LocalName
= bstr_from_xmlChar(localname
);
962 QName
= bstr_from_xmlChar(localname
);
964 if(This
->vbInterface
)
965 hr
= IVBSAXContentHandler_endElement(
966 This
->saxreader
->vbcontentHandler
,
967 &NamespaceUri
, &LocalName
, &QName
);
969 hr
= ISAXContentHandler_endElement(
970 This
->saxreader
->contentHandler
,
971 NamespaceUri
, SysStringLen(NamespaceUri
),
972 LocalName
, SysStringLen(LocalName
),
973 QName
, SysStringLen(QName
));
975 SysFreeString(NamespaceUri
);
976 SysFreeString(LocalName
);
977 SysFreeString(QName
);
980 format_error_message_from_id(This
, hr
);
984 static void libxmlCharacters(
990 saxlocator
*This
= ctx
;
993 xmlChar
*lastCurCopy
;
998 if(*(This
->lastCur
-1) != '>' && *(This
->lastCur
-1) != '/') return;
1000 if(*(This
->lastCur
-1) != '>')
1002 end
= (xmlChar
*)This
->pParserCtxt
->input
->cur
-len
;
1003 while(*(end
-1) != '>') end
--;
1004 update_position(This
, end
);
1007 chEnd
= This
->lastCur
+len
;
1008 while(*chEnd
!= '<') chEnd
++;
1010 Chars
= bstr_from_xmlChar(ch
);
1012 lastCurCopy
= This
->lastCur
;
1013 columnCopy
= This
->column
;
1014 lineCopy
= This
->line
;
1015 end
= This
->lastCur
;
1017 if(This
->saxreader
->contentHandler
)
1019 while(This
->lastCur
< chEnd
)
1021 end
= This
->lastCur
;
1022 while(end
< chEnd
-1)
1024 if(*end
== '\r') break;
1028 Chars
= bstr_from_xmlChar(This
->lastCur
);
1030 if(*end
== '\r' && *(end
+1) == '\n')
1032 memmove((WCHAR
*)Chars
+(end
-This
->lastCur
),
1033 (WCHAR
*)Chars
+(end
-This
->lastCur
)+1,
1034 (SysStringLen(Chars
)-(end
-This
->lastCur
))*sizeof(WCHAR
));
1035 SysReAllocStringLen(&Chars
, Chars
, SysStringLen(Chars
)-1);
1037 else if(*end
== '\r') Chars
[end
-This
->lastCur
] = '\n';
1039 if(This
->vbInterface
)
1040 hr
= IVBSAXContentHandler_characters(
1041 This
->saxreader
->vbcontentHandler
, &Chars
);
1043 hr
= ISAXContentHandler_characters(
1044 This
->saxreader
->contentHandler
,
1045 Chars
, end
-This
->lastCur
+1);
1047 SysFreeString(Chars
);
1050 format_error_message_from_id(This
, hr
);
1054 if(*(end
+1) == '\n') end
++;
1055 if(end
< chEnd
) end
++;
1057 This
->column
+= end
-This
->lastCur
;
1058 This
->lastCur
= end
;
1061 This
->lastCur
= lastCurCopy
;
1062 This
->column
= columnCopy
;
1063 This
->line
= lineCopy
;
1064 update_position(This
, chEnd
);
1068 static void libxmlSetDocumentLocator(
1070 xmlSAXLocatorPtr loc
)
1072 saxlocator
*This
= ctx
;
1075 if(This
->vbInterface
)
1076 hr
= IVBSAXContentHandler_putref_documentLocator(
1077 This
->saxreader
->vbcontentHandler
,
1078 (IVBSAXLocator
*)&This
->lpVBSAXLocatorVtbl
);
1080 hr
= ISAXContentHandler_putDocumentLocator(
1081 This
->saxreader
->contentHandler
,
1082 (ISAXLocator
*)&This
->lpSAXLocatorVtbl
);
1085 format_error_message_from_id(This
, hr
);
1088 void libxmlFatalError(void *ctx
, const char *msg
, ...)
1090 saxlocator
*This
= ctx
;
1096 if(!This
->saxreader
->errorHandler
)
1098 xmlStopParser(This
->pParserCtxt
);
1103 FIXME("Error handling is not compatible.\n");
1105 va_start(args
, msg
);
1106 vsprintf(message
, msg
, args
);
1109 len
= MultiByteToWideChar(CP_ACP
, 0, message
, -1, NULL
, 0);
1110 wszError
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
)*len
);
1111 MultiByteToWideChar(CP_ACP
, 0, message
, -1, (LPWSTR
)wszError
, len
);
1113 if(This
->vbInterface
)
1115 BSTR bstrError
= SysAllocString(wszError
);
1116 IVBSAXErrorHandler_fatalError(This
->saxreader
->vberrorHandler
,
1117 (IVBSAXLocator
*)&This
->lpVBSAXLocatorVtbl
, &bstrError
, E_FAIL
);
1120 ISAXErrorHandler_fatalError(This
->saxreader
->errorHandler
,
1121 (ISAXLocator
*)&This
->lpSAXLocatorVtbl
, wszError
, E_FAIL
);
1123 HeapFree(GetProcessHeap(), 0, wszError
);
1125 xmlStopParser(This
->pParserCtxt
);
1129 /*** IVBSAXLocator interface ***/
1130 /*** IUnknown methods ***/
1131 static HRESULT WINAPI
ivbsaxlocator_QueryInterface(IVBSAXLocator
* iface
, REFIID riid
, void **ppvObject
)
1133 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1135 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
1139 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
1140 IsEqualGUID( riid
, &IID_IDispatch
) ||
1141 IsEqualGUID( riid
, &IID_IVBSAXLocator
))
1147 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1148 return E_NOINTERFACE
;
1151 IVBSAXLocator_AddRef( iface
);
1156 static ULONG WINAPI
ivbsaxlocator_AddRef(IVBSAXLocator
* iface
)
1158 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1159 TRACE("%p\n", This
);
1160 return InterlockedIncrement( &This
->ref
);
1163 static ULONG WINAPI
ivbsaxlocator_Release(
1164 IVBSAXLocator
* iface
)
1166 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1167 return ISAXLocator_Release((ISAXLocator
*)&This
->lpVBSAXLocatorVtbl
);
1170 /*** IDispatch methods ***/
1171 static HRESULT WINAPI
ivbsaxlocator_GetTypeInfoCount( IVBSAXLocator
*iface
, UINT
* pctinfo
)
1173 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1175 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1182 static HRESULT WINAPI
ivbsaxlocator_GetTypeInfo(
1183 IVBSAXLocator
*iface
,
1184 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
1186 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1189 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1191 hr
= get_typeinfo(IVBSAXLocator_tid
, ppTInfo
);
1196 static HRESULT WINAPI
ivbsaxlocator_GetIDsOfNames(
1197 IVBSAXLocator
*iface
,
1199 LPOLESTR
* rgszNames
,
1204 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1205 ITypeInfo
*typeinfo
;
1208 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1211 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
1212 return E_INVALIDARG
;
1214 hr
= get_typeinfo(IVBSAXLocator_tid
, &typeinfo
);
1217 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
1218 ITypeInfo_Release(typeinfo
);
1224 static HRESULT WINAPI
ivbsaxlocator_Invoke(
1225 IVBSAXLocator
*iface
,
1226 DISPID dispIdMember
,
1230 DISPPARAMS
* pDispParams
,
1231 VARIANT
* pVarResult
,
1232 EXCEPINFO
* pExcepInfo
,
1235 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1236 ITypeInfo
*typeinfo
;
1239 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1240 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1242 hr
= get_typeinfo(IVBSAXLocator_tid
, &typeinfo
);
1245 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVBSAXLocatorVtbl
), dispIdMember
, wFlags
, pDispParams
,
1246 pVarResult
, pExcepInfo
, puArgErr
);
1247 ITypeInfo_Release(typeinfo
);
1253 /*** IVBSAXLocator methods ***/
1254 static HRESULT WINAPI
ivbsaxlocator_get_columnNumber(
1255 IVBSAXLocator
* iface
,
1258 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1259 return ISAXLocator_getColumnNumber(
1260 (ISAXLocator
*)&This
->lpVBSAXLocatorVtbl
,
1264 static HRESULT WINAPI
ivbsaxlocator_get_lineNumber(
1265 IVBSAXLocator
* iface
,
1268 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1269 return ISAXLocator_getLineNumber(
1270 (ISAXLocator
*)&This
->lpVBSAXLocatorVtbl
,
1274 static HRESULT WINAPI
ivbsaxlocator_get_publicId(
1275 IVBSAXLocator
* iface
,
1278 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1279 return ISAXLocator_getPublicId(
1280 (ISAXLocator
*)&This
->lpVBSAXLocatorVtbl
,
1281 (const WCHAR
**)publicId
);
1284 static HRESULT WINAPI
ivbsaxlocator_get_systemId(
1285 IVBSAXLocator
* iface
,
1288 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1289 return ISAXLocator_getSystemId(
1290 (ISAXLocator
*)&This
->lpVBSAXLocatorVtbl
,
1291 (const WCHAR
**)systemId
);
1294 static const struct IVBSAXLocatorVtbl ivbsaxlocator_vtbl
=
1296 ivbsaxlocator_QueryInterface
,
1297 ivbsaxlocator_AddRef
,
1298 ivbsaxlocator_Release
,
1299 ivbsaxlocator_GetTypeInfoCount
,
1300 ivbsaxlocator_GetTypeInfo
,
1301 ivbsaxlocator_GetIDsOfNames
,
1302 ivbsaxlocator_Invoke
,
1303 ivbsaxlocator_get_columnNumber
,
1304 ivbsaxlocator_get_lineNumber
,
1305 ivbsaxlocator_get_publicId
,
1306 ivbsaxlocator_get_systemId
1309 /*** ISAXLocator interface ***/
1310 /*** IUnknown methods ***/
1311 static HRESULT WINAPI
isaxlocator_QueryInterface(ISAXLocator
* iface
, REFIID riid
, void **ppvObject
)
1313 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1315 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
1319 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
1320 IsEqualGUID( riid
, &IID_ISAXLocator
))
1326 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1327 return E_NOINTERFACE
;
1330 ISAXLocator_AddRef( iface
);
1335 static ULONG WINAPI
isaxlocator_AddRef(ISAXLocator
* iface
)
1337 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1338 TRACE("%p\n", This
);
1339 return InterlockedIncrement( &This
->ref
);
1342 static ULONG WINAPI
isaxlocator_Release(
1345 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1348 TRACE("%p\n", This
);
1350 ref
= InterlockedDecrement( &This
->ref
);
1354 SysFreeString(This
->publicId
);
1356 SysFreeString(This
->systemId
);
1358 ISAXXMLReader_Release((ISAXXMLReader
*)&This
->saxreader
->lpSAXXMLReaderVtbl
);
1359 HeapFree( GetProcessHeap(), 0, This
);
1365 /*** ISAXLocator methods ***/
1366 static HRESULT WINAPI
isaxlocator_getColumnNumber(
1370 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1372 *pnColumn
= This
->column
;
1376 static HRESULT WINAPI
isaxlocator_getLineNumber(
1380 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1382 *pnLine
= This
->line
;
1386 static HRESULT WINAPI
isaxlocator_getPublicId(
1388 const WCHAR
** ppwchPublicId
)
1391 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1393 if(This
->publicId
) SysFreeString(This
->publicId
);
1395 publicId
= bstr_from_xmlChar(xmlSAX2GetPublicId(This
->pParserCtxt
));
1396 if(SysStringLen(publicId
))
1397 This
->publicId
= (WCHAR
*)&publicId
;
1400 SysFreeString(publicId
);
1401 This
->publicId
= NULL
;
1404 *ppwchPublicId
= This
->publicId
;
1408 static HRESULT WINAPI
isaxlocator_getSystemId(
1410 const WCHAR
** ppwchSystemId
)
1413 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1415 if(This
->systemId
) SysFreeString(This
->systemId
);
1417 systemId
= bstr_from_xmlChar(xmlSAX2GetSystemId(This
->pParserCtxt
));
1418 if(SysStringLen(systemId
))
1419 This
->systemId
= (WCHAR
*)&systemId
;
1422 SysFreeString(systemId
);
1423 This
->systemId
= NULL
;
1426 *ppwchSystemId
= This
->systemId
;
1430 static const struct ISAXLocatorVtbl isaxlocator_vtbl
=
1432 isaxlocator_QueryInterface
,
1434 isaxlocator_Release
,
1435 isaxlocator_getColumnNumber
,
1436 isaxlocator_getLineNumber
,
1437 isaxlocator_getPublicId
,
1438 isaxlocator_getSystemId
1441 static HRESULT
SAXLocator_create(saxreader
*reader
, saxlocator
**ppsaxlocator
, BOOL vbInterface
)
1443 saxlocator
*locator
;
1445 locator
= HeapAlloc( GetProcessHeap(), 0, sizeof (*locator
) );
1447 return E_OUTOFMEMORY
;
1449 locator
->lpVBSAXLocatorVtbl
= &ivbsaxlocator_vtbl
;
1450 locator
->lpSAXLocatorVtbl
= &isaxlocator_vtbl
;
1452 locator
->vbInterface
= vbInterface
;
1454 locator
->saxreader
= reader
;
1455 ISAXXMLReader_AddRef((ISAXXMLReader
*)&reader
->lpSAXXMLReaderVtbl
);
1457 locator
->pParserCtxt
= NULL
;
1458 locator
->publicId
= NULL
;
1459 locator
->systemId
= NULL
;
1460 locator
->lastCur
= NULL
;
1462 locator
->column
= 0;
1463 locator
->ret
= S_OK
;
1465 *ppsaxlocator
= locator
;
1467 TRACE("returning %p\n", *ppsaxlocator
);
1472 /*** SAXXMLReader internal functions ***/
1473 static HRESULT
internal_parseBuffer(saxreader
*This
, const char *buffer
, int size
, BOOL vbInterface
)
1475 saxlocator
*locator
;
1478 hr
= SAXLocator_create(This
, &locator
, vbInterface
);
1482 locator
->pParserCtxt
= xmlCreateMemoryParserCtxt(buffer
, size
);
1483 if(!locator
->pParserCtxt
)
1485 ISAXLocator_Release((ISAXLocator
*)&locator
->lpSAXLocatorVtbl
);
1489 locator
->pParserCtxt
->sax
= &locator
->saxreader
->sax
;
1490 locator
->pParserCtxt
->userData
= locator
;
1492 if(xmlParseDocument(locator
->pParserCtxt
)) hr
= E_FAIL
;
1493 else hr
= locator
->ret
;
1495 if(locator
->pParserCtxt
)
1497 locator
->pParserCtxt
->sax
= NULL
;
1498 xmlFreeParserCtxt(locator
->pParserCtxt
);
1499 locator
->pParserCtxt
= NULL
;
1502 ISAXLocator_Release((ISAXLocator
*)&locator
->lpSAXLocatorVtbl
);
1506 static HRESULT WINAPI
internal_getEntityResolver(
1508 void *pEntityResolver
,
1511 FIXME("(%p)->(%p) stub\n", This
, pEntityResolver
);
1515 static HRESULT WINAPI
internal_putEntityResolver(
1517 void *pEntityResolver
,
1520 FIXME("(%p)->(%p) stub\n", This
, pEntityResolver
);
1524 static HRESULT WINAPI
internal_getContentHandler(
1526 void *pContentHandler
,
1529 TRACE("(%p)->(%p)\n", This
, pContentHandler
);
1530 if(pContentHandler
== NULL
)
1532 if(This
->contentHandler
)
1535 IVBSAXContentHandler_AddRef(This
->vbcontentHandler
);
1537 ISAXContentHandler_AddRef(This
->contentHandler
);
1539 if(vbInterface
) *(IVBSAXContentHandler
**)pContentHandler
=
1540 This
->vbcontentHandler
;
1541 else *(ISAXContentHandler
**)pContentHandler
= This
->contentHandler
;
1546 static HRESULT WINAPI
internal_putContentHandler(
1548 void *contentHandler
,
1551 TRACE("(%p)->(%p)\n", This
, contentHandler
);
1555 IVBSAXContentHandler_AddRef((IVBSAXContentHandler
*)contentHandler
);
1557 ISAXContentHandler_AddRef((ISAXContentHandler
*)contentHandler
);
1559 if(This
->contentHandler
)
1562 IVBSAXContentHandler_Release(This
->vbcontentHandler
);
1564 ISAXContentHandler_Release(This
->contentHandler
);
1567 This
->vbcontentHandler
= contentHandler
;
1569 This
->contentHandler
= contentHandler
;
1574 static HRESULT WINAPI
internal_getDTDHandler(
1579 FIXME("(%p)->(%p) stub\n", This
, pDTDHandler
);
1583 static HRESULT WINAPI
internal_putDTDHandler(
1588 FIXME("(%p)->(%p) stub\n", This
, pDTDHandler
);
1592 static HRESULT WINAPI
internal_getErrorHandler(
1594 void *pErrorHandler
,
1597 TRACE("(%p)->(%p)\n", This
, pErrorHandler
);
1598 if(pErrorHandler
== NULL
)
1600 if(This
->errorHandler
)
1603 IVBSAXErrorHandler_AddRef(This
->vberrorHandler
);
1605 ISAXErrorHandler_AddRef(This
->errorHandler
);
1608 *(IVBSAXErrorHandler
**)pErrorHandler
= This
->vberrorHandler
;
1610 *(ISAXErrorHandler
**)pErrorHandler
= This
->errorHandler
;
1616 static HRESULT WINAPI
internal_putErrorHandler(
1621 TRACE("(%p)->(%p)\n", This
, errorHandler
);
1625 IVBSAXErrorHandler_AddRef((IVBSAXErrorHandler
*)errorHandler
);
1627 ISAXErrorHandler_AddRef((ISAXErrorHandler
*)errorHandler
);
1629 if(This
->errorHandler
)
1632 IVBSAXErrorHandler_Release(This
->vberrorHandler
);
1634 ISAXErrorHandler_Release(This
->errorHandler
);
1637 This
->vberrorHandler
= errorHandler
;
1639 This
->errorHandler
= errorHandler
;
1645 static HRESULT WINAPI
internal_parse(
1652 TRACE("(%p)\n", This
);
1655 switch(V_VT(&varInput
))
1658 hr
= internal_parseBuffer(This
, (const char*)V_BSTR(&varInput
),
1659 SysStringByteLen(V_BSTR(&varInput
)), vbInterface
);
1661 case VT_ARRAY
|VT_UI1
: {
1663 LONG lBound
, uBound
;
1666 hr
= SafeArrayGetLBound(V_ARRAY(&varInput
), 1, &lBound
);
1667 if(hr
!= S_OK
) break;
1668 hr
= SafeArrayGetUBound(V_ARRAY(&varInput
), 1, &uBound
);
1669 if(hr
!= S_OK
) break;
1670 dataRead
= (uBound
-lBound
)*SafeArrayGetElemsize(V_ARRAY(&varInput
));
1671 hr
= SafeArrayAccessData(V_ARRAY(&varInput
), (void**)&pSAData
);
1672 if(hr
!= S_OK
) break;
1673 hr
= internal_parseBuffer(This
, pSAData
, dataRead
, vbInterface
);
1674 SafeArrayUnaccessData(V_ARRAY(&varInput
));
1679 IPersistStream
*persistStream
;
1680 IStream
*stream
= NULL
;
1681 IXMLDOMDocument
*xmlDoc
;
1683 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
1684 &IID_IPersistStream
, (void**)&persistStream
) == S_OK
)
1686 hr
= IPersistStream_Save(persistStream
, stream
, TRUE
);
1687 IPersistStream_Release(persistStream
);
1688 if(hr
!= S_OK
) break;
1690 if(stream
|| IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
1691 &IID_IStream
, (void**)&stream
) == S_OK
)
1699 hr
= IStream_Stat(stream
, &dataInfo
, STATFLAG_NONAME
);
1700 if(hr
== E_PENDING
) continue;
1703 data
= HeapAlloc(GetProcessHeap(), 0,
1704 dataInfo
.cbSize
.QuadPart
);
1707 hr
= IStream_Read(stream
, data
,
1708 dataInfo
.cbSize
.QuadPart
, &dataRead
);
1709 if(hr
== E_PENDING
) continue;
1712 hr
= internal_parseBuffer(This
, data
,
1713 dataInfo
.cbSize
.QuadPart
, vbInterface
);
1714 HeapFree(GetProcessHeap(), 0, data
);
1715 IStream_Release(stream
);
1718 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
1719 &IID_IXMLDOMDocument
, (void**)&xmlDoc
) == S_OK
)
1723 IXMLDOMDocument_get_xml(xmlDoc
, &bstrData
);
1724 hr
= internal_parseBuffer(This
, (const char*)bstrData
,
1725 SysStringByteLen(bstrData
), vbInterface
);
1726 IXMLDOMDocument_Release(xmlDoc
);
1732 WARN("vt %d not implemented\n", V_VT(&varInput
));
1739 static HRESULT
internal_vbonDataAvailable(void *obj
, char *ptr
, DWORD len
)
1741 saxreader
*This
= obj
;
1743 return internal_parseBuffer(This
, ptr
, len
, TRUE
);
1746 static HRESULT
internal_onDataAvailable(void *obj
, char *ptr
, DWORD len
)
1748 saxreader
*This
= obj
;
1750 return internal_parseBuffer(This
, ptr
, len
, FALSE
);
1753 static HRESULT WINAPI
internal_parseURL(
1761 TRACE("(%p)->(%s)\n", This
, debugstr_w(url
));
1763 if(vbInterface
) hr
= bind_url(url
, internal_vbonDataAvailable
, This
, &bsc
);
1764 else hr
= bind_url(url
, internal_onDataAvailable
, This
, &bsc
);
1774 /*** IVBSAXXMLReader interface ***/
1775 /*** IUnknown methods ***/
1776 static HRESULT WINAPI
saxxmlreader_QueryInterface(IVBSAXXMLReader
* iface
, REFIID riid
, void **ppvObject
)
1778 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1780 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
1784 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
1785 IsEqualGUID( riid
, &IID_IDispatch
) ||
1786 IsEqualGUID( riid
, &IID_IVBSAXXMLReader
))
1790 else if( IsEqualGUID( riid
, &IID_ISAXXMLReader
))
1792 *ppvObject
= (ISAXXMLReader
*)&This
->lpSAXXMLReaderVtbl
;
1796 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1797 return E_NOINTERFACE
;
1800 IVBSAXXMLReader_AddRef( iface
);
1805 static ULONG WINAPI
saxxmlreader_AddRef(IVBSAXXMLReader
* iface
)
1807 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1808 TRACE("%p\n", This
);
1809 return InterlockedIncrement( &This
->ref
);
1812 static ULONG WINAPI
saxxmlreader_Release(
1813 IVBSAXXMLReader
* iface
)
1815 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1818 TRACE("%p\n", This
);
1820 ref
= InterlockedDecrement( &This
->ref
);
1823 if(This
->contentHandler
)
1824 ISAXContentHandler_Release(This
->contentHandler
);
1826 if(This
->errorHandler
)
1827 ISAXErrorHandler_Release(This
->errorHandler
);
1829 HeapFree( GetProcessHeap(), 0, This
);
1835 static HRESULT WINAPI
saxxmlreader_GetTypeInfoCount( IVBSAXXMLReader
*iface
, UINT
* pctinfo
)
1837 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1839 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1846 static HRESULT WINAPI
saxxmlreader_GetTypeInfo(
1847 IVBSAXXMLReader
*iface
,
1848 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
1850 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1853 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1855 hr
= get_typeinfo(IVBSAXXMLReader_tid
, ppTInfo
);
1860 static HRESULT WINAPI
saxxmlreader_GetIDsOfNames(
1861 IVBSAXXMLReader
*iface
,
1863 LPOLESTR
* rgszNames
,
1868 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1869 ITypeInfo
*typeinfo
;
1872 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1875 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
1876 return E_INVALIDARG
;
1878 hr
= get_typeinfo(IVBSAXXMLReader_tid
, &typeinfo
);
1881 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
1882 ITypeInfo_Release(typeinfo
);
1888 static HRESULT WINAPI
saxxmlreader_Invoke(
1889 IVBSAXXMLReader
*iface
,
1890 DISPID dispIdMember
,
1894 DISPPARAMS
* pDispParams
,
1895 VARIANT
* pVarResult
,
1896 EXCEPINFO
* pExcepInfo
,
1899 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1900 ITypeInfo
*typeinfo
;
1903 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1904 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1906 hr
= get_typeinfo(IVBSAXXMLReader_tid
, &typeinfo
);
1909 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVBSAXXMLReaderVtbl
), dispIdMember
, wFlags
, pDispParams
,
1910 pVarResult
, pExcepInfo
, puArgErr
);
1911 ITypeInfo_Release(typeinfo
);
1917 /*** IVBSAXXMLReader methods ***/
1918 static HRESULT WINAPI
saxxmlreader_getFeature(
1919 IVBSAXXMLReader
* iface
,
1920 const WCHAR
*pFeature
,
1921 VARIANT_BOOL
*pValue
)
1923 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1925 FIXME("(%p)->(%s %p) stub\n", This
, debugstr_w(pFeature
), pValue
);
1929 static HRESULT WINAPI
saxxmlreader_putFeature(
1930 IVBSAXXMLReader
* iface
,
1931 const WCHAR
*pFeature
,
1932 VARIANT_BOOL vfValue
)
1934 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1936 FIXME("(%p)->(%s %x) stub\n", This
, debugstr_w(pFeature
), vfValue
);
1940 static HRESULT WINAPI
saxxmlreader_getProperty(
1941 IVBSAXXMLReader
* iface
,
1945 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1947 FIXME("(%p)->(%s %p) stub\n", This
, debugstr_w(pProp
), pValue
);
1951 static HRESULT WINAPI
saxxmlreader_putProperty(
1952 IVBSAXXMLReader
* iface
,
1956 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1958 FIXME("(%p)->(%s) stub\n", This
, debugstr_w(pProp
));
1962 static HRESULT WINAPI
saxxmlreader_getEntityResolver(
1963 IVBSAXXMLReader
* iface
,
1964 IVBSAXEntityResolver
**pEntityResolver
)
1966 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1967 return internal_getEntityResolver(This
, pEntityResolver
, TRUE
);
1970 static HRESULT WINAPI
saxxmlreader_putEntityResolver(
1971 IVBSAXXMLReader
* iface
,
1972 IVBSAXEntityResolver
*pEntityResolver
)
1974 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1975 return internal_putEntityResolver(This
, pEntityResolver
, TRUE
);
1978 static HRESULT WINAPI
saxxmlreader_getContentHandler(
1979 IVBSAXXMLReader
* iface
,
1980 IVBSAXContentHandler
**ppContentHandler
)
1982 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1983 return internal_getContentHandler(This
, ppContentHandler
, TRUE
);
1986 static HRESULT WINAPI
saxxmlreader_putContentHandler(
1987 IVBSAXXMLReader
* iface
,
1988 IVBSAXContentHandler
*contentHandler
)
1990 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1991 return internal_putContentHandler(This
, contentHandler
, TRUE
);
1994 static HRESULT WINAPI
saxxmlreader_getDTDHandler(
1995 IVBSAXXMLReader
* iface
,
1996 IVBSAXDTDHandler
**pDTDHandler
)
1998 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1999 return internal_getDTDHandler(This
, pDTDHandler
, TRUE
);
2002 static HRESULT WINAPI
saxxmlreader_putDTDHandler(
2003 IVBSAXXMLReader
* iface
,
2004 IVBSAXDTDHandler
*pDTDHandler
)
2006 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2007 return internal_putDTDHandler(This
, pDTDHandler
, TRUE
);
2010 static HRESULT WINAPI
saxxmlreader_getErrorHandler(
2011 IVBSAXXMLReader
* iface
,
2012 IVBSAXErrorHandler
**pErrorHandler
)
2014 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2015 return internal_getErrorHandler(This
, pErrorHandler
, TRUE
);
2018 static HRESULT WINAPI
saxxmlreader_putErrorHandler(
2019 IVBSAXXMLReader
* iface
,
2020 IVBSAXErrorHandler
*errorHandler
)
2022 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2023 return internal_putErrorHandler(This
, errorHandler
, TRUE
);
2026 static HRESULT WINAPI
saxxmlreader_getBaseURL(
2027 IVBSAXXMLReader
* iface
,
2028 const WCHAR
**pBaseUrl
)
2030 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2032 FIXME("(%p)->(%p) stub\n", This
, pBaseUrl
);
2036 static HRESULT WINAPI
saxxmlreader_putBaseURL(
2037 IVBSAXXMLReader
* iface
,
2038 const WCHAR
*pBaseUrl
)
2040 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2042 FIXME("(%p)->(%s) stub\n", This
, debugstr_w(pBaseUrl
));
2046 static HRESULT WINAPI
saxxmlreader_getSecureBaseURL(
2047 IVBSAXXMLReader
* iface
,
2048 const WCHAR
**pSecureBaseUrl
)
2050 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2052 FIXME("(%p)->(%p) stub\n", This
, pSecureBaseUrl
);
2057 static HRESULT WINAPI
saxxmlreader_putSecureBaseURL(
2058 IVBSAXXMLReader
* iface
,
2059 const WCHAR
*secureBaseUrl
)
2061 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2063 FIXME("(%p)->(%s) stub\n", This
, debugstr_w(secureBaseUrl
));
2067 static HRESULT WINAPI
saxxmlreader_parse(
2068 IVBSAXXMLReader
* iface
,
2071 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2072 return internal_parse(This
, varInput
, TRUE
);
2075 static HRESULT WINAPI
saxxmlreader_parseURL(
2076 IVBSAXXMLReader
* iface
,
2079 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2080 return internal_parseURL(This
, url
, TRUE
);
2083 static const struct IVBSAXXMLReaderVtbl saxreader_vtbl
=
2085 saxxmlreader_QueryInterface
,
2086 saxxmlreader_AddRef
,
2087 saxxmlreader_Release
,
2088 saxxmlreader_GetTypeInfoCount
,
2089 saxxmlreader_GetTypeInfo
,
2090 saxxmlreader_GetIDsOfNames
,
2091 saxxmlreader_Invoke
,
2092 saxxmlreader_getFeature
,
2093 saxxmlreader_putFeature
,
2094 saxxmlreader_getProperty
,
2095 saxxmlreader_putProperty
,
2096 saxxmlreader_getEntityResolver
,
2097 saxxmlreader_putEntityResolver
,
2098 saxxmlreader_getContentHandler
,
2099 saxxmlreader_putContentHandler
,
2100 saxxmlreader_getDTDHandler
,
2101 saxxmlreader_putDTDHandler
,
2102 saxxmlreader_getErrorHandler
,
2103 saxxmlreader_putErrorHandler
,
2104 saxxmlreader_getBaseURL
,
2105 saxxmlreader_putBaseURL
,
2106 saxxmlreader_getSecureBaseURL
,
2107 saxxmlreader_putSecureBaseURL
,
2109 saxxmlreader_parseURL
2112 /*** ISAXXMLReader interface ***/
2113 /*** IUnknown methods ***/
2114 static HRESULT WINAPI
isaxxmlreader_QueryInterface(ISAXXMLReader
* iface
, REFIID riid
, void **ppvObject
)
2116 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2117 return saxxmlreader_QueryInterface((IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
, riid
, ppvObject
);
2120 static ULONG WINAPI
isaxxmlreader_AddRef(ISAXXMLReader
* iface
)
2122 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2123 return saxxmlreader_AddRef((IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
);
2126 static ULONG WINAPI
isaxxmlreader_Release(ISAXXMLReader
* iface
)
2128 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2129 return saxxmlreader_Release((IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
);
2132 /*** ISAXXMLReader methods ***/
2133 static HRESULT WINAPI
isaxxmlreader_getFeature(
2134 ISAXXMLReader
* iface
,
2135 const WCHAR
*pFeature
,
2136 VARIANT_BOOL
*pValue
)
2138 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2139 return IVBSAXXMLReader_getFeature(
2140 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2144 static HRESULT WINAPI
isaxxmlreader_putFeature(
2145 ISAXXMLReader
* iface
,
2146 const WCHAR
*pFeature
,
2147 VARIANT_BOOL vfValue
)
2149 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2150 return IVBSAXXMLReader_putFeature(
2151 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2155 static HRESULT WINAPI
isaxxmlreader_getProperty(
2156 ISAXXMLReader
* iface
,
2160 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2161 return IVBSAXXMLReader_getProperty(
2162 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2166 static HRESULT WINAPI
isaxxmlreader_putProperty(
2167 ISAXXMLReader
* iface
,
2171 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2172 return IVBSAXXMLReader_putProperty(
2173 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2177 static HRESULT WINAPI
isaxxmlreader_getEntityResolver(
2178 ISAXXMLReader
* iface
,
2179 ISAXEntityResolver
**ppEntityResolver
)
2181 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2182 return internal_getEntityResolver(This
, ppEntityResolver
, FALSE
);
2185 static HRESULT WINAPI
isaxxmlreader_putEntityResolver(
2186 ISAXXMLReader
* iface
,
2187 ISAXEntityResolver
*pEntityResolver
)
2189 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2190 return internal_putEntityResolver(This
, pEntityResolver
, FALSE
);
2193 static HRESULT WINAPI
isaxxmlreader_getContentHandler(
2194 ISAXXMLReader
* iface
,
2195 ISAXContentHandler
**pContentHandler
)
2197 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2198 return internal_getContentHandler(This
, pContentHandler
, FALSE
);
2201 static HRESULT WINAPI
isaxxmlreader_putContentHandler(
2202 ISAXXMLReader
* iface
,
2203 ISAXContentHandler
*contentHandler
)
2205 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2206 return internal_putContentHandler(This
, contentHandler
, FALSE
);
2209 static HRESULT WINAPI
isaxxmlreader_getDTDHandler(
2210 ISAXXMLReader
* iface
,
2211 ISAXDTDHandler
**pDTDHandler
)
2213 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2214 return internal_getDTDHandler(This
, pDTDHandler
, FALSE
);
2217 static HRESULT WINAPI
isaxxmlreader_putDTDHandler(
2218 ISAXXMLReader
* iface
,
2219 ISAXDTDHandler
*pDTDHandler
)
2221 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2222 return internal_putDTDHandler(This
, pDTDHandler
, FALSE
);
2225 static HRESULT WINAPI
isaxxmlreader_getErrorHandler(
2226 ISAXXMLReader
* iface
,
2227 ISAXErrorHandler
**pErrorHandler
)
2229 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2230 return internal_getErrorHandler(This
, pErrorHandler
, FALSE
);
2233 static HRESULT WINAPI
isaxxmlreader_putErrorHandler(
2234 ISAXXMLReader
* iface
,
2235 ISAXErrorHandler
*errorHandler
)
2237 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2238 return internal_putErrorHandler(This
, errorHandler
, FALSE
);
2241 static HRESULT WINAPI
isaxxmlreader_getBaseURL(
2242 ISAXXMLReader
* iface
,
2243 const WCHAR
**pBaseUrl
)
2245 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2246 return IVBSAXXMLReader_get_getBaseURL(
2247 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2251 static HRESULT WINAPI
isaxxmlreader_putBaseURL(
2252 ISAXXMLReader
* iface
,
2253 const WCHAR
*pBaseUrl
)
2255 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2256 return IVBSAXXMLReader_put_putBaseURL(
2257 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2261 static HRESULT WINAPI
isaxxmlreader_getSecureBaseURL(
2262 ISAXXMLReader
* iface
,
2263 const WCHAR
**pSecureBaseUrl
)
2265 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2266 return IVBSAXXMLReader_get_getSecureBaseURL(
2267 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2271 static HRESULT WINAPI
isaxxmlreader_putSecureBaseURL(
2272 ISAXXMLReader
* iface
,
2273 const WCHAR
*secureBaseUrl
)
2275 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2276 return IVBSAXXMLReader_put_putSecureBaseURL(
2277 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2281 static HRESULT WINAPI
isaxxmlreader_parse(
2282 ISAXXMLReader
* iface
,
2285 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2286 return internal_parse(This
, varInput
, FALSE
);
2289 static HRESULT WINAPI
isaxxmlreader_parseURL(
2290 ISAXXMLReader
* iface
,
2293 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2294 return internal_parseURL(This
, url
, FALSE
);
2297 static const struct ISAXXMLReaderVtbl isaxreader_vtbl
=
2299 isaxxmlreader_QueryInterface
,
2300 isaxxmlreader_AddRef
,
2301 isaxxmlreader_Release
,
2302 isaxxmlreader_getFeature
,
2303 isaxxmlreader_putFeature
,
2304 isaxxmlreader_getProperty
,
2305 isaxxmlreader_putProperty
,
2306 isaxxmlreader_getEntityResolver
,
2307 isaxxmlreader_putEntityResolver
,
2308 isaxxmlreader_getContentHandler
,
2309 isaxxmlreader_putContentHandler
,
2310 isaxxmlreader_getDTDHandler
,
2311 isaxxmlreader_putDTDHandler
,
2312 isaxxmlreader_getErrorHandler
,
2313 isaxxmlreader_putErrorHandler
,
2314 isaxxmlreader_getBaseURL
,
2315 isaxxmlreader_putBaseURL
,
2316 isaxxmlreader_getSecureBaseURL
,
2317 isaxxmlreader_putSecureBaseURL
,
2318 isaxxmlreader_parse
,
2319 isaxxmlreader_parseURL
2322 HRESULT
SAXXMLReader_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
2326 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
2328 reader
= HeapAlloc( GetProcessHeap(), 0, sizeof (*reader
) );
2330 return E_OUTOFMEMORY
;
2332 reader
->lpVBSAXXMLReaderVtbl
= &saxreader_vtbl
;
2333 reader
->lpSAXXMLReaderVtbl
= &isaxreader_vtbl
;
2335 reader
->contentHandler
= NULL
;
2336 reader
->errorHandler
= NULL
;
2338 memset(&reader
->sax
, 0, sizeof(xmlSAXHandler
));
2339 reader
->sax
.initialized
= XML_SAX2_MAGIC
;
2340 reader
->sax
.startDocument
= libxmlStartDocument
;
2341 reader
->sax
.endDocument
= libxmlEndDocument
;
2342 reader
->sax
.startElementNs
= libxmlStartElementNS
;
2343 reader
->sax
.endElementNs
= libxmlEndElementNS
;
2344 reader
->sax
.characters
= libxmlCharacters
;
2345 reader
->sax
.setDocumentLocator
= libxmlSetDocumentLocator
;
2346 reader
->sax
.error
= libxmlFatalError
;
2347 reader
->sax
.fatalError
= libxmlFatalError
;
2349 *ppObj
= &reader
->lpVBSAXXMLReaderVtbl
;
2351 TRACE("returning iface %p\n", *ppObj
);
2358 HRESULT
SAXXMLReader_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
2360 MESSAGE("This program tried to use a SAX XML Reader object, but\n"
2361 "libxml2 support was not present at compile time.\n");