Commit d9215263 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

webservices: Inherit the prefix only if parent and child namespaces match.

parent df4046a3
......@@ -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 );
}
......
......@@ -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;
......
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