[PATCH v4 3/3] msxml3: When saving XML use encoding specified in the processing instruction.

Dmitry Timoshkov dmitry at baikal.ru
Thu May 27 02:56:59 CDT 2021


Nikolay Sivov <nsivov at codeweavers.com> wrote:

> On 5/20/21 9:50 AM, Dmitry Timoshkov wrote:
> > +static char *xmldoc_encoding(IXMLDOMDocument3 *doc)
> > +{
> > +    HRESULT hr;
> > +    IXMLDOMNode *node;
> > +    char *encoding = NULL;
> > +
> > +    hr = IXMLDOMDocument3_get_firstChild(doc, &node);
> > +    if (hr == S_OK)
> > +    {
> > +        DOMNodeType type;
> > +
> > +        hr = IXMLDOMNode_get_nodeType(node, &type);
> > +        if (hr == S_OK && type == NODE_PROCESSING_INSTRUCTION)
> > +        {
> > +            IXMLDOMProcessingInstruction *pi;
> > +            IXMLDOMNode *item;
> > +            IXMLDOMNamedNodeMap *node_map;
> > +
> > +            hr = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMProcessingInstruction, (void **)&pi);
> > +            if (hr == S_OK)
> > +            {
> > +                hr = IXMLDOMNode_get_attributes(node, &node_map);
> > +                if (hr == S_OK)
> > +                {
> > +                    static const WCHAR encodingW[] = {'e','n','c','o','d','i','n','g',0};
> > +                    BSTR bstr;
> > +
> > +                    bstr = SysAllocString(encodingW);
> > +                    hr = IXMLDOMNamedNodeMap_getNamedItem(node_map, bstr, &item);
> > +                    SysFreeString(bstr);
> > +                    if (hr == S_OK)
> > +                    {
> > +                        VARIANT var;
> > +
> > +                        hr = IXMLDOMNode_get_nodeValue(item, &var);
> > +                        if (hr == S_OK)
> > +                        {
> > +                            if (V_VT(&var) == VT_BSTR)
> > +                                encoding = (char *)xmlchar_from_wchar(V_BSTR(&var));
> > +
> > +                            VariantClear(&var);
> > +                        }
> > +                    }
> > +
> > +                    IXMLDOMNamedNodeMap_Release(node_map);
> > +                }
> > +
> > +                IXMLDOMProcessingInstruction_Release(pi);
> > +            }
> > +        }
> > +
> > +        IXMLDOMNode_Release(node);
> > +    }
> > +
> > +    return encoding;
> > +}
> Why all this complexity? Isn't it the same as reading current "encoding"
> value from artificially linked PI node?

Do you mean checking the first document child node type for XML_PI_NODE
and directly calling xmlGetProp("encoding")? Or something else?

-- 
Dmitry.



More information about the wine-devel mailing list