Jump to content
sybren

Datetime Or "..."

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

Share this post


Link to post
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

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...