Using a local XSD for an external namespace or XSD location

Sometimes an XSD refers to another XSD that is external. Requiring XSD processing to connect across the internet to access that XSD is strongly discouraged. Network connections have low performance and are unreliable in a production system, and the external XSD might not be reachable. A best practice is to copy the XSD locally to the resource tree and specify how to map the external XSD namespace to a local XSD.

In some situations it is common for an XSD to define an external namespace URI without specifying the external download location for an XSD.

In both cases, Gosu provides a registry file, gwxmlmodule.xml, that lets you use a local XSD instead. The file is located in the configuration > res module.

The base configuration includes multiple gwxmlmodule.xml files located in various modules. The configuration > res > gwxmlmodule.xml instance is the application-level file. The other instances of the file are for Guidewire internal use only and are not visible in Studio. Their purpose is to remap common W3C XSD files to local locations to avoid unnecessarily connecting to the W3C web site.

See also

Use a local XSD for an external namespace URI or XSD location URL

To remap an external namespace to a local location, edit the gwxmlmodule.xml file.

Procedure

  1. Download a copy of the target external XSD.
  2. Place that XSD in the local resources hierarchy.
  3. In Studio, open the gwxmlmodule.xml file. The file is located in the configuration > res module. Add a schema-locations element with an xmlns attribute that specifies the local resource location.
  4. Add a child schema element to the schema-locations element.
  5. Set the element's resourcePath attribute to the fully qualified path to the local XSD. You must use a forward slash (/), not a period (.), to indicate any subpackage.
  6. To direct Gosu to find and remap an external namespace declaration in parsed XSD, set the xmlNamespace attribute to the external XSD namespace URI. The value starts with http:// so it looks like a quoted URL, but it is actually a unique ID and not a URL address.
  7. To direct Gosu to find and remap an external XSD download location in parsed XSD, set the externalLocations attribute to the external XSD URL address. This value may also be useful for your own reference, in case you need to download the latest version of the file.

Example

Sample schema-locations and schema elements are defined in the following example.
<!-- XML namespaces and external schema locations can be registered in this file to 
     remap to local resources.
     The remappings are used when either an <xsd:import> is encountered without a 
     <schemaLocation> element, or when an external schema location is specified. The 
     "externalLocations" attribute is a space-delimited list of external references to 
     recognize for a particular schema.
-->
<schema-locations xmlns="http://guidewire.com/xml/module">
  <schema xmlNamespace="http://guidewire.com/archiving" 
          resourcePath="gw/plugin/archiving/archiving.xsd" 
          externalLocations=""/>
  <schema xmlNamespace="http://guidewire.com/importing" 
          resourcePath="gw/api/importing/importing.xsd" 
          externalLocations=""/>
</schemalocations>