External Schemas

An external schema is a separate file from the XML message that is referenced at the top of that message. To use external schemas, both the schema and the XML message that references it need to be sent to the receiver unless of course that receiver already has a copy of the schema that can be used. If you create an external schema for your messages, you only have to write the schema once, and then make a simple reference to that file from each message. If you opt to use an internal schema, the schema must be written every time you send a message, which can slow down your messaging time. To reference an external schema file, you can add a parameter to your top-level tag inside your XML message, which will look like this:

<Company xmlns="http://www.myserver.com/MySchema.xsd">

In this sample reference to an external schema file, the schema is stored in a file named MySchema.xsd on a Web server named www.myserver.com. This schema defines the structure and data rules for a Company message, so all tags in between this <Company> tag and its ending </Company> tag must adhere to the schema rules.

One way to simplify the storage and availability of your external schemas is to make them available on the Internet or your company's intranet. You would simply make your reference tag point to a URL that tells where the schema is located and let the network take care of the rest. If you are using industry-wide schemas or multicompany messaging systems, placing your schemas in a common location allows everyone to access and use those schemas, ensuring that all parties involved will be using the exact same schema every time.

0 0

Post a comment