Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to validate a XSD ?

Status
Not open for further replies.

Ezeeckiel

Programmer
Joined
May 10, 2004
Messages
3
Location
BE
Hi !

I'm brand new in this wonderful love that xml is but i've got some troubles to create mty first xsd file. I've looked a lot on the internet and didn't really find THE example i need.

I try to validate it thanks to :
Here is the file :

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd=" targetNamespace=" <xsd:include schemaLocation="
<xsd:simpleType name="IDType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="EntityType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="ListType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="TextType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="Frame_RangeType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="Keyframe_FrameType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="TemporalRelationsType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="StateType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="Bounding_BoxType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="ColorType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="CentroidType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="MovingDirectionType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="EventListType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="Tracking_StampType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="SpeedType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

<xsd:attributeGroup name="EventAttributes">
<xsd:attribute name="Event_ID" type="IDType" use="required"/>
<xsd:attribute name="Event_Type" type="EntityType" use="required"/>
<xsd:attribute name="Actors_List" type="ListType" use="required"/>
<xsd:attribute name="Event_Text" type="TextType"/>
<xsd:attribute name="Event_Frame_Range" type="Frame_RangeType"/>
<xsd:attribute name="Event_Keyframe_Frame" type="Keyframe_FrameType"/>
</xsd:attributeGroup>

<xsd:attributeGroup name="MobileObjectAttributes">
<xsd:attribute name="MobileObject_Type" type="EntityType"/>
<xsd:attribute name="MobileObject_Text" type="TextType"/>
<xsd:attribute name="MobileObject_Frame_Range" type="Frame_RangeType"/>
<xsd:attribute name="MobileObject_Keyframe_Frame" type="Keyframe_FrameType"/>
<xsd:attribute name="MobileObject_Bounding_Box" type="Bounding_BoxType"/>
<xsd:attribute name="MobileObject_Centroid" type="CentroidType"/>
</xsd:attributeGroup>

<xsd:attributeGroup name="TrackingAttributes">
<xsd:attribute name="Tracking_Stamp" type="IDType" use="required"/>
<xsd:attribute name="Tracking_Frame_Range" type="Frame_RangeType"/>
<xsd:attribute name="Tracking_Bounding_Box" type="Bounding_BoxType"/>
<xsd:attribute name="Tracking_Centroid" type="CentroidType"/>
</xsd:attributeGroup>

<xsd:attribute name="speed" type="xsd:string"/>
<xsd:attribute name="event_list" type="xsd:string"/>
<xsd:attribute name="color" type="xsd:string"/>
<xsd:attribute name="moving_direction" type="string"/>
<xsd:attribute name="state" type="xsd:string"/>
<xsd:attribute name="sub_events" type="xsd:string"/>
<xsd:attribute name="temporal_relations" type="xsd:string"/>
etc...
</xsd:schema>


My question is WAHT IS WRONG with it ?
Here are the errors the validator returns :

# Type reference '#IDType' is unresolved, locationURI: null, line: 1, column: 1, node: [xsd:attribute: null], annotationURI: null
# Type reference '#EntityType' is unresolved, locationURI: null, line: 1, column: 1, node: [xsd:attribute: null], annotationURI: null
# Type reference '#ListType' is unresolved, locationURI: null, line: 1, column: 1, node: [xsd:attribute: null], annotationURI: null
# Type reference '#TextType' is unresolved, locationURI: null, line: 1, column: 1, node: [xsd:attribute: null], annotationURI: null
# Type reference '#Frame_RangeType' is unresolved, locationURI: null, line: 1, column: 1, node: [xsd:attribute: null], annotationURI: null
# Type reference '#Keyframe_FrameType' is unresolved, locationURI: null, line: 1, column: 1, node: [xsd:attribute: null], annotationURI: null
# Type reference '#EntityType' is unresolved, locationURI: null, line: 1, column: 1, node: [xsd:attribute: null], annotationURI: null
# Type reference '#TextType' is unresolved, locationURI: null, line: 1, column: 1, node: [xsd:attribute: null], annotationURI: null
# Type reference '#Frame_RangeType' is unresolved, locationURI: null, line: 1, column: 1, node: [xsd:attribute: null], annotationURI: null
# Type reference '#Keyframe_FrameType' is unresolved, locationURI: null, line: 1, column: 1, node: [xsd:attribute: null], annotationURI: null
# Type reference '#Bounding_BoxType' is unresolved, locationURI: null, line: 1, column: 1, node: [xsd:attribute: null], annotationURI: null
# Type reference '#CentroidType' is unresolved, locationURI: null, line ..... etc..


So what do you thihnk ?

Olivier
 
I loaded your document into XMLSpy, and it complained about this:
Code:
 <xsd:attributeGroup name="EventAttributes">
        <xsd:attribute name="Event_ID" type="IDType" use="required"/>
You're saying you have an attribute named "Event_ID" which is of type "IDType", but it can't find a definition for "IDType".

Yes, it's defined up top, but it still doesn't like it. I would just use xsd:string, since your IDType doesn't have any other restrictions on it.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Salut!

Thanks for your answer !
It made me understand that i missed something...
Could you either explain me how to define this IDType ? (i thought :
<xsd:simpleType name="IDType">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>

was the definition it needed )
You said that I should use only a xsd:string since there's no restrictions. I'm starting with this because it easier not to make mistakes with simple examples and it'll get more complicated very soon. That's why i'd like to keep this kind of declaration.

Now my question is : "how to define my own members ?"
(i'm not even sure my question is something i can ask, maybe it's just all wrong lol)

Olivier
 
I wouldn't even try declaring my own types for something as simple as that.

Another problem may be that your type is geared towards use as an element, and you're trying to use it as an attrbute. I've defined my own types for elements, but never for attributes -- don't know if it's possible.

My advice is, you're already making it complicated.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top