Altova Mailing List Archives>Archive Index >xmlschema-dev Archive Home >Recent entries >Thread Prev - RE: XSD to ER Diagram [Thread Next] "Default" node definitionTo: "xmlschema-dev" <xmlschema-dev@--.---> Date: 9/15/2008 1:06:00 PM 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 elemen= ts 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 fro= m 1 to 300, and I need to define a "default" node at the end for the elem= ents 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="unb= ounded"> <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] From John.Tucker@n... Thu Sep 18 22:48:44 2008 Received: from farnsworth.w3.org ([128.30.52.43] helo=wiggum.w3.org) | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
