Trouble validating an attribute of type "time"

This should cover W3C XML Schema, Relax NG and DTD related problems.
SSteve
Posts: 6
Joined: Thu Sep 22, 2005 11:38 pm
Location: Sierra Foothills, CA

Trouble validating an attribute of type "time"

Post by SSteve » Thu Sep 22, 2005 11:55 pm

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

Radu
Posts: 6582
Joined: Fri Jul 09, 2004 5:18 pm

Post by Radu » Fri Sep 23, 2005 8:35 am

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.

SSteve
Posts: 6
Joined: Thu Sep 22, 2005 11:38 pm
Location: Sierra Foothills, CA

Post by SSteve » Fri Sep 23, 2005 8:36 pm

Changing the times to HH:MM:SS did indeed make the document valid. Thanks, Radu.

Post Reply