- From: togix <togix@libero.it>
- Date: Mon, 15 Sep 2008 11:06:24 +0200
- To: "xmlschema-dev" <xmlschema-dev@w3.org>
Hi all, I'm currently working on a XML file and related Schema for its validation.. I need now to define a "default" node, that will contain all the elements that do not match any of the previous nodes of the same type. Eg. I define three ranges for node "length", that will contain values from 1 to 300, and I need to define a "default" node at the end for the elements with value > 300. Is it possible to do so using the XML Schema? Any suggestion will be appreciated. Tranks, Claudio. Example of XML file: [code]<?xml version="1.0" encoding="UTF-8"?> <rules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <length> <range name="len_1"> <minval>1</minval> <maxval>100</maxval> </range> <range name="len_2"> <minval>101</minval> <maxval>200</maxval> </range> <range name="len_3"> <minval>201</minval> <maxval>300</maxval> </range> <!-- nodo <range name="default"> --> </length> </rules>[/code] Example of XSD file: [code]<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <!-- ### definition of simple elements and attributes ### --> <xs:element name="minval" type="xs:positiveInteger"/> <xs:element name="maxval" type="xs:positiveInteger"/> <xs:attribute name="name" type="xs:string"/> <!-- ### definition of complex elements ### --> <xs:element name="rules"> <xs:complexType> <xs:sequence> <!-- per Length --> <xs:element name="length"> <xs:complexType> <xs:sequence> <xs:element name="range" minOccurs="1" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element ref="minval"/> <xs:element ref="maxval"/> </xs:sequence> <xs:attribute ref="name"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>[/code]
Received on Tuesday, 16 September 2008 04:38:17 UTC