W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2008

"Default" node definition

From: togix <togix@libero.it>
Date: Mon, 15 Sep 2008 11:06:24 +0200
Message-Id: <K78BYO$64ED7FEB21FFAF18D7D23E0B28B9FFCF@libero.it>
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.


Example of XML file:
[code]<?xml version="1.0" encoding="UTF-8"?>
<rules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <range name="len_1">
    <range name="len_2">
    <range name="len_3">
    <!--   nodo <range name="default">   -->

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">
        <!-- per Length -->
        <xs:element name="length">
              <xs:element name="range" minOccurs="1" maxOccurs="unbounded">
                    <xs:element ref="minval"/>
                    <xs:element ref="maxval"/>
                  <xs:attribute ref="name"/>
Received on Tuesday, 16 September 2008 04:38:17 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:48 UTC