webservices: Treat empty prefixes as NULL.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bae46fb214
commit
a1c9801dc6
|
@ -395,7 +395,7 @@ static void test_WsWriteStartElement(void)
|
|||
HRESULT hr;
|
||||
WS_XML_WRITER *writer;
|
||||
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"};
|
||||
WS_XML_STRING localname = {1, (BYTE *)"a"}, localname2 = {1, (BYTE *)"b"}, empty = {0, NULL};
|
||||
|
||||
hr = WsCreateWriter( NULL, 0, &writer, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
@ -469,6 +469,17 @@ static void test_WsWriteStartElement(void)
|
|||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output( writer, "<p:a xmlns:p=\"ns\"><b xmlns=\"ns2\"/></p:a>", __LINE__ );
|
||||
|
||||
hr = set_output( writer );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
hr = WsWriteStartElement( writer, &empty, &localname, &empty, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
hr = WsWriteEndStartElement( writer, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
hr = WsWriteEndElement( writer, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output( writer, "<a></a>", __LINE__ );
|
||||
|
||||
WsFreeWriter( writer );
|
||||
}
|
||||
|
||||
|
@ -476,7 +487,8 @@ static void test_WsWriteStartAttribute(void)
|
|||
{
|
||||
HRESULT hr;
|
||||
WS_XML_WRITER *writer;
|
||||
WS_XML_STRING prefix = {1, (BYTE *)"p"}, localname = {3, (BYTE *)"str"}, ns = {2, (BYTE *)"ns"};
|
||||
WS_XML_STRING prefix = {1, (BYTE *)"p"}, localname = {3, (BYTE *)"str"};
|
||||
WS_XML_STRING localname2 = {3, (BYTE *)"len"}, ns = {2, (BYTE *)"ns"}, empty = {0, NULL};
|
||||
WS_XML_UTF8_TEXT text = {{WS_XML_TEXT_TYPE_UTF8}};
|
||||
|
||||
hr = WsCreateWriter( NULL, 0, &writer, NULL );
|
||||
|
@ -492,9 +504,7 @@ static void test_WsWriteStartAttribute(void)
|
|||
ok( hr == E_INVALIDARG, "got %08x\n", hr );
|
||||
|
||||
/* WsWriteStartAttribute doesn't output anything */
|
||||
localname.length = 3;
|
||||
localname.bytes = (BYTE *)"len";
|
||||
hr = WsWriteStartAttribute( writer, &prefix, &localname, &ns, FALSE, NULL );
|
||||
hr = WsWriteStartAttribute( writer, &prefix, &localname2, &ns, FALSE, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output( writer, "", __LINE__ );
|
||||
|
||||
|
@ -513,6 +523,21 @@ static void test_WsWriteStartAttribute(void)
|
|||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output( writer, "<p:str p:len=\"0\" xmlns:p=\"ns\"/>", __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 );
|
||||
|
||||
hr = WsWriteStartAttribute( writer, &empty, &localname2, &empty, FALSE, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
hr = WsWriteEndAttribute( writer, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
hr = WsWriteEndElement( writer, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
check_output( writer, "<p:str len=\"\" xmlns:p=\"ns\"/>", __LINE__ );
|
||||
|
||||
WsFreeWriter( writer );
|
||||
}
|
||||
|
||||
|
|
|
@ -518,12 +518,12 @@ static HRESULT write_attribute( struct writer *writer, WS_XML_ATTRIBUTE *attr )
|
|||
/* ' prefix:attr="value"' */
|
||||
|
||||
size = attr->localName->length + 4 /* ' =""' */;
|
||||
if (prefix) size += prefix->length + 1 /* ':' */;
|
||||
if (prefix && prefix->length) size += prefix->length + 1 /* ':' */;
|
||||
if (text) size += text->value.length;
|
||||
if ((hr = write_grow_buffer( writer, size )) != S_OK) return hr;
|
||||
|
||||
write_char( writer, ' ' );
|
||||
if (prefix)
|
||||
if (prefix && prefix->length)
|
||||
{
|
||||
write_bytes( writer, prefix->bytes, prefix->length );
|
||||
write_char( writer, ':' );
|
||||
|
@ -734,11 +734,11 @@ static HRESULT write_startelement( struct writer *writer )
|
|||
/* '<prefix:localname prefix:attr="value"... xmlns:prefix="ns"'... */
|
||||
|
||||
size = elem->localName->length + 1 /* '<' */;
|
||||
if (elem->prefix) size += elem->prefix->length + 1 /* ':' */;
|
||||
if (elem->prefix && elem->prefix->length) size += elem->prefix->length + 1 /* ':' */;
|
||||
if ((hr = write_grow_buffer( writer, size )) != S_OK) return hr;
|
||||
|
||||
write_char( writer, '<' );
|
||||
if (elem->prefix)
|
||||
if (elem->prefix && elem->prefix->length)
|
||||
{
|
||||
write_bytes( writer, elem->prefix->bytes, elem->prefix->length );
|
||||
write_char( writer, ':' );
|
||||
|
@ -796,12 +796,12 @@ static HRESULT write_endelement( struct writer *writer, const WS_XML_ELEMENT_NOD
|
|||
/* '</prefix:localname>' */
|
||||
|
||||
size = elem->localName->length + 3 /* '</>' */;
|
||||
if (elem->prefix) size += elem->prefix->length + 1 /* ':' */;
|
||||
if (elem->prefix && elem->prefix->length) size += elem->prefix->length + 1 /* ':' */;
|
||||
if ((hr = write_grow_buffer( writer, size )) != S_OK) return hr;
|
||||
|
||||
write_char( writer, '<' );
|
||||
write_char( writer, '/' );
|
||||
if (elem->prefix)
|
||||
if (elem->prefix && elem->prefix->length)
|
||||
{
|
||||
write_bytes( writer, elem->prefix->bytes, elem->prefix->length );
|
||||
write_char( writer, ':' );
|
||||
|
|
Loading…
Reference in New Issue