CuriousBug
CuriousBug

Reputation: 243

Linking xml schema namespace to instance xml instance

I am new to xml and using existdb to create a basic database. I have a schema xml with targetNamespace defined and I am using that namespace as schemaLocation in instance xml. 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?

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>

Upvotes: 0

Views: 131

Answers (2)

Yitzhak Khabinsky
Yitzhak Khabinsky

Reputation: 22311

Check it out here: eXist-db: Programmatically validate an XML document

Or here: eXist-db: XML Validation

"...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 ..."

Upvotes: 0

Michael Kay
Michael Kay

Reputation: 163595

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. With one or two possible exceptions, most software that reads XML does not trigger validation merely because it sees an xsi:schemaLocation attribute. There are many schema validators and many different ways of enabling schema validation, but it usually won't happen unless you request it explicitly.

Upvotes: 1

Related Questions