Hans Leidekker : webservices: Inherit the prefix only if parent and child namespaces match.
Module: wine Branch: master Commit: d921526312e7f2da54c53a8d4f91ba330db7e761 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d921526312e7f2da54c53a8d4f... Author: Hans Leidekker <hans(a)codeweavers.com> Date: Fri Jul 8 10:20:31 2016 +0200 webservices: Inherit the prefix only if parent and child namespaces match. Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/webservices/tests/writer.c | 29 ++++++++++++++++++++++++----- dlls/webservices/writer.c | 7 +++++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/dlls/webservices/tests/writer.c b/dlls/webservices/tests/writer.c index d230cdd..6be47b5 100644 --- a/dlls/webservices/tests/writer.c +++ b/dlls/webservices/tests/writer.c @@ -364,7 +364,7 @@ static void test_WsWriteStartElement(void) { HRESULT hr; WS_XML_WRITER *writer; - WS_XML_STRING prefix = {1, (BYTE *)"p"}, ns = {2, (BYTE *)"ns"}; + WS_XML_STRING prefix = {1, (BYTE *)"p"}, ns = {2, (BYTE *)"ns"}, ns2 = {3, (BYTE *)"ns2"}; WS_XML_STRING localname = {1, (BYTE *)"a"}, localname2 = {1, (BYTE *)"b"}; hr = WsCreateWriter( NULL, 0, &writer, NULL ) ; @@ -404,21 +404,40 @@ static void test_WsWriteStartElement(void) hr = set_output( writer ); ok( hr == S_OK, "got %08x\n", hr ); - hr = WsWriteStartElement( writer, NULL, &localname, &ns, NULL ); + hr = WsWriteStartElement( writer, &prefix, &localname, &ns, NULL ); ok( hr == S_OK, "got %08x\n", hr ); check_output( writer, "", __LINE__ ); hr = WsWriteStartElement( writer, NULL, &localname2, &ns, NULL ); ok( hr == S_OK, "got %08x\n", hr ); - check_output( writer, "<a xmlns=\"ns\">", __LINE__ ); + check_output( writer, "<p:a xmlns:p=\"ns\">", __LINE__ ); + + hr = WsWriteEndElement( writer, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + check_output( writer, "<p:a xmlns:p=\"ns\"><p:b/>", __LINE__ ); + + hr = WsWriteEndElement( writer, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + check_output( writer, "<p:a xmlns:p=\"ns\"><p:b/></p:a>", __LINE__ ); + + hr = set_output( writer ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsWriteStartElement( writer, &prefix, &localname, &ns, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + check_output( writer, "", __LINE__ ); + + hr = WsWriteStartElement( writer, NULL, &localname2, &ns2, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + check_output( writer, "<p:a xmlns:p=\"ns\">", __LINE__ ); hr = WsWriteEndElement( writer, NULL ); ok( hr == S_OK, "got %08x\n", hr ); - check_output( writer, "<a xmlns=\"ns\"><b/>", __LINE__ ); + check_output( writer, "<p:a xmlns:p=\"ns\"><b xmlns=\"ns2\"/>", __LINE__ ); hr = WsWriteEndElement( writer, NULL ); ok( hr == S_OK, "got %08x\n", hr ); - check_output( writer, "<a xmlns=\"ns\"><b/></a>", __LINE__ ); + check_output( writer, "<p:a xmlns:p=\"ns\"><b xmlns=\"ns2\"/></p:a>", __LINE__ ); WsFreeWriter( writer ); } diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c index 48c7382..f8512dc 100644 --- a/dlls/webservices/writer.c +++ b/dlls/webservices/writer.c @@ -929,8 +929,11 @@ static HRESULT write_add_element_node( struct writer *writer, const WS_XML_STRIN if (!(parent = find_parent( writer->current ))) return WS_E_INVALID_FORMAT; - if (!prefix && node_type( writer->current ) == WS_XML_NODE_TYPE_ELEMENT) - prefix = writer->current->hdr.prefix; + if (!prefix && node_type( parent ) == WS_XML_NODE_TYPE_ELEMENT) + { + elem = &parent->hdr; + if (WsXmlStringEquals( ns, elem->ns, NULL ) == S_OK) prefix = elem->prefix; + } if (!(node = alloc_node( WS_XML_NODE_TYPE_ELEMENT ))) return E_OUTOFMEMORY; elem = &node->hdr;
participants (1)
-
Alexandre Julliard