ReactOS 0.4.16-dev-2135-g2f5a67f
schema.c File Reference
#include <stdio.h>
#include <assert.h>
#include "ole2.h"
#include "msxml2.h"
#include "wine/test.h"
Include dependency graph for schema.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

static BSTR _bstr_ (const WCHAR *str)
 
static void free_bstrs (void)
 
static VARIANT _variantdoc_ (void *doc)
 
static IXMLDOMDocument2create_document (void)
 
static voidcreate_cache (REFIID riid)
 
static HRESULT validate_regex_document (IXMLDOMDocument2 *doc, IXMLDOMDocument2 *schema, IXMLDOMSchemaCollection *cache, const WCHAR *regex, const WCHAR *input)
 
static void test_regex (void)
 
static void test_get (void)
 
static void test_remove (void)
 
static void test_validate_on_load (void)
 
static void test_collection_content (void)
 
 START_TEST (schema)
 

Variables

static const WCHAR xsd_schema1_uri [] = L"x-schema:test1.xsd"
 
static const WCHAR xsd_schema1_xml []
 
static const WCHAR xsd_schema2_uri [] = L"x-schema:test2.xsd"
 
static const WCHAR xsd_schema2_xml []
 
static const WCHAR xsd_schema3_uri [] = L"x-schema:test3.xsd"
 
static const WCHAR xsd_schema3_xml []
 
static const WCHAR xdr_schema1_uri [] = L"x-schema:test1.xdr"
 
static const WCHAR xdr_schema1_xml []
 
static const WCHAR xdr_schema2_uri [] = L"x-schema:test2.xdr"
 
static const WCHAR xdr_schema2_xml []
 
static BSTR alloced_bstrs [256]
 
static int alloced_bstrs_count
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 24 of file schema.c.

Function Documentation

◆ _bstr_()

static BSTR _bstr_ ( const WCHAR str)
static

Definition at line 110 of file schema.c.

111{
115}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define assert(_expr)
Definition: assert.h:32
static BSTR alloced_bstrs[256]
Definition: schema.c:376
static int alloced_bstrs_count
Definition: schema.c:377
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
const WCHAR * str

◆ _variantdoc_()

static VARIANT _variantdoc_ ( void doc)
static

Definition at line 125 of file schema.c.

126{
127 VARIANT v;
128 V_VT(&v) = VT_DISPATCH;
129 V_DISPATCH(&v) = (IDispatch*)doc;
130 return v;
131}
@ VT_DISPATCH
Definition: compat.h:2304
const GLdouble * v
Definition: gl.h:2040
#define V_VT(A)
Definition: oleauto.h:211
#define V_DISPATCH(A)
Definition: oleauto.h:239

◆ create_cache()

static void * create_cache ( REFIID  riid)
static

Definition at line 144 of file schema.c.

145{
146 void *obj = NULL;
147 HRESULT hr;
148
149 hr = CoCreateInstance(&CLSID_XMLSchemaCache40, NULL, CLSCTX_INPROC_SERVER, riid, &obj);
150 ok(hr == S_OK, "Failed to create a document object, hr %#lx.\n", hr);
151
152 return obj;
153}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
HRESULT hr
Definition: shlfolder.c:183

◆ create_document()

static IXMLDOMDocument2 * create_document ( void  )
static

Definition at line 133 of file schema.c.

134{
136 HRESULT hr;
137
138 hr = CoCreateInstance(&CLSID_DOMDocument40, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&obj);
139 ok(hr == S_OK, "Failed to create a document object, hr %#lx.\n", hr);
140
141 return obj;
142}

◆ free_bstrs()

static void free_bstrs ( void  )
static

Definition at line 117 of file schema.c.

118{
119 int i;
120 for (i = 0; i < alloced_bstrs_count; i++)
123}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271

◆ START_TEST()

START_TEST ( schema  )

Definition at line 466 of file schema.c.

