webservices: Implement WsSkipNode.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2017-05-23 12:03:50 +02:00 committed by Alexandre Julliard
parent 7508702341
commit da030566e7
3 changed files with 107 additions and 1 deletions

View File

@ -1739,6 +1739,52 @@ HRESULT WINAPI WsReadNode( WS_XML_READER *handle, WS_ERROR *error )
return hr;
}
static HRESULT skip_node( struct reader *reader )
{
const struct node *parent;
HRESULT hr;
if (node_type( reader->current ) == WS_XML_NODE_TYPE_EOF) return WS_E_INVALID_OPERATION;
if (node_type( reader->current ) == WS_XML_NODE_TYPE_ELEMENT) parent = reader->current;
else parent = NULL;
for (;;)
{
if ((hr = read_node( reader ) != S_OK) || !parent) break;
if (node_type( reader->current ) != WS_XML_NODE_TYPE_END_ELEMENT) continue;
if (reader->current->parent == parent) return read_node( reader );
}
return hr;
}
/**************************************************************************
* WsSkipNode [webservices.@]
*/
HRESULT WINAPI WsSkipNode( WS_XML_READER *handle, WS_ERROR *error )
{
struct reader *reader = (struct reader *)handle;
HRESULT hr;
TRACE( "%p %p\n", handle, error );
if (error) FIXME( "ignoring error parameter\n" );
if (!reader) return E_INVALIDARG;
EnterCriticalSection( &reader->cs );
if (reader->magic != READER_MAGIC)
{
LeaveCriticalSection( &reader->cs );
return E_INVALIDARG;
}
hr = skip_node( reader );
LeaveCriticalSection( &reader->cs );
return hr;
}
/**************************************************************************
* WsReadStartElement [webservices.@]
*/

View File

@ -4403,6 +4403,65 @@ static void test_WsReadAttribute(void)
WsFreeReader( reader );
}
static void test_WsSkipNode(void)
{
const WS_XML_NODE *node;
WS_XML_READER *reader;
HRESULT hr;
hr = WsSkipNode( NULL, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
hr = WsCreateReader( NULL, 0, &reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsSkipNode( reader, NULL );
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
hr = set_input( reader, "<t><u></u></t>", sizeof("<t><u></u></t>") - 1 );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsGetReaderNode( reader, &node, NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( node->nodeType == WS_XML_NODE_TYPE_BOF, "got %u\n", node->nodeType );
/* BOF */
hr = WsSkipNode( reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsGetReaderNode( reader, &node, NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( node->nodeType == WS_XML_NODE_TYPE_ELEMENT, "got %u\n", node->nodeType );
/* element */
hr = WsSkipNode( reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsGetReaderNode( reader, &node, NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( node->nodeType == WS_XML_NODE_TYPE_EOF, "got %u\n", node->nodeType );
/* EOF */
hr = WsSkipNode( reader, NULL );
ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
hr = set_input( reader, "<!--comment--><t></t>", sizeof("<!--comment--><t></t>") - 1 );
ok( hr == S_OK, "got %08x\n", hr );
/* non-element */
hr = WsSkipNode( reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsGetReaderNode( reader, &node, NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( node->nodeType == WS_XML_NODE_TYPE_COMMENT, "got %u\n", node->nodeType );
hr = WsSkipNode( reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsGetReaderNode( reader, &node, NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( node->nodeType == WS_XML_NODE_TYPE_ELEMENT, "got %u\n", node->nodeType );
WsFreeReader( reader );
}
START_TEST(reader)
{
test_WsCreateError();
@ -4444,4 +4503,5 @@ START_TEST(reader)
test_WsReadCharsUtf8();
test_WsReadQualifiedName();
test_WsReadAttribute();
test_WsSkipNode();
}

View File

@ -159,7 +159,7 @@
@ stdcall WsSetReaderPosition(ptr ptr ptr)
@ stdcall WsSetWriterPosition(ptr ptr ptr)
@ stub WsShutdownSessionChannel
@ stub WsSkipNode
@ stdcall WsSkipNode(ptr ptr)
@ stub WsStartReaderCanonicalization
@ stub WsStartWriterCanonicalization
@ stub WsTrimXmlWhitespace