HRESULT dt_validate(XDR_DT dt, xmlChar const* content) { xmlDocPtr tmp_doc; xmlNodePtr node; xmlNsPtr ns; HRESULT hr; TRACE("(dt:%s, %s)\n", debugstr_dt(dt), debugstr_a((char const*)content)); if (!datatypes_schema) { xmlSchemaParserCtxtPtr spctx; assert(datatypes_src != NULL); spctx = xmlSchemaNewMemParserCtxt((char const*)datatypes_src, datatypes_len); datatypes_schema = Schema_parse(spctx); xmlSchemaFreeParserCtxt(spctx); } switch (dt) { case DT_INVALID: return E_FAIL; case DT_BIN_BASE64: case DT_BIN_HEX: case DT_BOOLEAN: case DT_CHAR: case DT_DATE: case DT_DATE_TZ: case DT_DATETIME: case DT_DATETIME_TZ: case DT_FIXED_14_4: case DT_FLOAT: case DT_I1: case DT_I2: case DT_I4: case DT_I8: case DT_INT: case DT_NMTOKEN: case DT_NMTOKENS: case DT_NUMBER: case DT_R4: case DT_R8: case DT_STRING: case DT_TIME: case DT_TIME_TZ: case DT_UI1: case DT_UI2: case DT_UI4: case DT_UI8: case DT_URI: case DT_UUID: if (!datatypes_schema) { ERR("failed to load schema for urn:schemas-microsoft-com:datatypes, " "you're probably using an old version of libxml2: " LIBXML_DOTTED_VERSION "\n"); /* Hopefully they don't need much in the way of XDR datatypes support... */ return S_OK; } if (content && xmlStrlen(content)) { tmp_doc = xmlNewDoc(NULL); node = xmlNewChild((xmlNodePtr)tmp_doc, NULL, dt_to_str(dt), content); ns = xmlNewNs(node, DT_nsURI, BAD_CAST "dt"); xmlSetNs(node, ns); xmlDocSetRootElement(tmp_doc, node); hr = Schema_validate_tree(datatypes_schema, (xmlNodePtr)tmp_doc); xmlFreeDoc(tmp_doc); } else { /* probably the node is being created manually and has no content yet */ hr = S_OK; } return hr; default: FIXME("need to handle dt:%s\n", debugstr_dt(dt)); return S_OK; } }
HRESULT dt_validate(XDR_DT dt, xmlChar const* content) { xmlDocPtr tmp_doc; xmlNodePtr node; xmlNsPtr ns; HRESULT hr; TRACE("(dt:%s, %s)\n", dt_to_str(dt), wine_dbgstr_a((char const*)content)); if (!datatypes_schema) { xmlSchemaParserCtxtPtr spctx; assert(datatypes_src != NULL); spctx = xmlSchemaNewMemParserCtxt((char const*)datatypes_src, datatypes_len); datatypes_schema = Schema_parse(spctx); xmlSchemaFreeParserCtxt(spctx); } switch (dt) { case DT_INVALID: return E_FAIL; case DT_BIN_BASE64: case DT_BIN_HEX: case DT_BOOLEAN: case DT_CHAR: case DT_DATE: case DT_DATE_TZ: case DT_DATETIME: case DT_DATETIME_TZ: case DT_FIXED_14_4: case DT_FLOAT: case DT_I1: case DT_I2: case DT_I4: case DT_I8: case DT_INT: case DT_NMTOKEN: case DT_NMTOKENS: case DT_NUMBER: case DT_R4: case DT_R8: case DT_STRING: case DT_TIME: case DT_TIME_TZ: case DT_UI1: case DT_UI2: case DT_UI4: case DT_UI8: case DT_URI: case DT_UUID: assert(datatypes_schema != NULL); if (content && xmlStrlen(content)) { tmp_doc = xmlNewDoc(NULL); node = xmlNewChild((xmlNodePtr)tmp_doc, NULL, dt_to_str(dt), content); ns = xmlNewNs(node, DT_nsURI, BAD_CAST "dt"); xmlSetNs(node, ns); xmlDocSetRootElement(tmp_doc, node); hr = Schema_validate_tree(datatypes_schema, (xmlNodePtr)tmp_doc); xmlFreeDoc(tmp_doc); } else { /* probably the node is being created manually and has no content yet */ hr = S_OK; } return hr; default: FIXME("need to handle dt:%s\n", dt_to_str(dt)); return S_OK; } }