Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


"Default" node definition

From: "togix" <togix@------.-->
To: "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)


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent