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">
  <xs:simpleType>
    <xi:include href="inc.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
   </xs:simpleType>
</xs:element>

where inc.xml looks like:

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

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,
--Stefan

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:36 GMT