0

An XSD file imports 3 XSDs as follows:

  <xs:import namespace="urn:swift:snl:ns.SwInt" schemaLocation="SwInt.xsd"/>
  <xs:import namespace="urn:swift:snl:ns.Sw" schemaLocation="Sw.xsd"/>     
  <xs:import namespace="urn:swift:snl:ns.SwSec" schemaLocation="SwSec.xsd"/> 

How do I include these imports in the XML created from this XSD?

kjhughes
  • 106,133
  • 27
  • 181
  • 240
Ahana
  • 1
  • 1

1 Answers1

0

XSDs are not imported into XML files. XSDs are imported or included into other XSD files.

XSDs can be associated with XML files. The most common mechanism for establishing that association is via hints conveyed through schemaLocation and noNamespaceSchemaLocation

Example: noNamespaceSchemaLocation

In the following XML file, purchaseReport is in no namespace, and the associated XSD can be found at http://www.example.com/ReportB.xsd:

<purchaseReport
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="http://www.example.com/ReportB.xsd">

   <!-- etc. -->

</purchaseReport>

Note that ReportB.xsd will have no targetNamespace.

Example: schemaLocation

In the following XML file, purchaseReport is in the http://www.example.com/Report namespace, and the associated XSD can be found at http://www.example.com/Report.xsd:

<purchaseReport
   xmlns="http://www.example.com/Report"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.example.com/ReportA
                       http://www.example.com/ReportA.xsd">

   <!-- etc. -->

</purchaseReport>

Note that ReportA.xsd will have a targetNamespace equal to the namespace of this XML file (http://www.example.com/ReportA).

In your particular case, the master XSD that imports the other XSDs would most likely itself have a namespace, so you would use the schemaLocation mechanism in an XML file to hint as to the location of the master XSD that governs the XML file.

Community
  • 1
  • 1
kjhughes
  • 106,133
  • 27
  • 181
  • 240