467{
468 IUnknown *obj;
469 HRESULT hr;
470
472 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
473
474 hr = CoCreateInstance(&CLSID_DOMDocument40, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument2, (void **)&obj);
475 if (FAILED(hr))
476 {
477 win_skip("DOMDocument40 is not supported.\n");
479 return;
480 }
481 IUnknown_Release(obj);
482
483 test_regex();
484 test_get();
485 test_remove();
488
490}
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define FAILED(hr)
Definition: intsafe.h:51
#define win_skip
Definition: minitest.h:67
static void test_collection_content(void)
Definition: schema.c:932
static void test_regex(void)
Definition: schema.c:239
static void test_remove(void)
Definition: schema.c:315
static void test_get(void)
Definition: schema.c:297
static void test_validate_on_load(void)
Definition: schema.c:368

◆ test_collection_content()

static void test_collection_content ( void  )
static

Definition at line 387 of file schema.c.

388{
389 IXMLDOMDocument2 *schema1, *schema2, *schema3, *schema4, *schema5;
391 BSTR content[5] = { 0 };
393 LONG length;
394 HRESULT hr;
395 BSTR bstr;
396 int i, j;
397
398 schema1 = create_document();
399 schema2 = create_document();
400 schema3 = create_document();
401 schema4 = create_document();
402 schema5 = create_document();
403 cache = create_cache(&IID_IXMLDOMSchemaCollection);
404
405 hr = IXMLDOMDocument2_loadXML(schema1, _bstr_(xdr_schema1_xml), &b);
406 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
407 ok(b == VARIANT_TRUE, "failed to load XML\n");
408 hr = IXMLDOMDocument2_loadXML(schema2, _bstr_(xdr_schema2_xml), &b);
409 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
410 ok(b == VARIANT_TRUE, "failed to load XML\n");
411 hr = IXMLDOMDocument2_loadXML(schema3, _bstr_(xsd_schema1_xml), &b);
412 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
413 ok(b == VARIANT_TRUE, "failed to load XML\n");
414 hr = IXMLDOMDocument2_loadXML(schema4, _bstr_(xsd_schema2_xml), &b);
415 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
416 ok(b == VARIANT_TRUE, "failed to load XML\n");
417 hr = IXMLDOMDocument2_loadXML(schema5, _bstr_(xsd_schema3_xml), &b);
418 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
419 ok(b == VARIANT_TRUE, "failed to load XML\n");
420
421 /* combining XDR and XSD schemas in the same cache is fine */
422 hr = IXMLDOMSchemaCollection_add(cache, _bstr_(xdr_schema1_uri), _variantdoc_(schema1));
423 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
424 hr = IXMLDOMSchemaCollection_add(cache, _bstr_(xdr_schema2_uri), _variantdoc_(schema2));
425 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
426 hr = IXMLDOMSchemaCollection_add(cache, _bstr_(xsd_schema1_uri), _variantdoc_(schema3));
427 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
428 hr = IXMLDOMSchemaCollection_add(cache, _bstr_(xsd_schema2_uri), _variantdoc_(schema4));
429 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
430 hr = IXMLDOMSchemaCollection_add(cache, _bstr_(xsd_schema3_uri), _variantdoc_(schema5));
431 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
432
433 length = -1;
434 hr = IXMLDOMSchemaCollection_get_length(cache, &length);
435 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
436 ok(length == 5, "Unexpected length %ld.\n", length);
437
438 for (i = 0; i < 5; ++i)
439 {
440 bstr = NULL;
441 hr = IXMLDOMSchemaCollection_get_namespaceURI(cache, i, &bstr);
442 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
443 ok(bstr != NULL && *bstr, "expected non-empty string\n");
444
445 for (j = 0; j < i; ++j)
446 ok(wcscmp(content[j], bstr), "got duplicate entry\n");
447 content[i] = bstr;
448 }
449
450 for (i = 0; i < 5; ++i)
451 {
453 content[i] = NULL;
454 }
455
456 IXMLDOMDocument2_Release(schema1);
457 IXMLDOMDocument2_Release(schema2);
458 IXMLDOMDocument2_Release(schema3);
459 IXMLDOMDocument2_Release(schema4);
460 IXMLDOMDocument2_Release(schema5);
461
462 IXMLDOMSchemaCollection_Release(cache);
463 free_bstrs();
464}
content
Definition: atl_ax.c:994
OLECHAR * BSTR
Definition: compat.h:2293
short VARIANT_BOOL
Definition: compat.h:2290
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1972
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define b
Definition: ke_i.h:79
#define create_cache(iid)
Definition: schema.c:420
static const WCHAR xdr_schema1_xml[]
Definition: schema.c:38
static const WCHAR xdr_schema2_uri[]
Definition: schema.c:55
static const WCHAR xdr_schema2_xml[]
Definition: schema.c:56
static void free_bstrs(void)
Definition: schema.c:386
static BSTR _bstr_(const WCHAR *str)
Definition: schema.c:379
#define create_document(iid)
Definition: schema.c:416
static const WCHAR xdr_schema1_uri[]
Definition: schema.c:37
static VARIANT _variantdoc_(void *doc)
Definition: schema.c:394
static const WCHAR xsd_schema1_uri[]
Definition: schema.c:87
static const WCHAR xsd_schema3_xml[]
Definition: schema.c:60
static const WCHAR xsd_schema2_xml[]
Definition: schema.c:46
static const WCHAR xsd_schema1_xml[]
Definition: schema.c:32
static const WCHAR xsd_schema2_uri[]
Definition: schema.c:45
static const WCHAR xsd_schema3_uri[]
Definition: schema.c:59
long LONG
Definition: pedump.c:60
Definition: cache.c:49

