Imagine there is a defined simple type in definition.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="myType">
<xs:restriction base="xs:string" />
</xs:simpleType>
</xs:schema>
Then the type is used in 2 different xsds: use1.xsd and use2.xsd:
use1.xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="definition.xsd"></xs:include>
<xs:complexType name="ComplexType1">
<xs:attribute name="typeInstance1" type="myType" use="required" />
</xs:complexType>
</xs:schema>
use2.xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="definition.xsd"></xs:include>
<xs:complexType name="ComplexType2">
<xs:attribute name="typeInstance2" type="myType" use="required" />
</xs:complexType>
</xs:schema>
Then there are 2 files particularUse1.xsd and particularUse2.xsd, that redefine two previous xsds:
particularUse1.xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:redefine schemaLocation="use1.xsd">
<xs:simpleType name="myType">
<xs:restriction base = "myType">
<xs:enumeration value = "value1"/>
<xs:enumeration value = "value2"/>
</xs:restriction>
</xs:simpleType>
</xs:redefine>
</xs:schema>
particularUse2.xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:redefine schemaLocation="use2.xsd">
<xs:simpleType name="myType">
<xs:restriction base = "myType">
<xs:enumeration value = "value1"/>
<xs:enumeration value = "value2"/>
</xs:restriction>
</xs:simpleType>
</xs:redefine>
</xs:schema>
Now the question: how I can reuse the redefinition of myType in particularUse1.xsd and particularUse2.xsd that they are not duplicated.
Ideally it would be another file reused.xsd:
<xs:simpleType name="myType">
<xs:restriction base = "myType">
<xs:enumeration value = "value1"/>
<xs:enumeration value = "value2"/>
</xs:restriction>
</xs:simpleType>
The reference from the file reused.xsd are used in particularUse1.xsd and particularUse2.xsd.
The answer really depends on what constraints you put on the XSD files, the use of them, and the tooling that you'll be using to consume the XML Schema files. This diagram shows the layout of the files as described by the question.
Since you're redefining use1.xsd and use2.xsd, I would assume that these two are not editable (typically released/maintained by someone else).
Option 1
One way is to remove the redefines from particularUse#.xsd, put the redefine in reused.xsd, and make sure that all the files are used together (for e.g., in .NET you have the XmlSchemaSet object, you need to have reused.xsd and one or both of the particularUse#.xsd added to the set). By having the files in scope, the PSVI model will actually use the redefined myType, even though the reused.xsd is not explicitly referenced by any particularUse#.xsd file.
reused.xsd
<?xml version="1.0" encoding="utf-8"?>
<!--XML Schema generated by QTAssistant/XSR Module (http://www.paschidev.com)-->
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:redefine schemaLocation="definition.xsd">
<xsd:simpleType name="myType">
<xsd:restriction base="myType">
<xsd:enumeration value="value1"/>
<xsd:enumeration value="value2"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:redefine>
</xsd:schema>
particularUse1.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="use1.xsd"/>
</xs:schema>
particularUse2.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="use2.xsd"/>
</xs:schema>
Option 2
This other option should work with most mainstream XML Schema editors and it would give you the redefined myType when opening just a particularUse#.xsd file; this provided you don't mind pulling in scope for particularUse2.xsd the content from use1.xsd (based on the illustration).
reused.xsd
<?xml version="1.0" encoding="utf-8"?>
<!--XML Schema generated by QTAssistant/XSR Module (http://www.paschidev.com)-->
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:redefine schemaLocation="use1.xsd">
<xsd:simpleType name="myType">
<xsd:restriction base="myType">
<xsd:enumeration value="value1"/>
<xsd:enumeration value="value2"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:redefine>
</xsd:schema>
particularUse2.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="reused.xsd"/>
<xs:include schemaLocation="use2.xsd"/>
</xs:schema>
Regardless of the option, the PSVI shows exactly what you want.