Jump to content

Datetime Or "..."


sybren
 Share

Recommended Posts

Hi folks,I want to have an element that either contains a dateTime or the literal string "...". Is there any way to specify this in Schema?The element in question is the creationTimestamp element as below:

	 <complexType name="persistedEntity">		  <sequence>			  <element name="editedBy" type="string" minOccurs="0" />			  <element name="creationTimestamp" type="dateTime" minOccurs="0" />			  <element name="status" type="syringe:entityStatus" minOccurs="0" />		  </sequence>	  </complexType>	<complexType name="role">		<complexContent>			<extension base="syringe:mnemonizedPersistedEntity">				<sequence>					<element name="name" type="string" />					<element name="builtIn" type="boolean" minOccurs="0" />				</sequence>			</extension>		</complexContent>	</complexType>

I would like to be able to use it as such:

			<role>				<editedBy>SYSTEM</editedBy>				<creationTimestamp>...</creationTimestamp>				<status>NORMAL</status>				<mnemonic>ADMIN</mnemonic>				<name>ADMIN</name>				<builtIn>true</builtIn>			</role>

The "..." is for testing purposes, a way to say "I don't care what dateTime is here", whereas the actual dateTime is used in any other case.Cheers,Sybren

Link to comment
Share on other sites

Instead of specifying xsd:dateTime on type, create a custom type that would be a union of xsd:dateTime, and your own type that defines "..." as a valid enumeration value.Particularly:

<xsd:element name="creationTimestamp" minOccurs="0" type="dateTimeExtended" /><xsd:simpleType name="dateTimeExtended">	<xsd:union memberTypes="xsd:dateTime dots"/></xsd:simpleType><xsd:simpleType name="dots">	<xsd:restriction base="xsd:string">		<xsd:enumeration value="..." />	</xsd:restriction></xsd:simpleType>

BTW, sorry for being so late in answering, but I only just now saw this topic.

Edited by boen_robot
Link to comment
Share on other sites

Instead of specifying xsd:dateTime on type, create a custom type that would be a union of xsd:dateTime, and your own type that defines "..." as a valid enumeration value.
Thank you, this is very useful and exactly what I hoped for :)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...