Defining a XML Schema with a sequence of elements containing 2 floats

vashan

New Member
I'm trying to define a schema for XML-files like this:\[code\]<?xml version="1.0" encoding="UTF-8" ?><traverse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd"> <cp>1.0 2.0</cp> <cp>3.0 -2.0</cp> <cp>-1.365575 0</cp> <cp>4 1.3</cp></traverse>\[/code\]It has to be a sequence of at least 3 cp's (control points) each defined by two doubles. I tried this (without the constraint that there have to be at least 3 control points):\[code\]<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="traverse"> <xs:complexType> <xs:sequence> <xs:element name="cp" type="control-point" /> </xs:sequence> </xs:complexType> </xs:element> <xs:simpleType name="listOfValues"> <xs:list itemType="xs:double"/> </xs:simpleType> <xs:simpleType name="control-point"> <xs:restriction base="listOfValues"> <xs:length value="http://stackoverflow.com/questions/11126353/2"/> </xs:restriction> </xs:simpleType></xs:schema>\[/code\]When I try to validate the XML-file above, XMLSpy tells me that cp-tags arent't allowed inside the traverse-tag. Can anyone help me? Thanks!
 
Back
Top