Page 1 of 1

Trouble validating an attribute of type "time"

Posted: Thu Sep 22, 2005 11:55 pm
by SSteve
Here's a fragment of my XSD file:

Code: Select all

<xs:element name="Track" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="length" type="xs:time" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
[/color]

and a fragment of my XML file:

<Track length="5:57">My Funny Valentine</Track>

When I attempt to validate the file, Oxygen gives me these errors:

http://www.w3.org/TR/xmlschema-2/#cvc-datatype-valid E cvc-datatype-valid.1.2.1: '5:57' is not a valid value for 'time'.
http://www.w3.org/TR/xmlschema-1/#cvc-attribute E cvc-attribute.3: The value '5:57' of attribute 'length' on element 'Track' is not valid with respect to its type, 'time'.

When I validate the same file with XMLSpy, I get no validation errors. I'm still a newbie at XSD, so I'm wondering if there's something I'm doing wrong.

(I realize that 'duration' would be a more appropriate data type than 'time', but I have to work within this restriction.)

Thanks for any help!

-Steve

Posted: Fri Sep 23, 2005 8:35 am
by Radu
Hi Steve

The attribute time must appear with all the parts (HH:MM:SS) like: "09:35:20".
For more information about time values see XSD Date and Time Data Types

Regards, Radu.

Posted: Fri Sep 23, 2005 8:36 pm
by SSteve
Changing the times to HH:MM:SS did indeed make the document valid. Thanks, Radu.