简体   繁体   English

将 xml 架构命名空间链接到实例 xml 实例

[英]Linking xml schema namespace to instance xml instance

I am new to xml and using existdb to create a basic database.我是 xml 的新手,并使用existdb 创建了一个基本的数据库。 I have a schema xml with targetNamespace defined and I am using that namespace as schemaLocation in instance xml.我有一个定义了 targetNamespace 的架构 xml,我在实例 xml 中使用该命名空间作为 schemaLocation。 However, I don't understand when the instance document gets evaluated against schema.但是,我不明白何时根据架构评估实例文档。 Even if I put invalid schema in instance document, all queries work.即使我在实例文档中放置了无效的架构,所有查询也能正常工作。 Am I missing something?我错过了什么吗? How do we link schema and instance xmls and both with the xquery?我们如何将架构和实例 xmls 以及两者都与 xquery 联系起来?

instance document:

    <entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://NamespaceTest.com/CommonTypes schema.xsd">
    ...
    </entities>

schema document(document name is schema.xsd)
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://NamespaceTest.com/CommonTypes">
...
</xs:schema>

Validation against a schema can be performed either by an XML parser or by a specialist schema validator, and in either case the schema location can be obtained either from the xsi:schemaLocation attribute or from elsewhere.对模式的验证可以由 XML 解析器或专业模式验证器执行,在任何一种情况下,模式位置都可以从xsi:schemaLocation属性或其他地方获得。 With one or two possible exceptions, most software that reads XML does not trigger validation merely because it sees an xsi:schemaLocation attribute.除了一两个可能的例外,大多数读取 XML 的软件不会仅仅因为看到xsi:schemaLocation属性就触发验证。 There are many schema validators and many different ways of enabling schema validation, but it usually won't happen unless you request it explicitly.有许多模式验证器和许多不同的启用模式验证的方法,但除非您明确请求,否则通常不会发生。

Check it out here: eXist-db: Programmatically validate an XML document在这里查看: eXist-db:以编程方式验证 XML 文档

Or here: eXist-db: XML Validation或者在这里: eXist-db:XML 验证

"...Implicit validation. Implicit validation is executed automatically when documents are inserted into the database. To enable implicit validation, change eXist-db configuration by editing conf.xml. The following two items must be configured: (1) Validation mode (2) Catalog Entity Resolver ..." "...隐式验证。隐式验证在文档插入数据库时​​自动执行。要启用隐式验证,通过编辑conf.xml更改eXist-db配置。必须配置以下两项: (1)验证模式( 2)目录实体解析器……”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM