16,819
社区成员




bool Configure::open(void)
{
if(!IsOpen())
{
ConfigureFileSource.setFileName(ConfigureFile);
if(ConfigureFileSource.open(QIODevice::ReadWrite))
{
if(XMLDocument.setContent(&ConfigureFileSource))
{
Root=XMLDocument.documentElement();
if(!Root.isNull())
{
QXmlSchemaValidator SchemaValidator;
QXmlSchema Schema;
QFile SchemaFile;
SchemaFile.setFileName("ConfigureSchema/ConfigureSchema.xsd");
if(SchemaFile.open(QIODevice::ReadOnly))
{
if(Schema.load(&SchemaFile))
{
SchemaValidator.setSchema(Schema);
if(SchemaValidator.validate(&ConfigureFileSource))
{
OpenFlag=true;
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
QByteArray data( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<xsd:schema"
" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""
" xmlns=\"http://qt.nokia.com/xmlschematest\""
" targetNamespace=\"http://qt.nokia.com/xmlschematest\""
" version=\"1.0\""
" elementFormDefault=\"qualified\">"
"</xsd:schema>" );
QXmlSchema schema;
schema.load(data);
if (schema.isValid())
qDebug() << "schema is valid";
else
qDebug() << "schema is invalid";
出处
http://doc.qt.io/qt-4.8/qxmlschema.html
<?xml version="1.1" encoding="UTF-8"?>
<Configure xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="Configure ConfigureSchema/ConfigureSchema.xsd"
xmlns="Configure">
<Modules>
<Document>
<DocumentSetting Type="MaxLoadSize" Setting="4G" /> <!--设置最大加载文件的大小是4G-->
<DocumentSetting Type="MaxTab" Setting="20" /> <!--设置最大tab大小是20-->
</Document>
<Cache>
<CacheSetting Type="DocumentCache" State="true" Timeout="10" /> <!--启用文档缓存,超时时间设置10s-->
<CacheSetting Type="PluginStateCache" State="true" Timeout="10" /> <!--启动插件状态缓存管理,超时时间10s-->
<CacheSetting Type="PluginConfigCache" State="true" Timeout="10" /> <!--启动插件配置缓存管理,超时时间10s-->
</Cache>
</Modules>
<Plugin>
<PlugServer Default="Default">
<ServerList>
<Server ID="Default" IP="127.0.0.1" Port="4545" Protocol="PluginManager" /> <!--设置默认插件服务器镜像地址-->
</ServerList>
</PlugServer>
<Manager>
<PlugServer Mode="Off" DefaultSelect="Default" > <!--关闭插件市场服务器-->
<AutoSort Strategy="Fastest" /> <!--启动服务器列表映像自动排序-->
</PlugServer>
</Manager>
</Plugin>
</Configure>