Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.xsd xs:int overloading

Status
Not open for further replies.

simonchristieis

Programmer
Jan 10, 2002
1,144
GB
I am looking to overload a simple type that has an xs:int restriction, I want the next restriction to be xs:int or empty. I know I can use the same process for an xs:string.

<snipped>
Code:
<xs:simpleType name="VerifyDateType">
	<xs:restriction base="VerifyDateType"/>
</xs:simpleType>

<xs:simpleType name="VerifyDateType">
	<xs:restriction base="xs:int"/>
</xs:simpleType>
</snipped>

I am looking for something like:

Code:
<xs:simpleType name="VerifyDateType">
	<xs:restriction base="VerifyDateType">
                <xs:minLength value="0"/>
        </xs:restriction>
</xs:simpleType>


Thanks in advance

Simon

 
The problem may be already at the prelude leading to the problem itself. I am not sure if we can give a simplyType of name which itself is the base of the simpleType in question to impose further restriction.
<xs:simpleType name=[tt][red]"VerifyDateType"[/red][/tt]>
<xs:restriction base=
[tt][red]"VerifyDateType"[/red][/tt]/>
</xs:simpleType>

Is it kind of typo? or is it the real intention to convey?
 
Thanks tsuji,

The only way round the problem was to define the int as an int or string, and allow the string to have zero length. This was done using a custom type with an enumeration equalling "".

Custom Types:
Code:
<xs:simpleType name="int-or-empty">
	<xs:union memberTypes="xs:int empty-string"/>
</xs:simpleType>
<xs:simpleType name="empty-string">
	<xs:restriction base="xs:string">
		<xs:enumeration value=""/>
	</xs:restriction>
</xs:simpleType>

Base Type (BaseType.xsd):
Code:
<xs:simpleType name="VerifyDateType">
	<xs:restriction base="int-or-empty"/>
</xs:simpleType>

Redefined Overload:
Code:
<xs:redefine schemaLocation="BaseType.xsd">
	<xs:simpleType name="VerifyDateType">
		<xs:restriction base="VerifyDateType">
			<xs:pattern value="[0-9]{8}"/>
		</xs:restriction>
	</xs:simpleType>
</xs:redefine>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top