Hosting W3 XML Schema files locally

I work at a company where we have our own XML language with its own set of schemas that validate against the W3 schema. For business reasons, I need to host these files internally instead of relying on the web hosted versions. I have little experience with XML schemas and am wondering what exactly this means. Is it as simple as copying and pasting the page source into my own file and pointing our other schemas there? Do I need to worry about the namespace documents as well? Any help here is appreciated. Thanks.

  • 1

    @kjhughes I guess I thought that the XSD I linked to was the XSD I want to host locally – it is what is linked in our schemas: <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>.

    – 

  • Depending on your schema processor, you may even find that for some popular schemas like the one for the XML namespace you don’t even need to supply a schemaLocation – the schema processor already knows where to find it.

    – 

  • @kjhughes So I do not need to host the namespace file locally? Will this cause problems if the W3 site is unreachable? (the use case is in the event of a DDOS attack blocking us from accessing W3).

    – 

  • @MichaelKay I might be wrong, I don’t think in my use case this is helpful. The issue is that sometimes W3 is inaccessible for us due to DDOS attacks. In this case, even if the processor knew where to look, it wouldn’t be able to find it anyway, correct? Or are you saying there is somewhere locally I can put the schema and the processor will look there?

    – 

  • @kjhughes I think I am getting terminology confused. I know now I need to host xml.xsd locally. I am wondering if I need to host http://www.w3.org/XML/1998/namespace. Is that what you mean when you say not to change the namespace URI – that I do not need to host that file? Apologies, I don’t quite have the domain language necessary to express myself.

    – 

To host external XSDs, including any from W3C, locally:

  1. Identify external XSD dependencies.

    You can identify an XSD’s external dependencies through the transitive closure of all XSD’s given by xs:include and xs:import @schemaLocation attributes. (No xs:include or xs:import implies no dependencies.)

  2. Copy the XSDs locally.

    Note that to actually retrieve xml.xsd, use a tool other than a browser (e.g. wget) or view the source of the file served to your web browser.

  3. Adjust references to the XSDs.

    Update the @schemaLocation attributes to reference the local
    rather than the remote copy. See
    How to reference a local XML Schema file correctly? Or, use an XML Catalog to remap to a local location.

Note that you do not need to change any namespace URIs, which are lexical constructs that do not need to be retrievable.

Leave a Comment