W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2003

Re: restrict content to values out of a xml file

From: <Stefan.Wachter@gmx.de>
Date: Fri, 28 Feb 2003 10:46:10 +0100 (MET)
To: Nadine.Koehler@sew-eurodrive.de
Cc: xmlschema-dev@w3.org
Message-ID: <27286.1046425570@www52.gmx.net>

If you want to use an enumeration constraint then the fragment to be
included in your schema document must be a valid schema fragment:

The schema document would look like:

<xs:element name="bla">
    <xi:include href="inc.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>

where inc.xml looks like:

<xs:restriction base="string" xmlns:xs="http://...">
  <xs:enumeration value="1"/>
  <xs:enumeration value="2"/>

The file inc.xml can easily be generated from another instance document
using XSLT.

The other possiblity using XInclude is to use key/keyref-constraints. The
disadvantage is that in order to validated an instance document the "value
file" must actually be included in the instance to validate. Therefore the
enumeration solution is to preferable.

Hope this helps,

PS: You have to make sure that your validator supports XIncludes. JBind
supports XIncludes in instance and schema documents.

> hi,
> thanx for the answer! 
> how can put that XIncludes thing into the enumeration? i couldnīt find any
> examples in the net.
> i have a structure like this, now what do i have to write into the
> enumeration tags?:
> <xs:element name="bla">
>      <xs:simpleType>
>          <xs:restriction base="xs:string">
>                 <xs:enumeration value="???"/>
>           </xs:restriction>
>      </xs:simpleType>
> </xs:element>
Received on Friday, 28 February 2003 04:46:42 UTC

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