◆ test_get()

static void test_get ( void  )
static

Definition at line 297 of file schema.c.

298{
301 HRESULT hr;
302
303 cache = create_cache(&IID_IXMLDOMSchemaCollection2);
304
305 hr = IXMLDOMSchemaCollection2_get(cache, NULL, NULL);
306 ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
307
308 hr = IXMLDOMSchemaCollection2_get(cache, _bstr_(L"uri"), &node);
309 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
310
311 IXMLDOMSchemaCollection2_Release(cache);
312 free_bstrs();
313}
#define L(x)
Definition: resources.c:13
Definition: dlist.c:348
#define E_POINTER
Definition: winerror.h:3480

Referenced by START_TEST().

◆ test_regex()

static void test_regex ( void  )
static

Definition at line 239 of file schema.c.

240{
241 static const struct regex_test
242 {
243 const WCHAR *regex;
244 const WCHAR *input;
245 }
246 tests[] =
247 {
248 { L"\\!", L"!" },
249 { L"\\\"", L"\"" },
250 { L"\\#", L"#" },
251 { L"\\$", L"$" },
252 { L"\\%", L"%" },
253 { L"\\,", L"," },
254 { L"\\/", L"/" },
255 { L"\\:", L":" },
256 { L"\\;", L";" },
257 { L"\\=", L"=" },
258 { L"\\>", L">" },
259 { L"\\@", L"@" },
260 { L"\\`", L"`" },
261 { L"\\~", L"~" },
262 { L"\\uCAFE", L"\xCAFE" },
263 /* non-BMP character in surrogate pairs: */
264 { L"\\uD83D\\uDE00", L"\xD83D\xDE00" },
265 /* "x{,2}" is non-standard and only works on libxml2 <= v2.9.10 */
266 { L"x{0,2}", L"x" }
267 };
268 unsigned int i;
269
270 for (i = 0; i < ARRAY_SIZE(tests); ++i)
271 {
272 const struct regex_test *test = &tests[i];
275 HRESULT hr;
276
277 winetest_push_context("Test %s", wine_dbgstr_w(test->regex));
278
279 doc = create_document();
281 cache = create_cache(&IID_IXMLDOMSchemaCollection);
282
283 hr = validate_regex_document(doc, schema, cache, tests->regex, tests->input);
284 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
285
286 if (doc)
287 IXMLDOMDocument2_Release(doc);
288 if (schema)
289 IXMLDOMDocument2_Release(schema);
290 if (cache)
291 IXMLDOMSchemaCollection_Release(cache);
292
294 }
295}
GLenum GLenum GLenum input
Definition: glext.h:9031
#define wine_dbgstr_w
Definition: kernel32.h:34
const WCHAR * schema
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
static struct test_info tests[]
static HRESULT validate_regex_document(IXMLDOMDocument2 *doc, IXMLDOMDocument2 *schema, IXMLDOMSchemaCollection *cache, const WCHAR *regex, const WCHAR *input)
Definition: schema.c:155
#define test
Definition: rosglue.h:37
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_remove()

