Jefftopia
Jefftopia

Reputation: 2155

How do XML files find the XML Schema?

I am interested in knowing more about the process that allows the XML files to actually locate the schema that validates it. I'm asking after testing three different xml headers (below) and noticing that the schema correctly validates with any variant.

XML Header 1:

<root xmlns="http://www.website.com/yolo"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 >

XML Header 2:

<root xmlns="http://www.website.com/yolo"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="

       http://www.website.com/yolo http://www.website.com/yolo    

      "
>

XML Header 3:

<root xmlns="http://www.website.com/yolo"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="

       http://www.website.com/yolo /u/me/folder/yolo.xsd    

       "
>

Upvotes: 2

Views: 1653

Answers (1)

C. M. Sperberg-McQueen
C. M. Sperberg-McQueen

Reputation: 25034

The XSD spec does not constrain the methods used by XSD validators to locate a schema for a document; it does define the xsi:schemaLocation hint to allow validators to read schema location information from the XML instance itself, but most validators accept schema bindings at invocation time. Your validator should provide documentation of how it finds schemas; you should consult that documentation.

Upvotes: 1

Related Questions