I want to introduce a new namespace and prefix "extending" hod:string from xsd:string. Then in my schema I could define a string element:
<xsd:element name="Label" type="hod:string"/>
This way I can change the maxLength of all elements of type hod:string, for example, to 80. If that requirement changes later to 50, I could simply change hod:string's definition in a single place. This is what I'm trying--my IDE doesn't like line 15 ("cannot resolve symbol hod:string"):
<xs:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:hod="http://hod.com/2019/XMLSchema/hod"
attributeFormDefault="unqualified" elementFormDefault="qualified">
<xsd:simpleType name="hod:string">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="80"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="Object">
<xsd:sequence>
<xsd:element name="Label" type="hod:string"/>
<xsd:element name="MateriaID" type="GUID"/>
...
I changed all 'hod:string' with 'mystring' to verify I was defining things right and it seems happy, but I want to use the prefix if possible. (also tried to change this: attributeFormDefault="qualified" but it didn't seem to make a difference)
nameattribute of thesimpleTypeelement needs to be anNCNamesoname="hod:string"is not allowed. If you want to declare a type in a particular namespace set up a schema with the namespace as thetargetNamespaceandxs:importthe schema.XDocument.Loadto automatically load the .xsd file referenced in<xsd:import>. That is apparently not the case; I looked for an option to auto-load it but didn't find one. CallingXmlSchemaSet::addfor the new file fixed it.