Importing a custom namespace / custom type into an XSD

I have a custom type that I use in a couple of my documents.

Unfortunately, in the past I was adding this to each xsd, as I needed it. However, I've now figured out how to import it into xsd files as needed.

Original schema

Currently I'm adding the following at the top of each xsd:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:simpleType name="customDateType">
		<xs:restriction base="xs:string">
			<xs:annotation>
				<xs:documentation><![CDATA[Allows for a year, a year and a month, or a year, month, and day, to be defined.]]></xs:documentation>
			</xs:annotation>
			<xs:pattern value="\d{4}(-\d{2}){0,2}"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- Remainder of schema goes here. -->
</xs:schema>

New schema

Instead of the above I create a new file, for example media.jamesrskemp.com/xsd/2010/09/04/CustomDateType.xsd, which looks like the following:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://media.jamesrskemp.com/ns/CustomDateType" version="1">
	<xs:simpleType name="customDateType">
		<xs:restriction base="xs:string">
			<xs:annotation>
				<xs:documentation><![CDATA[Allows for a year, a year and a month, or a year, month, and day, to be defined.]]></xs:documentation>
			</xs:annotation>
			<xs:pattern value="\d{4}(-\d{2}){0,2}"/>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>

Then I need to update the original XSD to refer to this. After some messing around with oXygen, it turns out it needs to look like this:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cdt="http://media.jamesrskemp.com/ns/CustomDateType">
	<xs:import namespace="http://media.jamesrskemp.com/ns/CustomDateType" schemaLocation="http://media.jamesrskemp.com/xsd/2010/09/04/CustomDateType.xsd"/>
	<!-- Remainder of schema continues here. -->

And with those minor changes I, or anyone else, can use my custom type.