static void test_remove ( void  )
static

Definition at line 315 of file schema.c.

316{
318 IXMLDOMDocument2 *doc;
320 HRESULT hr;
321 VARIANT v;
322 LONG len;
323
324 /* ::remove() works for version 4 */
325 cache = create_cache(&IID_IXMLDOMSchemaCollection2);
326
327 doc = create_document();
328 ok(doc != NULL, "got %p\n", doc);
329
330 hr = IXMLDOMDocument2_loadXML(doc, _bstr_(xsd_schema1_xml), &b);
331 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
332
333 V_VT(&v) = VT_DISPATCH;
334 V_DISPATCH(&v) = (IDispatch*)doc;
335 hr = IXMLDOMSchemaCollection2_add(cache, _bstr_(xsd_schema1_uri), v);
336 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
337
338 len = -1;
339 hr = IXMLDOMSchemaCollection2_get_length(cache, &len);
340 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
341 ok(len == 1, "Unexpected length %ld.\n", len);
342
343 hr = IXMLDOMSchemaCollection2_remove(cache, NULL);
344 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
345
346 hr = IXMLDOMSchemaCollection2_remove(cache, _bstr_(L"invaliduri"));
347 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
348
349 len = -1;
350 hr = IXMLDOMSchemaCollection2_get_length(cache, &len);
351 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
352 ok(len == 1, "Unexpected length %ld.\n", len);
353
354 hr = IXMLDOMSchemaCollection2_remove(cache, _bstr_(xsd_schema1_uri));
355 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
356
357 len = -1;
358 hr = IXMLDOMSchemaCollection2_get_length(cache, &len);
359 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
360 ok(len == 0, "Unexpected length %ld.\n", len);
361
362 IXMLDOMDocument2_Release(doc);
363 IXMLDOMSchemaCollection2_Release(cache);
364
365 free_bstrs();
366}
GLenum GLsizei len
Definition: glext.h:6722

Referenced by START_TEST().

◆ test_validate_on_load()

static void test_validate_on_load ( void  )
static

Definition at line 368 of file schema.c.

369{
372 HRESULT hr;
373
374 cache = create_cache(&IID_IXMLDOMSchemaCollection2);
375
376 hr = IXMLDOMSchemaCollection2_get_validateOnLoad(cache, NULL);
377 ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
378
379 b = VARIANT_FALSE;
380 hr = IXMLDOMSchemaCollection2_get_validateOnLoad(cache, &b);
381 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
382 ok(b == VARIANT_TRUE, "got %d\n", b);
383
384 IXMLDOMSchemaCollection2_Release(cache);
385}

Referenced by START_TEST().

◆ validate_regex_document()

static HRESULT validate_regex_document ( IXMLDOMDocument2 doc,
IXMLDOMDocument2 schema,
IXMLDOMSchemaCollection cache,
const WCHAR regex,
const WCHAR input 
)
static

