Commit f27159a5 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Respect 'namespaces' feature calling content handler callbacks.

parent 137a21d0
...@@ -302,6 +302,11 @@ static inline HRESULT get_feature_value(const saxreader *reader, saxreader_featu ...@@ -302,6 +302,11 @@ static inline HRESULT get_feature_value(const saxreader *reader, saxreader_featu
return S_OK; return S_OK;
} }
static BOOL is_namespaces_enabled(const saxreader *reader)
{
return (reader->version < MSXML4) || (reader->features & Namespaces);
}
static inline BOOL has_content_handler(const saxlocator *locator) static inline BOOL has_content_handler(const saxlocator *locator)
{ {
return (locator->vbInterface && locator->saxreader->vbcontentHandler) || return (locator->vbInterface && locator->saxreader->vbcontentHandler) ||
...@@ -1286,42 +1291,53 @@ static void libxmlStartElementNS( ...@@ -1286,42 +1291,53 @@ static void libxmlStartElementNS(
if (has_content_handler(This)) if (has_content_handler(This))
{ {
BSTR uri; BSTR uri;
int i;
for (i = 0; i < nb_namespaces; i++) if (is_namespaces_enabled(This->saxreader))
{ {
if(This->vbInterface) int i;
hr = IVBSAXContentHandler_startPrefixMapping(
This->saxreader->vbcontentHandler,
&element->ns[i].prefix,
&element->ns[i].uri);
else
hr = ISAXContentHandler_startPrefixMapping(
This->saxreader->contentHandler,
element->ns[i].prefix,
SysStringLen(element->ns[i].prefix),
element->ns[i].uri,
SysStringLen(element->ns[i].uri));
if (sax_callback_failed(This, hr)) for (i = 0; i < nb_namespaces; i++)
{ {
format_error_message_from_id(This, hr); if (This->vbInterface)
return; hr = IVBSAXContentHandler_startPrefixMapping(
This->saxreader->vbcontentHandler,
&element->ns[i].prefix,
&element->ns[i].uri);
else
hr = ISAXContentHandler_startPrefixMapping(
This->saxreader->contentHandler,
element->ns[i].prefix,
SysStringLen(element->ns[i].prefix),
element->ns[i].uri,
SysStringLen(element->ns[i].uri));
if (sax_callback_failed(This, hr))
{
format_error_message_from_id(This, hr);
return;
}
} }
} }
uri = find_element_uri(This, URI); uri = find_element_uri(This, URI);
hr = SAXAttributes_populate(This, nb_namespaces, namespaces, nb_attributes, attributes); hr = SAXAttributes_populate(This, nb_namespaces, namespaces, nb_attributes, attributes);
if(hr == S_OK) if (hr == S_OK)
{ {
if(This->vbInterface) BSTR local;
if (is_namespaces_enabled(This->saxreader))
local = element->local;
else
uri = local = NULL;
if (This->vbInterface)
hr = IVBSAXContentHandler_startElement(This->saxreader->vbcontentHandler, hr = IVBSAXContentHandler_startElement(This->saxreader->vbcontentHandler,
&uri, &element->local, &element->qname, &This->IVBSAXAttributes_iface); &uri, &local, &element->qname, &This->IVBSAXAttributes_iface);
else else
hr = ISAXContentHandler_startElement(This->saxreader->contentHandler, hr = ISAXContentHandler_startElement(This->saxreader->contentHandler,
uri, SysStringLen(uri), uri, SysStringLen(uri),
element->local, SysStringLen(element->local), local, SysStringLen(local),
element->qname, SysStringLen(element->qname), element->qname, SysStringLen(element->qname),
&This->ISAXAttributes_iface); &This->ISAXAttributes_iface);
} }
...@@ -1340,9 +1356,8 @@ static void libxmlEndElementNS( ...@@ -1340,9 +1356,8 @@ static void libxmlEndElementNS(
saxlocator *This = ctx; saxlocator *This = ctx;
element_entry *element; element_entry *element;
const xmlChar *p; const xmlChar *p;
BSTR uri, local;
HRESULT hr; HRESULT hr;
BSTR uri;
int i;
update_position(This, FALSE); update_position(This, FALSE);
p = This->pParserCtxt->input->cur; p = This->pParserCtxt->input->cur;
...@@ -1382,15 +1397,20 @@ static void libxmlEndElementNS( ...@@ -1382,15 +1397,20 @@ static void libxmlEndElementNS(
return; return;
} }
if(This->vbInterface) if (is_namespaces_enabled(This->saxreader))
local = element->local;
else
uri = local = NULL;
if (This->vbInterface)
hr = IVBSAXContentHandler_endElement( hr = IVBSAXContentHandler_endElement(
This->saxreader->vbcontentHandler, This->saxreader->vbcontentHandler,
&uri, &element->local, &element->qname); &uri, &local, &element->qname);
else else
hr = ISAXContentHandler_endElement( hr = ISAXContentHandler_endElement(
This->saxreader->contentHandler, This->saxreader->contentHandler,
uri, SysStringLen(uri), uri, SysStringLen(uri),
element->local, SysStringLen(element->local), local, SysStringLen(local),
element->qname, SysStringLen(element->qname)); element->qname, SysStringLen(element->qname));
This->nb_attributes = 0; This->nb_attributes = 0;
...@@ -1402,18 +1422,21 @@ static void libxmlEndElementNS( ...@@ -1402,18 +1422,21 @@ static void libxmlEndElementNS(
return; return;
} }
i = -1; if (is_namespaces_enabled(This->saxreader))
while (iterate_endprefix_index(This, element, &i))
{ {
if(This->vbInterface) int i = -1;
hr = IVBSAXContentHandler_endPrefixMapping( while (iterate_endprefix_index(This, element, &i))
This->saxreader->vbcontentHandler, &element->ns[i].prefix); {
else if (This->vbInterface)
hr = ISAXContentHandler_endPrefixMapping( hr = IVBSAXContentHandler_endPrefixMapping(
This->saxreader->contentHandler, This->saxreader->vbcontentHandler, &element->ns[i].prefix);
element->ns[i].prefix, SysStringLen(element->ns[i].prefix)); else
hr = ISAXContentHandler_endPrefixMapping(
This->saxreader->contentHandler,
element->ns[i].prefix, SysStringLen(element->ns[i].prefix));
if (sax_callback_failed(This, hr)) break; if (sax_callback_failed(This, hr)) break;
}
} }
if (sax_callback_failed(This, hr)) if (sax_callback_failed(This, hr))
...@@ -2820,7 +2843,7 @@ static HRESULT WINAPI saxxmlreader_putFeature( ...@@ -2820,7 +2843,7 @@ static HRESULT WINAPI saxxmlreader_putFeature(
/* accepted cases */ /* accepted cases */
if ((feature == ExternalGeneralEntities && value == VARIANT_FALSE) || if ((feature == ExternalGeneralEntities && value == VARIANT_FALSE) ||
(feature == ExternalParameterEntities && value == VARIANT_FALSE) || (feature == ExternalParameterEntities && value == VARIANT_FALSE) ||
(feature == Namespaces && value == VARIANT_TRUE )) feature == Namespaces)
{ {
return set_feature_value(This, feature, value); return set_feature_value(This, feature, value);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment