- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在根据 XSD 架构验证 XML 文件,就像它们在 MSXML 文档中所做的那样 example .我有以下代码:
XMLSchemaValidation updateInfoSchema;
updateInfoSchema.DoInitialization(L"schema.xsd");
HRESULT hr = CoInitialize(NULL);
if(SUCCEEDED(hr))
{
try
{
_bstr_t bstrOutput = updateInfoSchema.validateFile(L"valid.xml");
}
catch(_com_error &e)
{
updateInfoSchema.dump_com_error(e);
}
CoUninitialize();
}
// Macro that calls a COM method returning HRESULT value.
#define CHK_HR(stmt) do { hr=(stmt); if (FAILED(hr)) goto CleanUp; } while(0)
_bstr_t XMLSchemaValidation::validateFile(_bstr_t bstrFile)
{
// Declare and initialize variables
MSXML2::IXMLDOMSchemaCollectionPtr pXS;
MSXML2::IXMLDOMDocument2Ptr pXD;
MSXML2::IXMLDOMParseErrorPtr pErr;
_bstr_t bstrResult = L"";
HRESULT hr = S_OK;
// Create a schema cache and add xsd schema to it.
CHK_HR(pXS.CreateInstance(__uuidof(MSXML2::XMLSchemaCache60), NULL, CLSCTX_INPROC_SERVER));
CHK_HR(pXS->add(L"", (LPCSTR)(SchemaFileName.GetString())));
// Create a DOMDocument and set its properties.
CHK_HR(pXD.CreateInstance(__uuidof(MSXML2::DOMDocument60), NULL, CLSCTX_INPROC_SERVER));
// Assign the schema cache to the DOMDocument's schemas collection.
pXD->schemas = pXS.GetInterfacePtr();
// Load bstrFile into the DOM document.
pXD->async = VARIANT_FALSE;
pXD->validateOnParse = VARIANT_TRUE;
pXD->resolveExternals = VARIANT_TRUE;
if(pXD->load(bstrFile) != VARIANT_TRUE)
{
pErr = pXD->parseError;
bstrResult = _bstr_t(L"Validation failed on ") + bstrFile +
_bstr_t(L"\n=====================") +
_bstr_t(L"\nReason: ") + _bstr_t(pErr->Getreason()) +
_bstr_t(L"\nSource: ") + _bstr_t(pErr->GetsrcText()) +
_bstr_t(L"\nLine: ") + _bstr_t(pErr->Getline()) +
_bstr_t(L"\n");
}
else
{
bstrResult = _bstr_t(L"Validation succeeded for ") + bstrFile +
_bstr_t(L"\n======================\n") +
_bstr_t(pXD->xml) + _bstr_t(L"\n");
}
CleanUp:
return bstrResult;
}
XMLSchemaValidation::DoInitialization(CString XSDFileName)
将 XSD 模式文件名获取到 CString XMLSchemaValidation::SchemaFileName
中。
代码遵循 MSXML 示例中的代码,但我明白了
First-chance exception at 0x76f9c41f (KernelBase.dll) in CSW.exe: Microsoft C++ exception: _com_error at memory location 0x04a7f014..
当代码到达 CHK_HR(pXS->add(L"", (LPCSTR)(SchemaFileName.GetString())));
时。 hr
有 -2146697210。
谁能告诉我为什么会这样?
最佳答案
MSXML 抛出 HRESULT
OBJECT_NOT_FOUND
(0x800C0006) 因为您使用的 xml 没有指定字符集,详见 this question .或者 MSXML 找不到该文件。
关于c++ - MSXML6 中的第一次机会异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19812780/
Closed. This question does not meet Stack Overflow guidelines。它当前不接受答案。 想改善这个问题吗?更新问题,以便将其作为on-topic
我有 2 个不同的 View 设置 View 和默认 View 我无法将 uiswitch 值传递给默认 View 开关在 NSUserDefaults 中存储位置 设置 View .m - (voi
我猜大多数内置的随机生成器会返回类似这样的内容: [0.0, 1.0) 所以如果我想要 50% 的机会,我会使用这样的东西: if random() < .5 或类似的东西: if random()
有没有办法使用合作伙伴 WSDL 创建机会?我在网上看到的唯一示例是使用 Enterprise WSDL 创建,但它们特定于组织。 在我提到的其他链接中.. http://www.salesforce
背景 我正在使用支持向量机对不平衡类进行二元分类(即我的训练集中正负标签的比例约为 100)。我想优化以下参数:m(我从训练数据中采样的正标签与负标签的比率)、w(类权重)和 SVM 参数 C。 问题
我想根据百分比随机生成 YES 或 NO 所以我想“滚动”并有 25% 的机会击中 YES,75% 的机会击中 NO 是否希望有人能为我指出正确的方向,以最好的方式做到这一点,也许是一些文章或其他什么
我是一名优秀的程序员,十分优秀!