Definition at line 155 of file schema.c.

157{
158 static const WCHAR regex_doc[] =
159L""
160"<?xml version='1.0'?>"
161"<root xmlns='urn:test'>%s</root>";
162
163 static const WCHAR regex_schema[] =
164L"<?xml version='1.0'?>"
165"<schema xmlns='http://www.w3.org/2001/XMLSchema'"
166" targetNamespace='urn:test'>"
167" <element name='root'>"
168" <simpleType>"
169" <restriction base='string'>"
170" <pattern value='%s'/>"
171" </restriction>"
172" </simpleType>"
173" </element>"
174"</schema>";
175
176 WCHAR buffer[1024];
178 BSTR namespace, bstr;
180 HRESULT hr;
181 VARIANT v;
182
183 VariantInit(&v);
184
185 swprintf(buffer, ARRAY_SIZE(buffer), regex_doc, input);
186 bstr = SysAllocString(buffer);
187 hr = IXMLDOMDocument2_loadXML(doc, bstr, &b);
188 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
189 ok(b == VARIANT_TRUE, "failed to load XML\n");
190 SysFreeString(bstr);
191
192 swprintf(buffer, ARRAY_SIZE(buffer), regex_schema, regex);
193 bstr = SysAllocString(buffer);
194 hr = IXMLDOMDocument2_loadXML(schema, bstr, &b);
195 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
196 ok(b == VARIANT_TRUE, "failed to load XML\n");
197 SysFreeString(bstr);
198
199 /* add the schema to the cache */
200 V_VT(&v) = VT_DISPATCH;
201 V_DISPATCH(&v) = NULL;
202 hr = IXMLDOMDocument2_QueryInterface(schema, &IID_IDispatch, (void**)&V_DISPATCH(&v));
203 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
204 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n");
205 namespace = SysAllocString(L"urn:test");
206 hr = IXMLDOMSchemaCollection_add(cache, namespace, v);
207 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
208 SysFreeString(namespace);
209 VariantClear(&v);
210/*
211 if (FAILED(hr))
212 return hr;
213*/
214 /* associate the cache to the doc */
215 V_VT(&v) = VT_DISPATCH;
216 V_DISPATCH(&v) = NULL;
217 hr = IXMLDOMSchemaCollection_QueryInterface(cache, &IID_IDispatch, (void**)&V_DISPATCH(&v));
218 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
219 ok(V_DISPATCH(&v) != NULL, "failed to get IDispatch interface\n");
220 hr = IXMLDOMDocument2_putref_schemas(doc, v);
221 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
222 VariantClear(&v);
223
224 /* validate the doc
225 * only declared elements in the declared order
226 * this is fine */
227 err = NULL;
228 bstr = NULL;
229 hr = IXMLDOMDocument2_validate(doc, &err);
230 ok(err != NULL, "domdoc_validate() should always set err\n");
231 if (IXMLDOMParseError_get_reason(err, &bstr) != S_FALSE)
232 trace("got error: %s\n", wine_dbgstr_w(bstr));
233 SysFreeString(bstr);
234 IXMLDOMParseError_Release(err);
235
236 return hr;
237}
#define trace
Definition: atltest.h:70
#define swprintf
Definition: precomp.h:40
GLuint buffer
Definition: glext.h:5915
const GUID IID_IDispatch
#define err(...)
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568
#define S_FALSE
Definition: winerror.h:3451

Referenced by test_regex().

Variable Documentation

◆ alloced_bstrs

BSTR alloced_bstrs[256]
static

Definition at line 107 of file schema.c.

◆ alloced_bstrs_count

int alloced_bstrs_count
static

Definition at line 108 of file schema.c.

◆ xdr_schema1_uri

const WCHAR xdr_schema1_uri[] = L"x-schema:test1.xdr"
static

Definition at line 73 of file schema.c.

