2

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    

       "
>
Jefftopia
  • 2,105
  • 1
  • 26
  • 45
  • 2
    XML _files_ are just data. What an XML _parser_ does depends on the parser. Most won't bother to download the schema since it's additional overhead for (usually) no gain. – Tyler Eaves Jul 18 '13 at 14:10
  • Notice also that all three variants start with `xmlns="http://www.website.com/yolo" ....`. This seems to be just enough for your XML parser to connect to the necessary schema. Then, anything else is probably redundant (for schema loading/validation). – ColdFusion Jul 18 '13 at 17:57

1 Answers1

1

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.

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65