Page 1 of 1

Creating a new data type

Posted: Mon Aug 13, 2007 1:46 pm
by carol.aboody
Hi all

I have 2 questions on creating data types:

1)
I need my "datereturn" attribute to be in a specific format, or contain empty value.
For example: 2007-02-02 12:22:00, or "".

2)I need my "avgrank" attribute to be decimal OR empty. If i use decimal with an empty answer i get a validation error.

This is my Schema:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<!--W3C Schema generated by XMLSpy v2007 sp2 (http://www.altova.com)-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="getrank">
<xs:complexType>
<xs:attribute name="rc" use="required" type="xs:int"/>
<xs:attribute name="datereturn" use="required" type="xs:????????"/>
<xs:attribute name="avgrank" use="required" type="xs:????????"/>

</xs:complexType>
</xs:element>
</xs:schema>
Thanks

Solution to empty-decimal problem,date format still an issue

Posted: Mon Aug 13, 2007 2:20 pm
by carol.aboody
I found a solution to the second problem here :
http://xsd.stylusstudio.com/2003May/post03006.htm

I still need help for the date format.

Thanks

Posted: Mon Aug 13, 2007 10:10 pm
by jkmyoung
If you're not using the standard date format, you could create a pattern based on an xs:string, eg
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="([0-9]{4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9])|"/>
</xs:restriction>
</xs:simpleType>

Can't remember if [0-9]{4} works, you might need to use [0-9][0-9][0-9][0-9]

Posted: Tue Aug 14, 2007 4:53 pm
by carol.aboody
I tried that, i got this message:

Validation Error Message: s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw '.'.

I couldn't find the meaning of it.