◆ xdr_schema1_xml

const WCHAR xdr_schema1_xml[]
static
Initial value:
=
L"<?xml version='1.0'?>"
"<Schema xmlns='urn:schemas-microsoft-com:xml-data'"
" xmlns:dt='urn:schemas-microsoft-com:datatypes'"
" name='test1.xdr'>"
" <ElementType name='x' dt:type='boolean'/>"
" <ElementType name='y'>"
" <datatype dt:type='int'/>"
" </ElementType>"
" <ElementType name='z'/>"
" <ElementType name='root' content='eltOnly' model='open' order='seq'>"
" <element type='x'/>"
" <element type='y'/>"
" <element type='z'/>"
" </ElementType>"
"</Schema>"

Definition at line 74 of file schema.c.

◆ xdr_schema2_uri

const WCHAR xdr_schema2_uri[] = L"x-schema:test2.xdr"
static

Definition at line 91 of file schema.c.

◆ xdr_schema2_xml

const WCHAR xdr_schema2_xml[]
static
Initial value:
=
L"<?xml version='1.0'?>"
"<Schema xmlns='urn:schemas-microsoft-com:xml-data'"
" xmlns:dt='urn:schemas-microsoft-com:datatypes'"
" name='test2.xdr'>"
" <ElementType name='x' dt:type='bin.base64'/>"
" <ElementType name='y' dt:type='uuid'/>"
" <ElementType name='z'/>"
" <ElementType name='root' content='eltOnly' model='closed' order='one'>"
" <element type='x'/>"
" <element type='y'/>"
" <element type='z'/>"
" </ElementType>"
"</Schema>"

Definition at line 92 of file schema.c.

◆ xsd_schema1_uri

const WCHAR xsd_schema1_uri[] = L"x-schema:test1.xsd"
static

Definition at line 31 of file schema.c.

◆ xsd_schema1_xml

const WCHAR xsd_schema1_xml[]
static
Initial value:
=
L"<?xml version='1.0'?>"
"<schema xmlns='http://www.w3.org/2001/XMLSchema'"
" targetNamespace='x-schema:test1.xsd'>"
" <element name='root'>"
" <complexType>"
" <sequence maxOccurs='unbounded'>"
" <any/>"
" </sequence>"
" </complexType>"
" </element>"
"</schema>"

Definition at line 32 of file schema.c.

Referenced by test_collection_content(), and test_remove().

◆ xsd_schema2_uri

const WCHAR xsd_schema2_uri[] = L"x-schema:test2.xsd"
static

Definition at line 45 of file schema.c.

Referenced by test_collection_content().

◆ xsd_schema2_xml

const WCHAR xsd_schema2_xml[]
static
Initial value:
=
L"<?xml version='1.0'?>"
"<schema xmlns='http://www.w3.org/2001/XMLSchema'"
" targetNamespace='x-schema:test2.xsd'>"
" <element name='root'>"
" <complexType>"
" <sequence maxOccurs='unbounded'>"
" <any/>"
" </sequence>"
" </complexType>"
" </element>"
"</schema>"

Definition at line 46 of file schema.c.

Referenced by test_collection_content().

◆ xsd_schema3_uri

const WCHAR xsd_schema3_uri[] = L"x-schema:test3.xsd"
static

Definition at line 59 of file schema.c.

Referenced by test_collection_content().

◆ xsd_schema3_xml

const WCHAR xsd_schema3_xml[]
static
Initial value:
=
L"<?xml version='1.0'?>"
"<schema xmlns='http://www.w3.org/2001/XMLSchema'"
" targetNamespace='x-schema:test3.xsd'>"
" <element name='root'>"
" <complexType>"
" <sequence maxOccurs='unbounded'>"
" <any/>"
" </sequence>"
" </complexType>"
" </element>"
"</schema>"

Definition at line 60 of file schema.c.

Referenced by test_collection_content().